Monit works partially

Subforum for general discussions. Do not dump your questions/problems here, but try to find the subforum where it belongs!

Moderators: leecollings, remb0

Post Reply
jvmaanen
Posts: 13
Joined: Wednesday 01 March 2017 13:32
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Monit works partially

Post by jvmaanen »

If the power of the raspberry has been off, it takes more than half an hour before domoticz is restarted. This happens after the script has performed the reboot.

I'm using these lines:
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
host 127.0.0.1 port 8080 protocol http
and request "/json.htm?type=command&param=getversion"
and content = '"status" : "OK"'
for 3 cycles
then restart
if 5 restarts within 5 cycles then exec "/sbin/reboot"

It looks like the "if failed" part is not working correctly.

When I check the Monit web page, I get the following error:
Monit error for Domoticz process.png
Monit error for Domoticz process.png (48.89 KiB) Viewed 426 times

After more than half an hour, the raspberry has been rebooted based on the "If 5..." statement and then after 5 minutes the domoticz server is finally started.
Monit succesfully started domoticz.png
Monit succesfully started domoticz.png (62.14 KiB) Viewed 426 times

What is wrong in the "if failed..." statement and how can I test this on the raspberry (terminal).
Kedi
Posts: 536
Joined: Monday 20 March 2023 14:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Somewhere in NL
Contact:

Re: Monit works partially

Post by Kedi »

I don't understand the "it takes more than half an hour before domoticz is restarted"
I suppose the script "/etc/init.d/domoticz.sh" is present, which should start domoticz right after the boot.
The default monit install has a 'start' delay of 60 or more seconds before it starts checking.
After that delay domoticz should already be up and responding to monit requests.

And beter change

Code: Select all

start program = "/etc/init.d/domoticz.sh start"
in

Code: Select all

start program = "/etc/init.d/domoticz.sh restart"
Logic will get you from A to B. Imagination will take you everywhere.
jvmaanen
Posts: 13
Joined: Wednesday 01 March 2017 13:32
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Monit works partially

Post by jvmaanen »

It surely helped a lot changing from start to restart.

There is still a difference between a reboot command and a power failure. After a reboot command domoticz is running, after a power failure domoticz is started, but not running:

pi@raspberrypi:~ $ sudo service domoticz status
● domoticz.service - LSB: Home Automation System
Loaded: loaded (/etc/init.d/domoticz.sh; generated)
Active: active (exited) since Sat 2024-08-31 10:17:16 CEST; 7min ago

Also the pidfile at /var/run/domoticz.pid is not available

After 5 minutes Moni becomes active and now restarts domoticz. Domoticz is now running again:
pi@raspberrypi:~ $ sudo service domoticz status
● domoticz.service - LSB: Home Automation System
Loaded: loaded (/etc/init.d/domoticz.sh; generated)
Active: active (running) since Sat 2024-08-31 10:27:08 CEST; 1min 7s ago

So, I still need Moni to activate domoticz, but with the restart option (instead of start) it now takes 5 minutes after the boot when Moni starts who checks for the missing pidfile and restarts domoticz. After the restart domoticz is active and running. In the previous situation I had to wait more than 30 minutes for the reboot command to kick in.
Kedi
Posts: 536
Joined: Monday 20 March 2023 14:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Somewhere in NL
Contact:

Re: Monit works partially

Post by Kedi »

Then there is something wrong with your system.
In both case (reboot / power failure) Domoticz should start directly after the system is started up.

B.t.w. I use a start delay of 60 seconds for Monit to do its job.
Logic will get you from A to B. Imagination will take you everywhere.
jvmaanen
Posts: 13
Joined: Wednesday 01 March 2017 13:32
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Monit works partially

Post by jvmaanen »

It looks like it starts after a power failure, but than exits. When I check there is no pidfile.

What can I do or check, to make sure that it starts correctly?
Kedi
Posts: 536
Joined: Monday 20 March 2023 14:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Somewhere in NL
Contact:

Re: Monit works partially

Post by Kedi »

Put on complete debug logging and simulate power failure. See wiki for howto.
In that logging should be a cause.
Post (partial) logging here as attachment or spoiler.
Don't forget to put normal logging back.
Logic will get you from A to B. Imagination will take you everywhere.
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Monit works partially

Post by waltervl »

What version of Domoticz are you using? The issue that Domoticz stops right after a cold reboot (power off) because of the time difference should be fixed in recent versions.

Another option is to have a extra Domoticz startup delay parameter on your environment so it will be sure the time has been synced before Domoticz is started. See for more info wiki page https://www.domoticz.com/wiki/Troublesh ... _cold_boot
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
jvmaanen
Posts: 13
Joined: Wednesday 01 March 2017 13:32
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Monit works partially

Post by jvmaanen »

Updating to the latest version solved the problem. I tested this several times. Now domoticz starts right after the power has been restored.
Thanks for all the advices.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest