Monit lists Apache as Not Monitored

apache-2.2monitmonitoring

I've just installed and configured monit according to the monit documentation. All services apart from Apache are listed as Running, but Apache says Not Monitored.

The relevant lines in monit's config are:

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

I can access http://localhost/server-status and http://localhost fine from the server. Monit lists Monitoring mode for Apache as active.

Server is running CentOS 5.4.

PID file is correct for parent httpd server:

[server ~]$ cat /var/run/httpd.pid
2905
[server ~]$ ps auxc | grep httpd
root      2905  0.0  0.9  26952  4808 ?        Ss   11:36   0:00 httpd

Best Answer

Make sure the contents of the pid file match up with the Apache master process's pid (i.e., the httpd process that runs as root). It's possible the pid file is stale.

If it's stale, get the pid of the Apache master process, and do something like echo 1234 > /var/run/httpd.pid, where 1234 is the pid in question.

After that, run monit monitor apache to restart monitoring of that service.