mysqlapachemonit

Monit service name error


So I have the following in my monitrc file:

check process apache with pidfile /usr/local/apache/logs/httpd.pid
group apache
start program = "/etc/init.d/httpd start"
stop program = "/etc/init.d/httpd stop"
if failed host XXX port 80 protocol http
and request "/monit/token" then restart
if cpu is greater than 60% for 2 cycles then alert
if cpu 80% for 5 cycles then restart
if totalmem 500 MB for 5 cycles then restart
if children 250 then restart
if loadavg(5min) greater than 10 for 8 cycles then stop
if 3 restarts within 5 cycles then timeout

but I keep getting the error that:

Error: service name conflict, apache already defined '/usr/local/apache/logs/httpd.pid'

Solution

  • If the hostname of the server is 'apache' then the conflict is with the default rule for monitoring the system load.

    Monit seems to have the implicit rule of 'check system hostname', where the hostname is the output of hostname command.

    You can overwrite that by adding just a line like:

    check system newhostname
    

    For example:

    check system localhost