- edited description
Monit restart not a task
Sorry for my bad englisch…
I run on a Odroid N2 Monit, end monit runs ok.
I try to monit my homeautomation [ Domoticz ] Looks also running ok.
Only the problem is that monit restart Domoticz not, bud wait untail monit must restart my Odroid.
My Config [ important things] Include the other things i tryed:
# DOMOTICZ
#########################
check process domoticz with pidfile /var/run/domoticz.pid
# start program = "/etc/init.d/domoticz.sh restart"
#start program = "/bin/systemctl restart domoticz.service"
start program = "/bin/systemctl restart domoticz.service"
stop program = "/bin/systemctl stop domoticz.service"
if failed
url http://192.168.5.70:8080/json.htm?type=command¶m=getversion
# url http://127.0.0.1:8080/json.htm?type=devices&rid=1
and content = '"status" : "OK"'
for 2 cycles
then restart
if cpu usage > 22% for 8 cycles then restart
if 7 restarts within 7 cycles then exec "/sbin/reboot"
#check process domoticz with pidfile /var/run/domoticz.pid
# start program = "/bin/systemctl restart domoticz.service"
# stop program = "/bin/systemctl stop domoticz.service"
The strange part, when i try the json link:
It says ok.
When i try the cli interface i get the status running.
pi@odroidn2:~$ /etc/init.d/domoticz.sh restart
[....] Restarting domoticz.sh (via systemctl): domoticz.service==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to restart 'domoticz.service'.
Authenticating as: ,,, (pi)
Password:
==== AUTHENTICATION COMPLETE ===
. ok
pi@odroidn2:~$ /etc/init.d/domoticz.sh restart
[....] Restarting domoticz.sh (via systemctl): domoticz.service==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to restart 'domoticz.service'.
Authenticating as: ,,, (pi)
Password:
==== AUTHENTICATION COMPLETE ===
. ok
pi@odroidn2:~$
Or:
pi@odroidn2:~$ /etc/init.d/domoticz.sh status
● domoticz.service - LSB: Home Automation System
Loaded: loaded (/etc/init.d/domoticz.sh; generated)
Active: active (running) since Sat 2020-03-07 12:51:42 CET; 31s ago
Docs: man:systemd-sysv-generator(8)
Process: 6651 ExecStart=/etc/init.d/domoticz.sh start (code=exited, status=0/SUCCESS)
Tasks: 55 (limit: 3350)
Memory: 104.8M
CGroup: /system.slice/domoticz.service
└─6657 /home/pi/domoticz/domoticz -daemon -www 8080 -sslwww 443
Mar 07 12:51:42 odroidn2 systemd[1]: Starting LSB: Home Automation System...
Mar 07 12:51:42 odroidn2 domoticz.sh[6651]: 2020-03-07 12:51:42.910 Status: Domoticz V4.11740 (c)2012-2020 GizMoCuz
Mar 07 12:51:42 odroidn2 domoticz.sh[6651]: 2020-03-07 12:51:42.910 Status: Build Hash: a1f0d3d83, Date: 2020-02-26 20:21:06
Mar 07 12:51:42 odroidn2 domoticz.sh[6651]: 2020-03-07 12:51:42.910 Status: Startup Path: /home/pi/domoticz/
Mar 07 12:51:42 odroidn2 domoticz.sh[6651]: domoticz: Domoticz is starting up....
Mar 07 12:51:42 odroidn2 domoticz[6656]: Domoticz is starting up....
Mar 07 12:51:42 odroidn2 domoticz[6657]: Domoticz running...
Mar 07 12:51:42 odroidn2 systemd[1]: Started LSB: Home Automation System.
pi@odroidn2:~$
And:
pi@odroidn2:~$ /etc/init.d/domoticz.sh stop
[....] Stopping domoticz.sh (via systemctl): domoticz.service==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to stop 'domoticz.service'.
Authenticating as: ,,, (pi)
Password:
==== AUTHENTICATION COMPLETE ===
. ok
pi@odroidn2:~$ /etc/init.d/domoticz.sh status
● domoticz.service - LSB: Home Automation System
Loaded: loaded (/etc/init.d/domoticz.sh; generated)
Active: inactive (dead) since Sat 2020-03-07 12:52:48 CET; 2s ago
Docs: man:systemd-sysv-generator(8)
Process: 6651 ExecStart=/etc/init.d/domoticz.sh start (code=exited, status=0/SUCCESS)
Process: 7886 ExecStop=/etc/init.d/domoticz.sh stop (code=exited, status=0/SUCCESS)
Mar 07 12:51:42 odroidn2 domoticz.sh[6651]: 2020-03-07 12:51:42.910 Status: Startup Path: /home/pi/domoticz/
Mar 07 12:51:42 odroidn2 domoticz.sh[6651]: domoticz: Domoticz is starting up....
Mar 07 12:51:42 odroidn2 domoticz[6656]: Domoticz is starting up....
Mar 07 12:51:42 odroidn2 domoticz[6657]: Domoticz running...
Mar 07 12:51:42 odroidn2 systemd[1]: Started LSB: Home Automation System.
Mar 07 12:52:43 odroidn2 systemd[1]: Stopping LSB: Home Automation System...
Mar 07 12:52:43 odroidn2 domoticz[6657]: Domoticz is exiting...
Mar 07 12:52:47 odroidn2 domoticz[6657]: Domoticz stopped...
Mar 07 12:52:48 odroidn2 systemd[1]: domoticz.service: Succeeded.
Mar 07 12:52:48 odroidn2 systemd[1]: Stopped LSB: Home Automation System.
pi@odroidn2:~$
when it is not running:
And when monit is running says:
So i hope there is som help from here..
I cannot find a other solution
Try to setup more times, to check everything to set it like the monit wik says.
Only make no differents,,,
Comments (13)
-
reporter -
reporter - changed title to Monit restart not a task
-
Hello D.M. Raspberry,
are the monit log information available also.“Execution Failed” looks like a problem with the used/defined start/stop commands.
With regards,
Lutz -
reporter Whe i try teh commands in to cli [ putty ] they work..
Only perhaps now you say this in need to give the sudo password.
Should that be the problem?
Only how can i fix that?
And strange, the reboot command works good..
-
Hello D.M. Raspberry,
as long as you start monit as a daemon with uid 0/root too, you should not have a authorisation problem, I thing.Sometimes the monit log gives some useful information.
With regards,
Lutz -
reporter ok..
Log i did not set on in the config [ now enabled ]
Only should i install monit as root?
Or how can i resolve the root issue?
Thanks
-
Hello D.M. Raspberry,
if you use systemctl commands you must start Monit with uid 0/root. The Systemd commands require root authorisation in general, I think.Have a look to the wiki to see how to configure Monit in a Systemd environment, see https://mmonit.com/wiki/Monit/Systemd
Maybe you can authorise normal users to use systemctl to start/stop services, but I don't know how to do this, sorry. I start Monit with uid 0 to use Launchd or Systemd commands.
With regards,
Lutzp.s.
Be aware, Systemd try to recover applications problems too. You should decide who do the job, Monit or Systemd. But, as long as you use systemctl to start/stop the monitored services, everything should work.
-
repo owner if you run monit as non-root, a possible solution could be to execute the start/stop commands with “sudo” and setting sudo to allow monit to execute that specific command-line with no password. Example monit configuration:
start program = "/usr/bin/sudo /bin/systemctl restart domoticz.service"
See for example here for sudo related setup (to allow monit to run
/bin/systemctl restart domoticz.service
via sudo with no password): https://superuser.com/questions/167631/fine-grained-sudoers-configuration-allowed-commandline-arguments -
repo owner - changed status to resolved
-
reporter @Tildeslash
Thanks for the comment..
i give this option a try.
Sorry i am a bad linux user. [ and bad englisch ] So i do not understand a lot of the link you gave me.
I changed the command lin in monitric.
And i think the stop is als different?
These are my commands?
start program = "/usr/bin/sudo /bin/systemctl restart domoticz.service" stop program = "/usr/bin/sudo /bin/systemctl stop domoticz.service"
Should this ok bij you?
-
repo owner Yes, looks good (+ you need to setup sudo as mentioned)
-
reporter Sorry for my stupidity …
Onkly do i need to take some action for this?
(+ you need to setup sudo as mentioned)
I run the code as root:
The start stop and restart documents are not working [ was a test ]
-
repo owner if you run monit as root, you don’t need sudo in the start/stop/restart commands
if you’re running monit as non-root user, you need to use sudo as described
- Log in to comment