0

I'm running Apache, and trying to monitor it wiht Monit. The monitoring seems to work fine, but when Apache is down, Monit does not succeed to start it.

Monit does detect that it's down, but the start command fails.

Below is the monit config

check process httpd with pidfile /var/run/httpd.pid
start program = "/usr/bin/apachestart start"
stop program = "/etc/init.d/httpd stop"
if failed host 127.0.0.1 port 80
protocol http then restart
if 5 restarts within 5 cycles then timeout

This refers to the startup script of Apache, which includes the following:

# cat /usr/bin/apachestart
## start Apache with default settings
ulimit -l 256;
ulimit -s 56000;
/usr/sbin/apachectl start;

This script sets a couple of params which seem to be required for this specific Apache/PHP setup. Works fine when run from the commandline as root, but apparently, for Monit, it's somehow a problem.

When running monit in debug mode (started with "monit -Iv"), I get the following

monit: pidfile '/var/run/httpd.pid' does not exist
'httpd' process is not running
-------------------------------------------------------------------------------
    monit [0x40de4d]
    monit(LogError+0x9f) [0x40e59f]
    monit(Event_post+0x406) [0x40ba96]
    monit(check_process+0x98) [0x41d798]
    monit(validate+0x1b3) [0x41dbf3]
    monit [0x410547]
    monit(main+0x492) [0x410d72]
    /lib64/libc.so.6(__libc_start_main+0xf4) [0x30f961d994]
    monit [0x408e39]
-------------------------------------------------------------------------------
Does not exist notification is sent to frank@avalonnet.com
Does not exist notification is sent to tom@avalonnet.com
'httpd' trying to restart
Monitoring disabled -- service httpd
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
'httpd' start: /usr/bin/apachestart
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
'httpd' failed to start
-------------------------------------------------------------------------------
    monit [0x40de4d]
    monit(LogError+0x9f) [0x40e59f]
    monit(Event_post+0x406) [0x40ba96]
    monit [0x409b7a]
    monit(control_service+0xcb) [0x409d8b]
    monit [0x40b3ae]
    monit(Event_post+0x445) [0x40bad5]
    monit(check_process+0x98) [0x41d798]
    monit(validate+0x1b3) [0x41dbf3]
    monit [0x410547]
    monit(main+0x492) [0x410d72]
    /lib64/libc.so.6(__libc_start_main+0xf4) [0x30f961d994]
    monit [0x408e39]
-------------------------------------------------------------------------------
Execution failed notification is sent to ...

Any ideas why monit cannot start the Apache?

user410932
  • 155
  • 2
  • 7

1 Answers1

1

/usr/sbin/apachectl start does not set the PID file for httpd properly.

Since your Monit config file tracks the process via /var/run/httpd.pid, you should really use /etc/init.d/httpd start as your start program.

If you need the additional parameters, you can place them in another config file. This is partially dependent on which version of Linux you're using.

ewwhite
  • 194,921
  • 91
  • 434
  • 799
  • Unfortunately, I found out that the problem is due to the "ulimit" in the script. Withoug that, it does work fine. – user410932 Jan 29 '13 at 12:39