Une façon de faire est de choisir un "destinataire" syslog (par exemple "user1"), qu'on indique dans le lancement de domoticz. Ensuite, suivant ce qu'on utilise (syslog, syslog-ng, rsyslog), rediriger les messages "user1" vers ce qu'on veut.salinois a écrit : 13 févr. 2024, 09:51 bonjour Flying Domotic ,
c'est ce que j'ai pu faire avec mon RPi avec l'appli "Weewx" de ma station meteo;
mais j'arrive pas à trouver la bonne syntaxe dans le fichier domoticz.sh pour que ça parte vers mon syslog externe...
salinois
LOG vers rsyslog
-
Flying Domotic
- Messages : 772
- Inscription : 10 mars 2020, 15:26
Re: LOG vers rsyslog
-
pierrotori
- Messages : 821
- Inscription : 29 févr. 2016, 12:11
Re: LOG vers rsyslog
justement on a des logs system dans syslog et les journaux qui contiennent des log de syslogFlying Domotic a écrit : 13 févr. 2024, 09:08 L'un n'empêche pas l'autre ... On peut écrire dans un log où on veut, et envoyer des messages syslog en même temps (c'est ce que je fais).
et il y a aussi rsyslog. Moi je ne sais pas lequel garder dans ces fichiers en double ou triple ?
car tant qu'à faire autant avoir un seul fichier de log , non ?
Re: LOG vers rsyslog
donc dans un 1er temps, dans le fichier domoticz.shFlying Domotic a écrit : 13 févr. 2024, 16:16 Une façon de faire est de choisir un "destinataire" syslog (par exemple "user1"), qu'on indique dans le lancement de domoticz. Ensuite, suivant ce qu'on utilise (syslog, syslog-ng, rsyslog), rediriger les messages "user1" vers ce qu'on veut.
Code : Tout sélectionner
#DAEMON_ARGS="user1 "et dans rsyslog.conf
Code : Tout sélectionner
user1 @192.168.x.x:514-
Flying Domotic
- Messages : 772
- Inscription : 10 mars 2020, 15:26
Re: LOG vers rsyslog
Si on regarde un peu la doc citée plus bas à https://www.domoticz.com/wiki/Set_up_Domoticz_to_syslog, on s’aperçoit que le format de la commande estsalinois a écrit : 13 févr. 2024, 21:15 donc dans un 1er temps, dans le fichier domoticz.sh====> je suis sur de rien iciCode : Tout sélectionner
#DAEMON_ARGS="user1 "
Code : Tout sélectionner
DAEMON_ARGS="-loglevel normal -syslog local1 -daemon -www .........."Code : Tout sélectionner
#DAEMON_ARGS="-syslog user1 "Code : Tout sélectionner
DAEMON_ARGS="-syslog user1 "On y découvre qu'il y a quelques autres arguments utiles du genre
- -deamon (pour que ça démarre en deamon)
- -www 8080 (pour qu'on utilise le port 8080 en mode http;
- -sslwww 433 (pour qu'on utilise le port 443 en mode https:)
- -log /var/log/domoticz.log (pour avoir un beau log centralisé)
Code : Tout sélectionner
#! /bin/sh
### BEGIN INIT INFO
# Provides: domoticz
# Required-Start: $network $remote_fs $syslog
# Required-Stop: $network $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Home Automation System
# Description: This daemon will start the Domoticz Home Automation System
### END INIT INFO
# Do NOT "set -e"
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
DESC="Domoticz Home Automation System"
NAME=domoticz
USERNAME=pi
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
DAEMON=/home/pi/domoticz/$NAME
DAEMON_ARGS="-daemon"
#DAEMON_ARGS="$DAEMON_ARGS -daemonname $NAME -pidfile $PIDFILE"
DAEMON_ARGS="$DAEMON_ARGS -www 8080"
DAEMON_ARGS="$DAEMON_ARGS -sslwww 443"
DAEMON_ARGS="$DAEMON_ARGS -log /var/log/domoticz.log"
#DAEMON_ARGS="$DAEMON_ARGS -syslog local1"
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions
pidof_domoticz() {
# if there is actually a domoticz process whose pid is in PIDFILE,
# print it and return 0.
if [ -e "$PIDFILE" ]; then
if pidof domoticz | tr ' ' '\n' | grep -w $(cat $PIDFILE); then
return 0
fi
pi@noailles:~ $ cat /etc/init.d/domoticz.sh
#! /bin/sh
### BEGIN INIT INFO
# Provides: domoticz
# Required-Start: $network $remote_fs $syslog
# Required-Stop: $network $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Home Automation System
# Description: This daemon will start the Domoticz Home Automation System
### END INIT INFO
# Do NOT "set -e"
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
DESC="Domoticz Home Automation System"
NAME=domoticz
USERNAME=pi
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
DAEMON=/home/pi/domoticz/$NAME
DAEMON_ARGS="-daemon"
DAEMON_ARGS="$DAEMON_ARGS -www 8080"
DAEMON_ARGS="$DAEMON_ARGS -sslwww 443"
DAEMON_ARGS="$DAEMON_ARGS -log /var/log/domoticz.log"
DAEMON_ARGS="$DAEMON_ARGS -syslog local1"
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions
pidof_domoticz() {
# if there is actually a domoticz process whose pid is in PIDFILE,
# print it and return 0.
if [ -e "$PIDFILE" ]; then
if pidof domoticz | tr ' ' '\n' | grep -w $(cat $PIDFILE); then
return 0
fi
fi
return 1
}
#
# Function that starts the daemon/service
#
do_start()
{
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
start-stop-daemon --chuid $USERNAME --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
|| return 1
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
$DAEMON_ARGS \
|| return 2
}
#
# Function that stops the daemon/service
#
do_stop()
{
# Return
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2
# Wait for children to finish too if this is a daemon that forks
# and if the daemon is only ever run from this initscript.
# If the above conditions are not satisfied then add some other code
# that waits for the process to drop all resources that could be
# needed by services started subsequently. A last resort is to
# sleep for some time.
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
[ "$?" = 2 ] && return 2
# Many daemons don't delete their pidfiles when they exit.
rm -f $PIDFILE
return "$RETVAL"
}
case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
ntp-wait
[ $? -ne 0 ] && echo WARNING : NTP KO, Domoticz may not start!!! || echo INFO : NTP OK, starting Domoticz...
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
status)
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
;;
reload)
log_daemon_msg "Reloading $DESC" "$NAME"
PID=$(pidof_domoticz) || true
if [ "${PID}" ]; then
kill -HUP $PID
log_end_msg 0
else
log_end_msg 1
fi
;;
restart)
log_daemon_msg "Restarting $DESC" "$NAME"
do_stop
case "$?" in
0|1)
do_start
case "$?" in
0) log_end_msg 0 ;;
1) log_end_msg 1 ;; # Old process is still running
*) log_end_msg 1 ;; # Failed to start
esac
;;
*)
# Failed to stop
log_end_msg 1
;;
esac
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|status|restart|reload}" >&2
exit 3
;;
esac
:
Sur le principe, il est clair que lire la doc aide souvent à comprendre à minima le contexte. Et ça aide à tester des "trucs" qui ont plus de chances de marcher ,-)
Re: LOG vers rsyslog
c'est ce que j'ai fait, mais peut-etre que je comprends pas tout
je l'ai bien modifié ( le fichier ) pour envoyer les logs dans /var/log/domoticz.log => ça fonctionne
===> voilà ma faute , j'avais oublié "$DAEMON_ARGS" devant la derniere ligne
mon rsyslog était bien configuré, lui
donc j'ai quand même lu un peu.....
et ça fonctionne.
JE me suis éparpillé un peu car j'étais en train aussi de configurer les dispositifs pour ma Livebox-5
j'étais pas loin du but.
merci à toi
salinois
je l'ai bien modifié ( le fichier ) pour envoyer les logs dans /var/log/domoticz.log => ça fonctionne
Code : Tout sélectionner
# Do NOT "set -e"
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
DESC="Domoticz Home Automation System"
NAME=domoticz
USERNAME=jeeper
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
DAEMON=/home/jeeper/domoticz/$NAME
DAEMON_ARGS="-daemon"
#DAEMON_ARGS="$DAEMON_ARGS -daemonname $NAME -pidfile $PIDFILE"
DAEMON_ARGS="$DAEMON_ARGS -www 8080"
DAEMON_ARGS="$DAEMON_ARGS -sslwww 443"
#DAEMON_ARGS="$DAEMON_ARGS -log /tmp/domoticz.txt"
DAEMON_ARGS="$DAEMON_ARGS -log /var/log/domoticz.log"
DAEMON_ARGS="-syslog user1 "mon rsyslog était bien configuré, lui
donc j'ai quand même lu un peu.....
et ça fonctionne.
JE me suis éparpillé un peu car j'étais en train aussi de configurer les dispositifs pour ma Livebox-5
j'étais pas loin du but.
merci à toi
salinois
Dernière modification par salinois le 13 févr. 2024, 23:20, modifié 2 fois.
-
Flying Domotic
- Messages : 772
- Inscription : 10 mars 2020, 15:26
Re: LOG vers rsyslog
Il y a un indice dans mon message, sauras-tu le trouver ?
Re: LOG vers rsyslog
j'ai modifié mon post avant pendant que tu étais en train de repondre
-
Flying Domotic
- Messages : 772
- Inscription : 10 mars 2020, 15:26
Re: LOG vers rsyslog
Alors, il faut bien regarder la dernière ligne :
qui devrait plutôt être :
Pour information, en bash, la façon de concaténer les chaînes est :
Code : Tout sélectionner
DAEMON_ARGS="$DAEMON_ARGS -log /var/log/domoticz.log"
DAEMON_ARGS="-syslog user1 "
Code : Tout sélectionner
DAEMON_ARGS="$DAEMON_ARGS -log /var/log/domoticz.log"
DAEMON_ARGS="$DAEMON_ARGS -syslog user1"
Code : Tout sélectionner
x = "$x <mettre ici ce qu'on veut ajouter>"Re: LOG vers rsyslog
oui, je j'ai fait
regarde ma reponse d'avant, j'avais corriger en meme temps que tu ecrivais
merci
salinois
regarde ma reponse d'avant, j'avais corriger en meme temps que tu ecrivais
merci
salinois
-
Flying Domotic
- Messages : 772
- Inscription : 10 mars 2020, 15:26
Re: LOG vers rsyslog
J'avoue que je suis un peu perdu avec les différentes versions. Il pourrait être habile de n'envoyer que les dernières, avec toutes les modifs 