1、开启php status页面
sed -i 's#\;pm.status_path = /status#pm.status_path = /status#g' /etc/php-fpm.d/www.conf
2、开启nginx 访问php状态页虚拟主机设置
cat /etc/nginx/conf.d/fpm.conf
server {
listen *:10081 default_server;
server_name _;
location ~ ^/(status|ping)$
{
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
}
}
3、执行脚本
cat /data/adminshell/php-fpm_status.sh
#!/bin/bash idle(){ curl -s http://127.0.0.1:10081/status|grep "idle"|awk 'BEGIN {OFS=":"} {print $3}' } total(){ curl -s http://127.0.0.1:10081/status|grep "total"|awk 'BEGIN {OFS=":"} {print $3}' } active(){ wget --quiet -O - http://127.0.0.1:10081/status|grep "active" |awk '{print$3}'|grep -v "process" } mactive(){ wget --quiet -O - http://127.0.0.1:10081/status?auto |grep "max active processes:" |awk '{print$4}' } listenqueuelen(){ wget --quiet -O - http://127.0.0.1:10081/status?auto |grep "listen queue len" |awk '{print$4}' } listenqueue(){ wget --quiet -O - http://127.0.0.1:10081/status?auto |grep "listen queue:"|grep -vE "len|max"|awk '{print$3}' } since(){ wget --quiet -O - http://127.0.0.1:10081/status?auto |grep "start since: " |awk '{print$3}' } conn(){ wget --quiet -O - http://127.0.0.1:10081/status?auto |grep "accepted conn" |awk '{print$3}' } maxchildrenreached(){ wget --quiet -O - http://127.0.0.1:10081/status?auto |grep "reached" |awk '{print$4}' } $1
4、zabbix配置键值
cat /etc/zabbix/zabbix_agentd.d/php-fpm.conf
##############################PHP-FPM###################################
UserParameter=idle.processe,/data/adminshell/php-fpm_status.sh idle
UserParameter=total.processes,/data/adminshell/php-fpm_status.sh total
UserParameter=active.processes,/data/adminshell/php-fpm_status.sh active
UserParameter=max.active.processes,/data/adminshell/php-fpm_status.sh mactive
UserParameter=listen.queue.len,/data/adminshell/php-fpm_status.sh listenqueuelen
UserParameter=listen.queue,/data/adminshell/php-fpm_status.sh listenqueue
UserParameter=start.since,/data/adminshell/php-fpm_status.sh since
UserParameter=accepted.conn,/data/adminshell/php-fpm_status.sh conn
UserParameter=max.children.reached,/data/adminshell/php-fpm_status.sh maxchildrenreached
5、zabbix设置模板
服务器端 # 页面监控主机添加对应的application items
创建Graphs(php-fpm status)
zabbix后台 Configuration->Hosts->被监控的主机name->Graphs
查看graph(php-fpm status)
zabbix后台 Monitoring->Graphs->对应的graph