解决方案是替换这一行:
check process apache with pidfile /var/run/httpd.pid
有了这条线:
check process httpd with pidfile /var/run/httpd/httpd.pid
而且我还删除了“组 apache”。
原帖:
在 CentOS 上安装Monit并为 Apache (httpd) 服务设置警报后,该服务不再创建 /var/run/httpd.pid 文件。
httpd 服务运行正常。
最重要的是,好像这还不够,Monit 将服务的状态报告为:执行失败
自然,重新启动此类服务的唯一方法是杀死它,因为“重新启动”脚本看不到任何正在运行的进程。
这些是 /etc/monit.d/monitrc 文件的内容:
set daemon 10
set logfile syslog facility log_daemon
set mailserver localhost
set mail-format { from: me@server.com }
set alert bugs@server.com
set httpd port 2812 and
# SSL ENABLE
# PEMFILE /var/certs/monit.pem
allow user:password
check process apache with pidfile /var/run/httpd.pid
group apache
start program = "/etc/init.d/httpd start"
stop program = "/etc/init.d/httpd stop"
if cpu is greater than 180% for 1 cycles then alert
if totalmem > 1200 MB for 2 cycles then restart
if children > 250 then restart
check process sshd with pidfile /var/run/sshd.pid
start program "/etc/init.d/sshd start"
stop program "/etc/init.d/sshd stop"
if failed port 22 protocol ssh for 5 cycles then restart
if 5 restarts within 25 cycles then timeout
“服务 httpd 重启”的输出:
Stopping httpd: [FAILED]
Starting httpd: (98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
[FAILED]
任何帮助将不胜感激。