first commit
This commit is contained in:
45
check.sh
Executable file
45
check.sh
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/bin/bash
|
||||
# Script qui vérifie l'état de domoticz et qui relance si off
|
||||
|
||||
PATH=/opt/domoticz/:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
|
||||
|
||||
now=$(date) #récupération de la date et heure pour les logs
|
||||
echo $now
|
||||
#Récupération du retour de la commande de status
|
||||
domoticz=$(/usr/sbin/service domoticz.sh status |egrep "inactive|failed" |wc -l)
|
||||
echo "statut domoticz" $domoticz
|
||||
|
||||
#grep "Error: RFLink: TX time out..." /var/log/domoticz.log |tail -n 1|cut -c 1-16
|
||||
#status=$(/usr/sbin/service domoticz.sh status) #On le lance
|
||||
|
||||
#echo $domoticz $status
|
||||
rflink=$(tail -n5000 /var/log/domoticz.log|grep -y "RFXCOM: Unhandled switch command" |wc -l)
|
||||
rflink2=$(tail -n5000 /var/log/domoticz.log|grep -y "RFXCOM: TX time out..." |wc -l)
|
||||
#rflink2=$(grep -y "Error: RFLink: TX time out..." /var/log/domoticz.log |wc -l)
|
||||
echo "Unhandled switch" $rflink
|
||||
echo "Time out" $rflink2
|
||||
|
||||
if [ "$domoticz" -ge "1" ] # Si le service n'est pas lancé
|
||||
then
|
||||
relance=$(/usr/sbin/service domoticz.sh restart) #On le lance
|
||||
echo "$now >> relance : $relance" #On log la lancement
|
||||
else
|
||||
echo "$now >> Domoticz lancé" #On log l'état normal
|
||||
fi
|
||||
|
||||
if [ "$rflink" -ge "1" ] # Si le service n'est pas lancé
|
||||
then
|
||||
cat /dev/null > /var/log/domoticz.log
|
||||
relance=$(/usr/sbin/service domoticz.sh restart) #On le lance
|
||||
echo "$now >> relance : $relance" #On log la lancement
|
||||
fi
|
||||
|
||||
if [ "$rflink2" -ge "1" ] # Si le service n'est pas lancé
|
||||
then
|
||||
cat /dev/null > /var/log/domoticz.log
|
||||
relance=$(/usr/sbin/service domoticz.sh restart) #On le lance
|
||||
echo "$now >> relance rflink : $relance" #On log la lancement
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user