Use Monit only for restart RPi

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
NetEye
Posts: 34
Joined: Friday 17 June 2016 7:57
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Spijkenisse
Contact:

Use Monit only for restart RPi

Post 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
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest