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_pathpm.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池子名称,大多数为wwwprocess manager: dynamic # 进程管理方式,值:static, dynamic or ondemand. dynamicstart 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?fullpool: wwwprocess manager: dynamicstart time: 24/Mar/2020:10:29:20 +0800start since: 686accepted conn: 130listen queue: 0max listen queue: 0listen queue len: 128idle processes: 6active processes: 1total processes: 7max active processes: 6max children reached: 0slow 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 # 请求URIcontent 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 # 上一个请求使用的内存................. # 省略部分内容
