所以我在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'
如果服务器的主机名是“apache”,则冲突是使用默认规则来监视系统负载。
Monit似乎有“check system hostname”的隐含规则,其中hostname是hostname命令的输出。
您可以通过添加如下行来覆盖它:
check system newhostname
例如:
check system localhost
当我忘记评论该行时,我看到了这个错误:
include /etc/monit/conf.d/*
在自定义的/etc/monit/conf.d/myprogram.conf文件中,因此它以递归方式包含该文件。
您是否有机会在此条目下或在单独的monit配置文件中有一个带有主机名apache的条目?
您具有多次定义的相同服务。检查该服务的所有monit配置文件。这包括你的monitrc和“Includes”部分下列出的所有文件(比如include /etc/monit/conf.d/*)。
如果在“包含”目录中的某个文件中重新定义“包含”,则会遇到递归引用问题。
非常非常重要的事情:你需要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
对于我的情况,我只需要重新启动monit
以摆脱服务名称错误:
sudo service monit restart
检查你在monit conf
目录下的任何/etc/monit.d/
文件中定义的Apache是否有任何冲突,我不小心为我的nginx
添加了puma.conf
并且之前遇到了同样的错误。