date: 2020-03-24title: php-fpm开启状态统计页 #标题
tags: php #标签
categories: zabbix # 分类
zabbix监控php-fpm时,需要开启它状态统计页以便收集相关信息。
修改php配置文件
[root@mysql ~]# cat /usr/local/php5.6/etc/php-fpm.conf | grep status_path
pm.status_path = /status # 去掉开头的注释符号“;”
nginx添加location规则
[root@mysql ~]# vi /usr/local/nginx/conf/nginx.conf # location规则如下
location ~ ^/(status|ping)$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi.conf;
}
重启相关服务
[root@mysql ~]# systemctl restart php-fpm
[root@mysql ~]# nginx -s reload
访问状态统计页
[root@mysql ~]# curl www.test.com/status # 访问测试
pool: www # fpm池子名称,大多数为www
process manager: dynamic # 进程管理方式,值:static, dynamic or ondemand. dynamic
start time: 24/Mar/2020:10:29:20 +0800 # 启动日期,如果reload了php-fpm,时间会更新
start since: 34 # 运行时长
accepted conn: 4 # 当前池子接受的请求数
listen queue: 0 # 请求等待队列,如果这个值不为0,那么要增加FPM的进程数量
max listen queue: 0 # 请求等待队列最高的数量
listen queue len: 128 # socket等待队列长度
idle processes: 4 # 空闲进程数量
active processes: 1 # 活跃进程数量
total processes: 5 # 总进程数量
max active processes: 1 # 最大的活跃进程数量(FPM启动开始算)
max children reached: 0 # 最大进程最大数量限制的次数,如果这个数量不为0,那说明你的最大进程数量太小了,请改大一点。
slow requests: 0 # 启用了php-fpm slow-log,缓慢请求的数量
php-fpm其他参数
php-fpm状态页比较个性化的一个地方是它可以带参数,可以带参数json、xml、html(输出格式不一样),以及full参数(显示每个php进程的详细信息)。
php-fpm状态页非常使用,使用zabbix或者nagios监控可以考虑使用xml或者默认方式。用web的话,推荐使用html,表格会比较清晰。
full参数
[root@mysql ~]# curl www.test.com/status?full
pool: www
process manager: dynamic
start time: 24/Mar/2020:10:29:20 +0800
start since: 686
accepted conn: 130
listen queue: 0
max listen queue: 0
listen queue len: 128
idle processes: 6
active processes: 1
total processes: 7
max active processes: 6
max children reached: 0
slow requests: 0
************************
pid: 90213 # 进程PID,可以单独kill这个进程
state: Idle # 当前进程的状态 (Idle, Running, …)
start time: 24/Mar/2020:10:29:20 +0800 # 进程启动的日期
start since: 686 # 当前进程运行时长
requests: 23 # 当前进程处理了多少个请求
request duration: 85032 # 请求时长(微妙)
request method: POST # 请求方法 (GET, POST, …)
request URI: /zabbix/jsrpc.php?output=json-rpc # 请求URI
content length: 114 # 请求内容长度 (仅用于 POST)
user: - # 用户 (PHP_AUTH_USER) (or ‘-’ 如果没设置)
script: /usr/local/nginx/html/zabbix/jsrpc.php # (or ‘-’ if not set)
last request cpu: 94.08 # 最后一个请求CPU使用率。
last request memory: 6291456 # 上一个请求使用的内存
................. # 省略部分内容