Can't get Monit running on Raspberry Pi Topic is solved

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
studiocascade
Posts: 39
Joined: Thursday 13 July 2017 23:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Can't get Monit running on Raspberry Pi

Post by studiocascade »

Hello dear Domoticz friends,

I am running Domoticz for a few years now and i'm very satisfied.
Sadly once in a while, the whole system crashes and i don't know where to start looking.
The general log didn't give me a clue.

Someone suggested me to install Monit.
Well, i did that, but i guess I'm doing something wrong.

When i run "sudo /etc/init.d/monit restart" i get the message
[....] Restarting monit (via systemctl): monit.serviceJob for monit.service failed because the control process exited with error code.
See "systemctl status monit.service" and "journalctl -xe" for details.
Running systemctl status monit.service gives the following information:
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 Thu 2020-08-13 20:28:45 CEST; 1min 35s ago
Docs: man:systemd-sysv-generator(8)
Process: 21527 ExecStart=/etc/init.d/monit start (code=exited, status=1/FAILURE)

Aug 13 20:28:45 Domoticz systemd[1]: Starting LSB: service and resource monitoring daemon...
Aug 13 20:28:45 Domoticz monit[21527]: Starting daemon monitor: monit'check system' not defined in c
Aug 13 20:28:45 Domoticz monit[21527]: /etc/monit/monitrc:216: Service name conflict, Domoticz alrea
Aug 13 20:28:45 Domoticz monit[21527]: failed!
Aug 13 20:28:45 Domoticz systemd[1]: monit.service: Control process exited, code=exited, status=1/FA
Aug 13 20:28:45 Domoticz systemd[1]: monit.service: Failed with result 'exit-code'.
Aug 13 20:28:45 Domoticz systemd[1]: Failed to start LSB: service and resource monitoring daemon.
Am i doing something wrong?

Here are some snippets from my monitrc:

Code: Select all

#
  set daemon 300            # check services at 2-minute intervals
   with start delay 300    # optional: delay the first check by 4-minutes (by
#                           # default Monit check immediately after Monit start)
#
#
## Set syslog logging. If you want to log to a standalone log file instead,
## specify the full path to the log file
#
  set log /var/log/monit.log

...

 set httpd port 2812 and
#     use address localhost  # only accept connection from localhost (drop if you use M/Monit)
     allow 192.168.2.1/255.255.255.0        # allow localhost to connect to the server and
     allow localhost
     allow admin:monit      # require user 'admin' with password 'monit'

...

  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://192.168.2.100: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"

EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: Can't get Monit running on Raspberry Pi

Post by EddyG »

Check for errors with.

Code: Select all

sudo /etc/init.d/monit syntax
It seems that domoticz is already defined somewhere else.
I would not include the check for domoticz in the /etc/monit/monitrc file
But put a 'Domoticz' file in /etc/monit/conf.d because all those files are included by the monitrc file.
studiocascade
Posts: 39
Joined: Thursday 13 July 2017 23:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Can't get Monit running on Raspberry Pi

Post by studiocascade »

Thanks for your quick reply!

When i do:

Code: Select all

sudo /etc/init.d/monit syntax

it says "Control file syntax OK"

Sorry for the noob question, but if i get you right you say:
i should comment out the check for domoticz in themonitrc file
Do you mean the line 'check process domoticz with pidfile...'?
Do i need to leave the rest of that alinea uncommented? 'start program =...' etc

and then just put a file named 'Domoticz' in the /etc/monit/conf.d
should the Domoticz file contain any information and first character must in caps or doesn't matter?
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: Can't get Monit running on Raspberry Pi

Post by EddyG »

Normaly this information should be in any (name it 'Domoticz') file and placed in /etc/monit/conf.d

Code: Select all

  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://192.168.2.100: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"
And should not be placed in the monitrc file, it does not harm, but is is not default monit logic.
Normally at the end of the /etc/monit/monitrc file there should be.

Code: Select all

###############################################################################
## Includes
###############################################################################
##
## It is possible to include additional configuration parts from other files or
## directories.
#
   include /etc/monit/conf.d/*
   include /etc/monit/conf-enabled/*
#
Which takes care of including all the file of those dirs.
The fact that it says "Control file syntax OK" makes it a puzzle for why monit stops.
My 'Domoticz file looks like

Code: Select all

check process domoticzd with pidfile /var/run/domoticz.pid
start program = "/etc/init.d/domoticz.sh restart" with timeout 60 seconds
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 9 cycles then restart

if 5 restarts within 5 cycles then exec "/sbin/reboot"
#if 5 restarts within 5 cycles then timeout
The only real difference is the line start program = "/etc/init.d/domoticz.sh restart" with timeout 60 seconds
I do a restart in that line.

B.t.w. the logging you provide is missing some information at the end of some lines.
That information might be crucial.
It mentions something about line 216 of monitrc.
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: Can't get Monit running on Raspberry Pi

Post by EddyG »

Probably found it.
You have the same name on the line check system $HOST as used by check process domoticz
Is your hostname domoticz?
Change it in check process Domoticz might solve it. (Capital 'D')
studiocascade
Posts: 39
Joined: Thursday 13 July 2017 23:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Can't get Monit running on Raspberry Pi

Post by studiocascade »

Thanks a lot for your replies again!
I did every suggestion:
  • took the part out of the monitrc file
  • created a separate file in /etc/monit/conf.d called it Domoticz
  • The check for the service now has a capital D
The line system $host is commented out in my monitrc file. Can i keep it that way?
My hostname indeed is Domoticz.

Still get the same errors as in my first post.
What else could it be?

Edit: Your suggestion about the process name made me look further.
If i do "sudo monit -t" i get the message /etc/monit/conf.d/Domoticz:1: Service name conflict, Domoticz already defined '/var/run/domoticz.pid'
So i guess this is probably the cause of the problem. But i honestly don't know how to fix.
Thanks for any help!
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: Can't get Monit running on Raspberry Pi

Post by EddyG »

Did you try an other name like "check process Domoticz-TEST" ?
Because it is in the naming. Keep in mind that Linux is most if not ALL of the time caption sensitive, but monit seems not.
Did you try my Domoticz monit file, because I changed in domotizd (extra d for daemon) at the end)
studiocascade
Posts: 39
Joined: Thursday 13 July 2017 23:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Can't get Monit running on Raspberry Pi

Post by studiocascade »

Ohh, thank you EddyG!!
This was the solution: Changing the process into domoticzd
After i did that, monit starts successfully
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest