Met ‘Monit’ kun je bewaken dat je Domoticz server altijd goed draait en dus al je Domotica taken goed kan uitvoeren. Een fijne gedachte.

Ik heb in een eerdere blog uitgelegd hoe ik ‘Monit’ gebruik om diverse processen van mijn Debian Server in te gaten te houden en automatisch te restarten indien nodig. Dit kun je natuurlijk ook gebruik voor Domoticz. Het is immers belangrijk dat deze altijd draait, want anders is dat slecht voor de WAF.

Om ‘Monit’ te installeren gebruik je het volgende commando op je Raspberry Pi waarop Domoticz draait:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo apt-get install monit
sudo apt-get install monit
sudo apt-get install monit

Hierna moet je nog wat instellingen plegen in de file ‘/etc/monit/monitrc’

Hierbij heb ik 3 dingen aangepast:

  1. Check Interval
  2. Secure Web-Interface met identificatie
  3. Domoticz Process checken

Zie hieronder de 3 stukken die ik respectievelijk heb veranderd/toegevoegd:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
set daemon 120 # check services at 2-minute intervals
with start delay 60 # delay the first check by 60 seconds
# (by default Monit check immediately after Monit start)
set daemon 120 # check services at 2-minute intervals with start delay 60 # delay the first check by 60 seconds # (by default Monit check immediately after Monit start)
set daemon 120            # check services at 2-minute intervals
  with start delay 60     # delay the first check by 60 seconds
                          # (by default Monit check immediately after Monit start)
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
set httpd port 2812
ssl enable
pemfile /opt/domoticz/server_cert.pem
allow admin:password # require user 'admin' with password 'password'
set httpd port 2812 ssl enable pemfile /opt/domoticz/server_cert.pem allow admin:password # require user 'admin' with password 'password'
set httpd port 2812
  ssl enable
  pemfile /opt/domoticz/server_cert.pem
  allow admin:password   # require user 'admin' with password 'password'
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# Domoticz Process
check process domoticz_process with pidfile /var/run/domoticz.pid
start program = "/etc/init.d/domoticz.sh start"
stop program = "/etc/init.d/domoticz.sh stop"
if failed
url http://127.0.0.1:8080/json.htm?type=command&param=getversion
and content = '"status" : "OK"'
for 2 cycles
then restart
if 5 restarts within 5 cycles then exec "/sbin/reboot"
# Domoticz Process check process domoticz_process with pidfile /var/run/domoticz.pid start program = "/etc/init.d/domoticz.sh start" stop program = "/etc/init.d/domoticz.sh stop" if failed url http://127.0.0.1:8080/json.htm?type=command&param=getversion and content = '"status" : "OK"' for 2 cycles then restart if 5 restarts within 5 cycles then exec "/sbin/reboot"
# Domoticz Process
check process domoticz_process with pidfile /var/run/domoticz.pid
  start program = "/etc/init.d/domoticz.sh start"
  stop  program = "/etc/init.d/domoticz.sh stop"
  if failed
     url http://127.0.0.1:8080/json.htm?type=command&param=getversion
         and content = '"status" : "OK"'
     for 2 cycles
  then restart
if 5 restarts within 5 cycles then exec "/sbin/reboot"

Om ‘Monit’ tenslotte te starten voer je het volgende commando uit:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo /etc/init.d/monit restart
sudo /etc/init.d/monit restart
sudo /etc/init.d/monit restart

Je kunt de web-interface van ‘Monit’ bereiken op:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
http://<ip-adres raspberry pi>:2812
http://<ip-adres raspberry pi>:2812
http://<ip-adres raspberry pi>:2812



Alhoewel ik het tot nu nog nooit heb meegemaakt dat Domoticz is gecrasht is het toch wel een fijne gedachte dat je zeker weet dat Domoticz altijd draait.