zabbixp-监控 php-fpm

1.php-fpm工作模式常用与nginx结合使用

//修改php-fpm.conf

[root@web01 ~]# vim /etc/php-fpm.d/www.conf

pm.status_path = /phpfpm_status 将前面的注释删除“;”

[root@web01 ~]# systemctl restart php-fpm.service

2.在nginx.conf的配置文件中添加php-fpm的状态信息

[root@web01 ~]# cat /etc/nginx/conf.d/status.conf
server {
listen 80;
server_name _;

location /nginx_status {
stub_status;
access_log off;
# allow 127.0.0.1;
# deny all;
}
location ~ ^/(phpfpm_status)$ {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include proxy_params;
}

}

3.访问测试phpfpm_status

[root@web01 ~]# curl http://127.0.0.1/phpfpm_status

扫描二维码关注公众号,回复: 3701805 查看本文章

#PHP-FPM状态解释:
pool #fpm池名称,大多数为www
process manager #进程管理方式dynamic或者static
start time #启动日志,如果reload了fpm,时间会更新
start since #运行时间
accepted conn #当前池接受的连接数
listen queue #请求等待队列,如果这个值不为0,那么需要增加FPM的进程数量 (长时间大于0)
max listen queue #请求等待队列最高的数量
listen queue len #socket等待队列长度
idle processes #空闲进程数量0 (空闲持续多长时间0则报警)
active processes #活跃进程数量200
total processes #总进程数量200
max active processes #最大的活跃进程数量(FPM启动开始计算)
max children reached #最大数量限制的次数,如果这个数量不为0,那说明你的最大进程数量过小,可以适当调整。
slow requests # 超过5s在执行,这就算慢

4.取值

curl -s http://127.0.0.1/phpfpm_status|grep "$1"|awk '{print $NF}'

2.定义监控项
[root@web02 zabbix_agentd.d]# cat php.conf
UserParameter=fpm[*],curl -s http://127.0.0.1/phpfpm_status|grep ^"$1":|awk '{print $NF}'

3.zabbix-server获取对应的监控项
[root@zabbix-server ~]# zabbix_get -s 172.16.1.7 -k fpm["accepted conn"]
50077

猜你喜欢

转载自www.cnblogs.com/fangdecheng/p/9841879.html