Zabbix监控php-fpm
原理:通过nginx的代理功能,把php-fpm的状态转发出来。再用command在zabbix上添加监控。步骤
1、开启Php-fpm状态功能。PHP5.3.3以后就集成了php-fpm模块,不需要额外装包。 2、Nginx配置。
3、重启nginx/php-fpm服务。
4、打开status页面。(测试到这初步成功)5、在zabbix agent脚本目录下创建脚本(/usr/local/zabbix/etc/monitor_scripts/) # cat php-fpm_status.sh -----可直接复制粘贴---- ######################################################################### # File Name:php-fpm_status.sh # Author: Ifeng # Created Time:2014年06月12日 星期四 #########################################################################
#!/bin/bash idle(){ wget --quiet -O -http://127.0.0.1/status |grep "idle processes" |awk '{print$3}'}
total(){ wget --quiet -O - http://127.0.0.1/status|grep "total processes" |awk '{print$3}'}
active(){ wget --quiet -O -http://127.0.0.1/status |grep "active" |awk '{print$3}'|grep -v"process"}
mactive(){
wget --quiet -O -http://127.0.0.1/status |grep "max active processes:" |awk'{print$4}'}
listenqueuelen(){ wget --quiet -O -http://127.0.0.1/status |grep "listen queue len" |awk '{print$4}'}
listenqueue(){ wget --quiet -O -http://127.0.0.1/status |grep "listen queue:"|grep -vE"len|max"|awk '{print$3}'}
since(){ wget --quiet -O -http://127.0.0.1/status |grep "start since: " |awk '{print$3}'}
conn(){ wget --quiet -O -http://127.0.0.1/status |grep "accepted conn" |awk '{print$3}'}$1
6、更改zabbix.agentd.conf的配置文件如下:UnsafeUserParameters=1 注意路径与脚本所在路径一致UserParameter=idle.processe,/usr/local/zabbix/etc/monitor_scriptsphp-fpm_status.shidle
UserParameter=total.processes,/usr/local/zabbix/etc/monitor_scripts/php-fpm_status.shtotal
UserParameter=active.processes,/usr/local/zabbix/etc/monitor_scripts/php-fpm_status.shactive
UserParameter=max.active.processes,/usr/local/zabbix/etc/monitor_scripts/php-fpm_status.shmactive
UserParameter=listen.queue.len,/usr/local/zabbix/etc/monitor_scripts/php-fpm_status.shlistenqueuelen
UserParameter=listen.queue,/usr/local/zabbix/etc/monitor_scripts/php-fpm_status.shlistenqueue
UserParameter=start.since,/usr/local/zabbix/etc/monitor_scripts/php-fpm_status.shsince
UserParameter=accepted.conn,/usr/local/zabbix/etc/monitor_scripts/php-fpm_status.shconn
7、Zabbix上添加监控。Zabbix WEB面面中,通过以上定义好的key 进行操作。
注:PHP-fpm的状态参数有很多,可用curl 127.0.0.1/status?full 查看如有需求,可自行改动脚本。
页:
[1]