废话不多说,需要Zabbix监控php-fpm性能状态,首先你需要开启php-fpm的状态页,请参考文章《开启php-fpm状态页》,然后我一步一步来完成Zabbix对php-fpm的监控。
Zabbix客户端配置
1、自定义key值
#编辑配置zabbix_agentd配置文件,添加以下内容
[root@localhost ~]# vim /usr/local/zabbix/etc/zabbix_agentd.conf
- UserParameter=php-fpm.status[*],/data/scripts/auto_detection_php_fpm_state.sh $1
2、重启Zabbix_agentd服务
[root@localhost ~]# service zabbix_agentd restart
3、下载脚本文件(获取监控值)
[root@localhost ~]# cd /data/scripts
[root@localhost scripts]# wget -c https://mirrors.yangxingzhen.com/shell/auto_detection_php_fpm_state.sh
[root@localhost scripts]# cat auto_detection_php_state.sh
#脚本内容如下
#!/bin/bash #Date:2018-5-20 14:08:55 #Author Blog: # https://www.yangxingzhen.com #Author WeChat: # 微信公众号:小柒博客 #Author mirrors site: # https://mirrors.yangxingzhen.com #About the Author # BY:YangXingZhen # Mail:xingzhen.yang@yangxingzhen.com #Zabbix监控php-fpm性能以及进程状态 HOST="https://www.yangxingzhen.com" if [ $# -eq 0 ];then echo -e "\033[32m Usage:/bin/bash|sh $0 ping|active|idle|total|max\033[0m" exit 1 fi function ping { /sbin/pidof php-fpm | wc -l } function active { curl -s "${HOST}/php_fpm_status" |awk '/^active/ {print $NF}' } function idle { curl -s "${HOST}/php_fpm_status" |awk '/idle/ {print $NF}' } function total { curl -s "${HOST}/php_fpm_status" |awk '/total/ {print $NF}' } function max { curl -s "${HOST}/php_fpm_status" |awk '/max active/ {print $NF}' } $1
[root@localhost scripts]# chmod +x auto_detection_php_fpm_state.sh
5、验证
#使用zabbix_get命令获取key值
Zabbix监控平台配置
1、下载模板文件
模板附件下载:
2、导入php-fpm模板
进入后台->配置->模板->导入(右上角)-> 选择下载的模板文件->最后点击导入 。
至此,php-fpm模板已经导入到Zabbix中。
关联模板
需要把php-fpm模板链接到你的监控主机上,进入后台->配置->点击你的主机->模板->选择刚才导入模板,点击添加,最后点击更新即可。
效果展示
若文章图片、下载链接等信息出错,请在评论区留言反馈,博主将第一时间更新!如本文“对您有用”,欢迎随意打赏,谢谢!


不错不错
打卡
佩服佩服!!!!