资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

Zabbix监控php-fpm

原理:通过nginx的代理功能,把php-fpm的状态转发出来。再用command在zabbix上添加监控。

武乡网站建设公司创新互联建站,武乡网站设计制作,有大型网站制作公司丰富经验。已为武乡成百上千提供企业网站建设服务。企业网站搭建\成都外贸网站建设要多少钱,请找那个售后服务好的武乡做网站的公司定做!

 

步骤

1、开启Php-fpm状态功能。

PHP5.3.3以后就集成了php-fpm模块,不需要额外装包。

   Zabbix监控php-fpm

2、Nginx配置。

Zabbix监控php-fpm

3、重启nginx/php-fpm服务。

4、打开status页面。(测试到这初步成功)

Zabbix监控php-fpm

5、在zabbix agent脚本目录下创建脚本(/usr/local/zabbix/etc/monitor_scripts/)

   [root@master~]# 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查看

如有需求,可自行改动脚本。



网页名称:Zabbix监控php-fpm
本文地址:http://cdkjz.cn/article/ihhoge.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220