Page 1 of 1

Use Monit only for restart RPi

Posted: Sunday 04 February 2018 19:22
by NetEye
People,
Am I right?????? or can somebody tell me how to do it
I want to use Monit only for restart Domoticz in case it fails (without notifications or others)
I installed Monit following: https://www.domoticz.com/wiki/Monitoring_domoticz without:
- Configure e-mail notifications
- Webservice
- Configuring monitoring of programs
From here I want to use a script (I think) to run Monit every time after a restart.
I found one (for what I think the fewest actions).
For what I understand I have to copy it in: Copy the script to /home/pi/domoticz/scripts/
and Execute sudo chmod +x domoticz_state_checker.sh
To run in automaticly: Open your crontab (Terminal: crontab -e) and add the following line:
*/5 * * * * /home/pi/scripts/domoticz_state_checker.sh

#!/bin/bash
DomoticzState=`sudo service domoticz.sh status`

if [[ $DomoticzState == "domoticz is running." ]]
then
echo 'Domoticz is running. Nothing to do.'
elif [[ $DomoticzState == "domoticz is not running ... failed!" ]]
then
echo 'Domoticz is not running. Restarting Domoticz...'
sudo service domoticz.sh restart
echo 'Domoticz restarted.'
fi