Home Tutorials Domoticz Monitoring your Domoticz

Monitoring your Domoticz

Domoticz tutorial Monit

Monitor Domoticz

When you trying scripts or plugins, or install the latest beta a crash of Domoticz can happen. With Monit, you can monitor Domoticz and will be informed when Domoticz is down. Not only a mail but it can also try a restart of Domoticz. and when that’s not the solution it can reboot the system.

Install Monit

sudo apt-get install monit

Configure Monit

When monit is installed it must be configured. You must tell monit what it must monitoring and what to do.

sudo nano /etc/monit/monitrc
  • set daemon 300 -> Check services at 300 seconds (5 minutes)
  • with start delay 300 -> Start checking the services after 300 seconds (this avoids bootloops if Domoticz has not started yet, give it some time to start fully)
  • set logfile /var/log/monit.log -> It is preferred to change the location of the log file to a mounted USB drive or HDD. Or store it in a RAM-drive.

Configure Email notifications


   set mailserver smtp.gmail.com port 587 
   username "yourmailaddress@gmail.com" password "MYPASSWORD"
   using tlsv1
   with timeout 30 seconds
   set alert email@gmail.com

If you use Gmail with 2-step verification, you first have to create an App password


  set mailserver smtp.yourprovider.com port 25
  with timeout 30 seconds
  set mail-format { from: email@provider.com }
  set alert email@provider.com

To test if Monit can send you emails, issue a sudo monit reload and you should get a mail that the instance has changed.


Monit comes with its own webserver, running on port 2812. To configure the web interface, find and uncomment the section that begins with set httpd port 2812. Once the section is uncommented, fill in the IP-address of the machine where you have Domoticz running at, allow anyone to connect, and then create a monit user and password

set httpd port 2812
 use address  			# only accept connection from localhost (comment to connect from other hosts)
 allow	# allow anybody to connect to the server and
 allow admin:monit         		# require user 'admin' with password 'monit', change if your system is accessible from internet
  1. allow #This will only allow hosts coming from the local network (change x.x.x.1 to your own LAN IP-range).
  2. allow localhost #use in combination with local network to allow command line to work

Once this is configured, you should reload monit:

sudo service monit reload

You will then be able to access the monit web interface by going to “YOURIP:2812” (change to IP-adress of your Domoticz system) Login with the username and password you configured earlier in the configfile (admin/monit ?).

Configuring monitoring of programs

Once the web services are set up, you can begin to input the programs that you want monitored and protected into the “/etc/monit/monitrc” configuration file. To simply ensure that programs stay online, you can use the /etc/init.d commands to stop or start a program. Here are some example configurations:


  check process domoticz with pidfile /var/run/domoticz.pid
  start program = "/etc/init.d/domoticz.sh start"
  stop  program = "/etc/init.d/domoticz.sh stop"
  if failed
         and content = '"status" : "OK"'
     for 2 cycles
     then restart
  if 5 restarts within 5 cycles then exec "/sbin/reboot"
  • Remark: if the service is not found, check if the response from Domoticz still exactly contains the string “state”: “OK”

To check for CPU-usage, include the line if cpu usage > 70% for 3 cycles then restart for example (put it between the ‘then restart’ and the last ‘if 5 restarts..’ line).

Once you have set up the configuration, check the syntax:

sudo monit -t

After resolving any possible syntax errors, you can start running all of the monitored programs.

sudo monit start all
data collected                    Thu, 30 Aug 2012 18:35:00

Monit can be started with a command that then keeps it running in the background

sudo service monit start

Typing the command below displays monit’s status

sudo monit status

This shows us the details:

The Monit daemon 5.3.2 uptime: 1h 25m 
System 'myhost.mydomain.tld'
 status                            Running
 monitoring status                 Monitored
 load average                      [0.03] [0.14] [0.20]
 cpu                               3.5%us 5.9%sy 0.0%wa
 memory usage                      26100 kB [10.4%]
 swap usage                        0 kB [0.0%]
 data collected                    Thu, 30 Aug 2012 18:35:00

Your done!

Once you have configured all of the above steps, Domoticz will be tracked constantly and the process will be restarted automatically if it would have stopped running.


Exit mobile version