我正在努力寻找一个php-fpm的监控工具。
这是我试过的:
### Monitoring php-fpm: the parent process. check process php-fpm with pidfile /var/run/php-fpm/php-fpm.pid group phpcgi # phpcgi group start program = "/etc/init.d/php-fpm start" stop program = "/etc/init.d/php-fpm stop" ## Test the UNIX socket. Restart if down. if failed unixsocket /var/run/php-fpm.sock then restart ## If the restarts attempts fail then alert. if 3 restarts within 5 cycles then timeout depends on php-fpm_bin depends on php-fpm_init ## Test the php-fpm binary. check file php-fpm_bin with path /usr/sbin/php-fpm group phpcgi if failed checksum then unmonitor if failed permission 755 then unmonitor if failed uid root then unmonitor if failed gid root then unmonitor ## Test the init scripts. check file php-fpm_init with path /etc/init.d/php-fpm group phpcgi if failed checksum then unmonitor if failed permission 755 then unmonitor if failed uid root then unmonitor if failed gid root then unmonitor
但它失败了,因为没有php-fpm.sock (Centos 6)
我使用php-fpm中的ping.path指令来检查它是否正常工作。
并configuration它在nginx.conf(我不知道如果它是你的设置)
location /ping { access_log off; allow 127.0.0.1; deny all; root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name; include fastcgi_params; }
在monit.d
check process php-fpm.www with pidfile /var/run/php-fpm/php-fpm.pid group php-fpm start program = "/etc/init.d/php-fpm start" stop program = "/etc/init.d/php-fpm stop" if failed host localhost port 80 protocol http and request '/ping' with timeout 20 seconds for 5 cycles then restart ## If the restarts attempts fail then alert. if 3 restarts within 5 cycles then timeout depends on php-fpm_bin depends on php-fpm_init depends on nginx
据我所知,php5-fpm和其他进程(如nginx)之间的唯一区别是它的pid文件不包含换行符。 也许这就是问题所在。 在任何情况下,我的解决scheme是丑陋的,但它也很好地工作:我只是直接检查“处理php-fpm与pidfile /var/run/php5-fpm.sock”(同时试图find一个修复这个错误)。
您是否考虑过使用monit的进程模式匹配以及现有的守护进程启动和停止?
某些forms的matching "php-fpm"
/var/run/php-fpm/php-fpm.sock是否有php-fpm.sock文件? 如果有,则修改这一行
if failed unixsocket /var/run/php-fpm.sock then restart
风趣
if failed unixsocket /var/run/php-fpm/php-fpm.sock then restart