1.nginx配置增加状态

vim/app/local/nginx/conf/vhosts/php-fpm_status.confserver{listen*:81default_server;server_name_;location/php-fpm-status{fastcgi_indexindex.php;fastcgi_paramSCRIPT_FILENAME/scripts$fastcgi_script_name;includefastcgi_params;fastcgi_pass127.0.0.1:9000;}}


2.测试访问

#curlhttp://localhost:81/php-fpm-statuspool:wwwprocessmanager:staticstarttime:09/Jan/2017:16:09:17+0800startsince:176354acceptedconn:5538266listenqueue:0maxlistenqueue:31listenqueuelen:65535idleprocesses:298activeprocesses:2totalprocesses:300maxactiveprocesses:300maxchildrenreached:0slowrequests:1102

3.增加监控脚本

vimphp_stat.sh#!/bin/bashsource/etc/bashrc>/dev/null2>&1source/etc/profile>/dev/null2>&1LOG=/usr/local/zabbix-agent/logs/phpfpmstatus.logcurl-shttp://127.0.0.1:81/php-fpm-status>$LOGpool(){awk'/pool/{print$NF}'$LOG}process_manager(){awk'/processmanager/{print$NF}'$LOG}start_since(){awk'/startsince:/{print$NF}'$LOG}accepted_conn(){awk'/acceptedconn:/{print$NF}'$LOG}listen_queue(){awk'/^(listenqueue:)/{print$NF}'$LOG}max_listen_queue(){awk'/maxlistenqueue:/{print$NF}'$LOG}listen_queue_len(){awk'/listenqueuelen:/{print$NF}'$LOG}idle_processes(){awk'/idleprocesses:/{print$NF}'$LOG}active_processes(){awk'/^(activeprocesses:)/{print$NF}'$LOG}total_processes(){awk'/totalprocesses:/{print$NF}'$LOG}max_active_processes(){awk'/maxactiveprocesses:/{print$NF}'$LOG}max_children_reached(){awk'/maxchildrenreached:/{print$NF}'$LOG}case"$1"inpool)pool;;process_manager)process_manager;;start_since)start_since;;accepted_conn)accepted_conn;;listen_queue)listen_queue;;max_listen_queue)max_listen_queue;;listen_queue_len)listen_queue_len;;idle_processes)idle_processes;;active_processes)active_processes;;total_processes)total_processes;;max_active_processes)max_active_processes;;max_children_reached)max_children_reached;;*)echo"Usage:$0{pool|process_manager|start_since|accepted_conn|listen_queue|max_listen_queue|listen_queue_len|idle_processes|active_processes|total_processes|max_active_processes|max_children_reached}"esac

4.增加配置参数

vim/app/local/nginx/conf/vhosts/php-fpm_status.conf#phpstatusUserParameter=phpfpm.status.pool,/usr/local/zabbix-agent/scripts/php_stat.shpoolUserParameter=phpfpm.status.process.manager,/usr/local/zabbix-agent/scripts/php_stat.shprocess_managerUserParameter=phpfpm.status.start.since,/usr/local/zabbix-agent/scripts/php_stat.shstart_sinceUserParameter=phpfpm.status.accepted.conn,/usr/local/zabbix-agent/scripts/php_stat.shaccepted_connUserParameter=phpfpm.status.listen.queue,/usr/local/zabbix-agent/scripts/php_stat.shlisten_queueUserParameter=phpfpm.status.max.listen.queue,/usr/local/zabbix-agent/scripts/php_stat.shmax_listen_queueUserParameter=phpfpm.status.listen.queue.len,/usr/local/zabbix-agent/scripts/php_stat.shlisten_queue_lenUserParameter=phpfpm.status.idle.processes,/usr/local/zabbix-agent/scripts/php_stat.shidle_processesUserParameter=phpfpm.status.active.processes,/usr/local/zabbix-agent/scripts/php_stat.shactive_processesUserParameter=phpfpm.status.total.processes,/usr/local/zabbix-agent/scripts/php_stat.shtotal_processesUserParameter=phpfpm.status.max.active.processes,/usr/local/zabbix-agent/scripts/php_stat.shmax_active_processesUserParameter=phpfpm.status.max.children.reached,/usr/local/zabbix-agent/scripts/php_stat.shmax_children_reached

5.重启进程

/etc/init.d/zabbix_agentdrestart

6.增加模板

7.增加item

8.增加监控图像

9.查看监控