9

所以我的monitrc文件中有以下内容:

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

但我不断收到以下错误:

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

7 回答 7

12

如果服务器的主机名是“apache”,则与监视系统负载的默认规则发生冲突。

Monit 似乎有“检查系统主机名”的隐含规则,其中主机名是主机名命令的输出。

您可以通过添加如下一行来覆盖它:

check system newhostname

例如:

check system localhost
于 2013-01-25T17:18:28.520 回答
4

当我忘记注释掉这一行时,我看到了这个错误:

include /etc/monit/conf.d/*

在自定义 /etc/monit/conf.d/myprogram.conf 文件中,因此它递归地包含该文件。

于 2015-11-23T17:02:31.280 回答
3

您是否有任何机会在此条目下方或在单独的监控配置文件中有一个主机名为 apache 的条目?

于 2012-02-25T22:33:45.153 回答
1

您多次定义了相同的服务。检查该服务的所有监控配置文件。这包括您的 monitrc 和“包含”部分下列出的所有文件(如 include /etc/monit/conf.d/*)。

如果您在“包含”目录之一的文件中重新定义“包含”,您将遇到递归引用问题。

于 2019-02-15T21:19:10.247 回答
0

非常非常重要的事情:您需要 monit 5.5 例如在 ubuntu 12.04 中仅在 repo 5.3 中可用

所以你需要从其他 repo 下载和安装。我的解决方案,例如:

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

于 2013-12-10T17:00:18.877 回答
0

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

于 2015-10-21T18:53:32.720 回答
0

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

sudo service monit restart

于 2017-10-04T09:40:49.170 回答