monit-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Monit not able to start after box reboot


From: Martin Pala
Subject: Re: Monit not able to start after box reboot
Date: Mon, 11 Jun 2012 23:32:20 +0200

If you run the monit binary, it checks whether the daemon is running already by reading the PID from its pidfile and looking for the given process. It seems that after your system rebooted, some other process obtained the same PID, so monit thinks that it is running and doesn't daemonize itself.

The solution could be to place the pidfile on tmpfs (memory based filesystem), which is not persistent across reboot => the file will disappear when you reboot the system.

The pidfile location can be set with the "set pidfile" statement.

Regards,
Martin



On Jun 11, 2012, at 11:24 PM, Fei, Yuming wrote:

Hi all,
I have seen a problem that monit is not able to start after the box reboot. The monit is run from init as daemon.
This problem happens occasionally. When it does happen, I saw these:
 
First of all, the .monit.pid file was not removed after the box shutdown.
Then monit was started from init, but it wrote “monit daemon at 12327 awakened” into its log, where 12327 is the pid in .monit.pid. The monit startup process then exited and no monit process run.
 
Cleaning up the .monit.pid file helped: restart monit after the cleaning up, then monit came up.
 
Anyone has experienced this? What could cause this to happen?
 
Looking at monit’s source code, I found these:
 
(1) the removal function of the pid file is registered in atexit(), however it may not be called if  the process terminates abnormally. Thus the pid file may not be removed, which is probably what was seen above.
(2) When monit starts up, it retrieves the pid value from the pid file, and calls getpgid to check the result. But if the process with that pid is running as a zombile, the getpgid checking will pass and monit thinks that the monit daemon is running, and will “awake” that daemon which is actually a zombie. The result is that monit daemon won’t come up.
 
It doesn’t seem that monit tests if there is a monit zombie process during startup.
Also, if by any chance there is a process running with the same pid in the .monit.pid, monit will send a signal to it to “awake” it …, and then it may kill that process.
 
This is seen in monit 5.1.1, and seems to be in the latest version 5.4 as well.
 
Thanks
Yuming


CONFIDENTIALITY AND SECURITY NOTICE

The contents of this message and any attachments may be confidential and proprietary. If you are not an intended recipient, please inform the sender of the transmission error and delete this message immediately without reading, distributing or copying the contents.
--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general


reply via email to

[Prev in Thread] Current Thread [Next in Thread]