munin 监控 php-fpm
php5.3以前php-fpm和php-cgi是分开的,php-fpm做为php-cgi,第三方的管理工具包存在的,php5.3以后,php吸收了php-fpm,当你查看进程时,在也看不到php-cgi了,取尔代之的是php-fpm进程。了解php-fpm进程的相关情况就很有必要了。
1,修改php-fpm配置
# vim /etc/php-fpm.d/www.conf pm.status_path = /status //把前面注释去掉 # /etc/init.d/php-fpm restart //重启
2,修改Nginx配置
# vim /etc/Nginx/conf.d/munin.conf //添加以下内容 location ~ ^/(status|ping)$ { include fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $fastcgi_script_name; allow 127.0.0.1; #allow 192.168.1.101; #allow munin.51yip.com; deny all; } # /etc/init.d/Nginx restart //重启
访问http://xxxxx.com/status,如果出现以下内容,说明Nginx和php-fpm配置对了
pool: www process manager: dynamic start time: 14/Jan/2015:09:26:23 +0800 start since: 28796 accepted conn: 261 listen queue: 0 max listen queue: 0 listen queue len: 128 idle processes: 6 active processes: 1 total processes: 7 max active processes: 4 max children reached: 0
3,下载munin的php-fpm插件
https://github.com/tjstein/php5-fpm-munin-plugins
4,配置munin php-fpm插件
# unzip php5-fpm-munin-plugins-master.zip # cd php5-fpm-munin-plugins-master # chmod +x phpfpm_* # ln -s /路径/phpfpm_* /etc/munin/plugins/ # vim /etc/munin/plugin-conf.d/php-fpm //创建新文件 [phpfpm*] user tank env.url http://munin.com/status env.ports 80 env.phpbin php-fpm env.phppool www # /etc/init.d/munin-node restart //重启
这里要注意[phpfpm*]可不是随便写的,根这个正则去找插件的,如果不匹配的话,在运行munin-run phpfpm_status 的时候,会报以下错误
Can't exec "/etc/munin/plugins/phpfpm_status": Permission denied
5,查看php-fpm插件是不是安装好了
[root@node1 plugins]# munin-run phpfpm_memory ram.value 277811200 [root@node1 plugins]# munin-run phpfpm_status idle.value 6 active.value 1 total.value 7 [root@node1 plugins]# munin-run phpfpm_processes php_processes.value 7 [root@node1 plugins]# munin-run phpfpm_connections accepted.value 406