我刚刚根据monit文档安装并configuration了monit 。 除Apache以外的所有服务均列为“正在运行”,但Apache说“ 未监控” 。
monitconfiguration中的相关行是:
check process apache with pidfile /var/run/httpd.pid group www start program = "/etc/init.d/httpd start" stop program = "/etc/init.d/httpd stop" if failed host localhost port 80 protocol http then restart if 5 restarts within 5 cycles then timeout
我可以从服务器访问http:// localhost / server-status和http:// localhost 。 Monit将Apache的监视模式列为活动状态 。
服务器正在运行CentOS 5.4。
PID文件对于父httpd服务器是正确的:
[server ~]$ cat /var/run/httpd.pid 2905 [server ~]$ ps auxc | grep httpd root 2905 0.0 0.9 26952 4808 ? Ss 11:36 0:00 httpd
确保pid文件的内容与Apache主进程的pid(即以root身份运行的httpd进程)相匹配。 这是可能的PID文件是陈旧的。
如果它是陈旧的,得到Apache主进程的PID,并执行echo 1234 > /var/run/httpd.pid ,其中1234是有问题的PID。
之后,运行monit monitor apache重新启动对该服务的监视。
您不提供操作系统版本/分布,但在CentOS 6上,您应该监视的PID文件位于: /var/run/httpd/httpd.pid
所以改成:
check process apache with pidfile /var/run/httpd/httpd.pid
顺便提一句,CentOS 5的Apache PID文件位于: /var/run/httpd.pid
编辑:也引用PIDpath。
Monit邮件列表中有关于您正在使用的协议testing的说明:
http://lists.gnu.org/archive/html/monit-general/2004-12/msg00057.html
如果您使用基于名称的虚拟主机,则可能需要传递主机名或站点名称。