pi@raspberrypi:~ $ sudo systemctl status monit.service
● monit.service - LSB: service and resource monitoring daemon
Loaded: loaded (/etc/init.d/monit; generated)
Active: failed (Result: exit-code) since Sat 2021-08-07 10:56:14 IST; 3h 49min ago
Docs: man:systemd-sysv-generator(8)
Aug 07 10:56:14 raspberrypi systemd[1]: Starting LSB: service and resource monitoring daemon...
Aug 07 10:56:14 raspberrypi monit[13627]: Starting daemon monitor: monit/etc/monit/monitrc:217: syntax error '/etc/init.d/httpd'
Aug 07 10:56:14 raspberrypi monit[13627]: failed!
Aug 07 10:56:14 raspberrypi systemd[1]: monit.service: Control process exited, code=exited, status=1/FAILURE
Aug 07 10:56:14 raspberrypi systemd[1]: monit.service: Failed with result 'exit-code'.
Aug 07 10:56:14 raspberrypi systemd[1]: Failed to start LSB: service and resource monitoring daemon.
Checking the config file for syntax gives the error
/etc/monit/monitrc:222: syntax error '/etc/init.d/domoticz.sh'
It maybe something quite simple but my lack of knowledge has me at a dead end.
Thanks in advance.
This is the last part of my file @ /etc/monit/monitrc
#
###############################################################################
## Includes
###############################################################################
##
## It is possible to include additional configuration parts from other files or
## directories.
#
include /etc/monit/conf.d/*
#
check process domoticz with pidfile /var/run/domoticz.pid
start program = "/etc/init.d/domoticz.sh restart"
stop program = "/etc/init.d/domoticz.sh stop"
if failed
url http://127.0.0.1:8080/json.htm?param=ge ... pe=command
and content = '"status" : "OK"'
for 2 cycles
then restart
## Check domoticz
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
url http://127.0.0.1:8080/json.htm?type=command¶m=getversion
and content = '"status" : "OK"'
for 2 cycles
then restart
if 5 restarts within 5 cycles then exec "/sbin/reboot"
Hi, thanks for the replies.
I have tried both of the above suggestions and even though i copy and pasted them into my own file i still get a syntax error '/etc/init.d/domoticz.sh' when i check syntax.
I must be missing something in setup.
Is it possible to totally remove Monit and setup again from scratch?
That does not add up.
The error is about httpd on line 217 and you state that it is domoticz.
In my default monitrc is near that line (217) the apache (httpd) configuration.
I use separate config files in the conf.d directory because they are included at the end of monitrc.
# cat /etc/monit/conf-enabled/domoticz
## Domoticz
check process domoticzd 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¶m=getversion
and content = '"status" : "OK"'
for 2 cycles
then restart
if 5 restarts within 5 cycles then exec "/sbin/reboot"
if cpu usage > 80% for 3 cycles then restart
# cat /etc/monit/conf-enabled/apache2
check process apache with pidfile /var/run/apache2/apache2.pid
group www
group apache
start program = "/etc/init.d/apache2 start"
stop program = "/etc/init.d/apache2 stop"
if 4 restarts within 20 cycles then timeout
if failed host localhost port 80 with protocol http and request "/server-status" with timeout 25 seconds for 4 times within 5 cycles then restart
depend apache_bin
depend apache_rc
check file apache_bin with path /usr/sbin/apache2
group apache
include /etc/monit/templates/rootbin
check file apache_rc with path /etc/init.d/apache2
group apache
include /etc/monit/templates/rootbin
check host apache-port-tcp80 with address 127.0.0.1
start program = "/etc/init.d/apache2 start"
stop program = "/etc/init.d/apache2 stop"
if 4 restarts within 20 cycles then timeout
if failed host localhost port 80 with protocol http and request "/server-status" with timeout 25 seconds for 4 times within 5 cycles then restart
depend apache
I added what you have to /etc/monit/conf-enabled/domoticz and commented out the relevant lines in monitrc.
same error, so i deleted that section and the syntax error moves it is now at the point where it has a problem with the word "Disk" in the line that reads
# if failed gid "disk" then unmonitor.
Why is it giving me a problem with stuff that is commented out (#)
really odd..
Follow up. it seems anything in quotation marks even if commented out threw an error. After much deleting and trial and error i am passing the syntax check.
Hi,
I've just worked through the monit install/config and the issue I've had is that, using systemd services, no PID file is now created (for any service,actually). Monit cannot then see the process it wants to monitor in it's CHECK PROCESS line. Obviously systemctl can give you the running PID number. I solved this by adding a line like this after the ExecStart command of domoticz.service file :-
ExecStartPost=/bin/sh -c 'umask 022; pgrep YOURSERVICE > /var/run/YOURSERVICE.pid'
You need to give the domoticz user permission to create the file in the folder.
Don't forget to run systemctl daemon-reload before restarting the domoticz service and change the monit config file for the PID you've created.
Most of the monit install links show init.d style set=ups which WILL create the PID file.