Monit service name error
Asked Answered
H

7

9

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'
Hone answered 8/12, 2011 at 19:31 Comment(0)
C
12

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
Contribution answered 25/1, 2013 at 17:18 Comment(0)
P
4

I saw this error when I forgot to comment out the line:

include /etc/monit/conf.d/*

in a custom /etc/monit/conf.d/myprogram.conf file, so it was recursively including that file.

Prefer answered 23/11, 2015 at 17:2 Comment(0)
T
3

By any chance do you have an entry with a host name apache beneath this entry or in a separate monit config file?

Teeny answered 25/2, 2012 at 22:33 Comment(0)
E
1

You have the same service defined more than once. Check all your monit config files for that service. This includes your monitrc and all files listed under the "Includes" section (like include /etc/monit/conf.d/*).

If you redefine "Includes" within a file in one of your "Includes" directories, you will run into recursive reference problems.

Encage answered 15/2, 2019 at 21:19 Comment(0)
S
0

Very very important thing : you need monit 5.5 For example in ubuntu 12.04 available in repo only 5.3

So you need to download and install from other repo. Solution for me , for example :

wget http://mirrors.kernel.org/ubuntu/pool/universe/m/monit/monit_5.5.1-1_amd64.deb && sudo dpkg -i monit_5.5.1-1_amd64.deb

Salangi answered 10/12, 2013 at 17:0 Comment(0)
T
0

Check if you have had any conflicts for Apache defined in any of the monit conf files under /etc/monit.d/ directory, I accidentally did added nginx for my puma.conf and ran into the same error before.

Tuppeny answered 21/10, 2015 at 18:53 Comment(0)
S
0

For my case, I simply had to restart monit to get rid of the service name error:

sudo service monit restart

Skijoring answered 4/10, 2017 at 9:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.