简体   繁体   中英

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'

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

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.

您是否有任何机会在此条目下方或单独的 monit 配置文件中具有主机名 apache 的条目?

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.

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

检查在/etc/monit.d/目录下的任何/etc/monit.d/ monit conf文件中定义的 Apache 是否有任何冲突,我不小心为我的puma.conf添加了nginx并且之前遇到了同样的错误。

就我而言,我只需重新启动monit即可消除服务名称错误:

sudo service monit restart

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM