user816604
user816604

Reputation:

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'

Upvotes: 9

Views: 7242

Answers (7)

gdexlab
gdexlab

Reputation: 199

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.

Upvotes: 1

Guru
Guru

Reputation: 84

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.

Upvotes: 0

Nigel Nindo
Nigel Nindo

Reputation: 86

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

sudo service monit restart

Upvotes: 0

wrapperapps
wrapperapps

Reputation: 988

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.

Upvotes: 4

Dmitry Lavrinenko
Dmitry Lavrinenko

Reputation: 1

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

Upvotes: 0

miconda
miconda

Reputation: 1817

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

Upvotes: 12

Martin Murphy
Martin Murphy

Reputation: 1805

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

Upvotes: 3

Related Questions