Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
What version of Linux and which distribution are you running? –  ewwhite Jan 29 '13 at 12:34
    
is monit running as root? –  chewbakka Jan 29 '13 at 12:35
    
@chewbakka: monit is started as root with command "monit -Iv" ... –  user410932 Jan 29 '13 at 12:38
    
erwhite: Linux is some old fedora thing. monit is just installed and latest version –  user410932 Jan 29 '13 at 12:38
add comment

2 Answers

/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.

share|improve this answer
    
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
add comment

i think the pid is /var/run/httpd/httpd.pid

share|improve this answer
1  
Depending on configuration and distribution. –  Falcon Momot Jun 18 at 10:02
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.