1.nginx配置增加状态

vim /app/local/nginx/conf/vhosts/php-fpm_status.conf server {    listen  *:81 default_server;    server_name _;    location /php-fpm-status {    fastcgi_index index.php;    fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;    include fastcgi_params;    fastcgi_pass 127.0.0.1:9000;    }}

2.测试访问

# curl http://localhost:81/php-fpm-statuspool:                 wwwprocess manager:      staticstart time:           09/Jan/2017:16:09:17 +0800start since:          176354accepted conn:        5538266listen queue:         0max listen queue:     31listen queue len:     65535idle processes:       298active processes:     2total processes:      300max active processes: 300max children reached: 0slow requests:        1102

3.增加监控脚本

vim php_stat.sh #!/bin/bashsource /etc/bashrc >/dev/null 2>&1source /etc/profile >/dev/null 2>&1LOG=/usr/local/zabbix-agent/logs/phpfpmstatus.logcurl -s http://127.0.0.1:81/php-fpm-status >$LOGpool(){        awk '/pool/ {print $NF}' $LOG}process_manager(){        awk '/process manager/ {print $NF}' $LOG}start_since(){        awk '/start since:/ {print $NF}' $LOG}accepted_conn(){        awk '/accepted conn:/ {print $NF}' $LOG}listen_queue(){        awk '/^(listen queue:)/ {print $NF}' $LOG}max_listen_queue(){        awk '/max listen queue:/ {print $NF}' $LOG}listen_queue_len(){        awk '/listen queue len:/ {print $NF}' $LOG}idle_processes(){        awk '/idle processes:/ {print $NF}' $LOG}active_processes(){        awk '/^(active processes:)/ {print $NF}' $LOG}total_processes(){        awk '/total processes:/ {print $NF}' $LOG}max_active_processes(){        awk '/max active processes:/ {print $NF}' $LOG}max_children_reached(){        awk '/max children reached:/ {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.sh poolUserParameter=phpfpm.status.process.manager,/usr/local/zabbix-agent/scripts/php_stat.sh process_managerUserParameter=phpfpm.status.start.since,/usr/local/zabbix-agent/scripts/php_stat.sh start_sinceUserParameter=phpfpm.status.accepted.conn,/usr/local/zabbix-agent/scripts/php_stat.sh accepted_connUserParameter=phpfpm.status.listen.queue,/usr/local/zabbix-agent/scripts/php_stat.sh listen_queueUserParameter=phpfpm.status.max.listen.queue,/usr/local/zabbix-agent/scripts/php_stat.sh max_listen_queueUserParameter=phpfpm.status.listen.queue.len,/usr/local/zabbix-agent/scripts/php_stat.sh listen_queue_lenUserParameter=phpfpm.status.idle.processes,/usr/local/zabbix-agent/scripts/php_stat.sh idle_processesUserParameter=phpfpm.status.active.processes,/usr/local/zabbix-agent/scripts/php_stat.sh active_processesUserParameter=phpfpm.status.total.processes,/usr/local/zabbix-agent/scripts/php_stat.sh total_processesUserParameter=phpfpm.status.max.active.processes,/usr/local/zabbix-agent/scripts/php_stat.sh max_active_processesUserParameter=phpfpm.status.max.children.reached,/usr/local/zabbix-agent/scripts/php_stat.sh max_children_reached

5.重启进程

/etc/init.d/zabbix_agentd restart

6.增加模板

7.增加item

8.增加监控图像

9.查看监控