mirror of
https://github.com/fhem/fhem-mirror.git
synced 2024-11-22 09:49:50 +00:00
79f30703b3
git-svn-id: https://svn.fhem.de/fhem/trunk@15682 2b470e98-0d58-463d-a4d8-8e2adae1ed80
33 lines
745 B
Bash
Executable File
33 lines
745 B
Bash
Executable File
#!/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
|
|
|