Hi,
the debug message about the non-existing pidfilewithin the same second can be ignored - it's logged only in the debug mode by the method Util_isProcessRunning() (the debug messages repetition is fixed in newer Monit versions). When you filter out the debug messages, the event-action sequence is showed:
[BST Sep 5 18:55:07] error : 'apache' process is not running [BST Sep 5 18:55:07] info : 'apache' trying to restart [BST Sep 5 18:55:07] info : 'apache' start: /etc/init.d/httpd [BST Sep 5 18:55:37] error : 'apache' failed to start
=> Monit detected that apache is not running at 18:55:07, it tried to restart it, but apache didn't start within 30 seconds.
The reason why apache didn't start via Monit is most probably its dependence on some environment variable. Monit purges the environment for security reasons when executing the program, so you get only: PATH=/bin:/usr/bin:/sbin:/usr/sbin + MONIT_ variables. Sometimes linux distributions use special file (such as /etc/apache2/envvars on Debian) where you can set environment variables which are required for Apache.
You can wrap the start program in shell - it'll load the environment you need:
--8<-- start program = "/bin/bash -c '/etc/init.d/httpd start'" --8<--
Regards, Martin
I think that my theory may hold water, from /etc/init.d/httpd
# When stopping httpd a delay of >10 second is required before SIGKILLing the # httpd parent; this gives enough time for the httpd parent to SIGKILL any
# errant children. stop() { echo -n $"Stopping $prog: " killproc -p ${pidfile} -d 10 $httpd RETVAL=$? echo [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
Nick Upson
On 10 September 2012 12:56, Nick Upson <address@hidden> wrote:
I've just found a server where monit has been attempting to restart httpd for several days.
the monit config entry is:
check process apache with pidfile /var/run/httpd.pid start program = "/etc/init.d/httpd start"
stop program = "/etc/init.d/httpd stop"
output in the monit.log is:
[BST Sep 5 18:55:07] debug : monit: pidfile '/var/run/httpd.pid' does not exist [BST Sep 5 18:55:07] error : 'apache' process is not running
[BST Sep 5 18:55:07] info : 'apache' trying to restart [BST Sep 5 18:55:07] debug : monit: pidfile '/var/run/httpd.pid' does not exist [BST Sep 5 18:55:07] debug : monit: pidfile '/var/run/httpd.pid' does not exist
[BST Sep 5 18:55:07] info : 'apache' start: /etc/init.d/httpd [BST Sep 5 18:55:07] debug : monit: pidfile '/var/run/httpd.pid' does not exist [BST Sep 5 18:55:07] debug : monit: pidfile '/var/run/httpd.pid' does not exist
[BST Sep 5 18:55:37] error : 'apache' failed to start
I think what is happening is that the restart and the start execution are over-lapping such that the removal of the pid file by the restart happens after the separate start. Why a restart is being attempted I do not understand.
This was corrected on the server by doing a manual kill of the httpd processes
and, BTW, reporting that the pid file does not exist as part of starting a process is, at best, redundant and at worse, confusing
Nick Upson
-- To unsubscribe: https://lists.nongnu.org/mailman/listinfo/monit-general
|