2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-13 05:06:35 +00:00

contrib/fhem_watchdog.sh: Simple watchdog solution to monitor fhem on Linux.

git-svn-id: https://svn.fhem.de/fhem/trunk@15681 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
hjr 2017-12-24 15:12:36 +00:00
parent fcb408d37e
commit e4fd97e0cb

View File

@ -0,0 +1,32 @@
#!/bin/sh
#
# $Id$
#
# Simple watchdog solution to monitor and restart fhem on Linux.
#
# Add this define to the fhem configuration:
# define at_FhemPulse at +*00:10 {system("/bin/date +%s > /opt/fhem/log/fhem_pulse.log")}
#
# Add a cron job that runs every ten minutes -> crontab -e
# */10 * * * * /opt/fhem/contrib/fhem_watchdog.sh
LOGFILE="/opt/fhem/log/fhem_pulse.log"
if [ `systemctl status fhem|grep inactive|wc -l` -eq "0" ]; then
# fhem service was started
if [ ! -e "${LOGFILE}" ]; then
# There is no pulse log file
systemctl restart fhem
exit 0
fi
if [ $(expr $(/bin/date +%s) - $(cat ${LOGFILE})) -gt 900 ]; then
# Last pulse is older than 15min.
systemctl restart fhem
exit 0
fi
fi
exit 0