当前位置: 首页>后端>正文

zabbix定制监控之php和nginx

zabbix定制监控之php和nginx,\color{red}{游戏运维外包,请点击官网联系},第1张 ???www.yiyuan21.com

zabbix定制监控之php和nginx,\color{gray}{本专题分享zabbix在lnmp上的使用心得。这是一系列的文章。},第2张

zabbix定制监控之php和nginx,\color{gray}{本专题包含部署安装,常规服务器各项指标的监控,微信报警信息,},第3张
zabbix定制监控之php和nginx,\color{gray}{以及根据公司的需求,定制监控模板。如需了解其他,请前往主页查看。},第4张

本文主要介绍zabbix自带监控之外的一些监控项目的定制。这篇主要介绍php和nginx的性能监控。是zabbix专题中的一篇。如需了解更多,请关注专题【zabbix】

一、配置nginx的status

1.1、确认http_stub_status_modul模块已经编译到nginx中

找到nginx进程的目录,直接nginx -V查看是否包含--with-http_stub_status_module,如果没有需要重新到nginx源码包的解压目录,带上--with-http_stub_status_modul重新编译一下nginx。

[root@monitor-server2 ~]# /opt/nginx/sbin/nginx -V
nginx version: nginx/1.5.8
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-23) (GCC) 
TLS SNI support enabled
configure arguments: --user=www --group=www --prefix=/opt/nginx --with-http_stub_status_module --with-http_ssl_module
#出现with-http_stub_status_module说明已装载status模块
1.2、启用status模块

修改nginx.conf文件,在默认server中增加一个如下的location即可,修改完成之后 /opt/nginx/sbin/nginx/ -s reload一下。然后就可以查看nginx的运行状态数据。

location /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.1;
allow 192.168.249.0/24; #这里填写zabbix server的ip
deny all;

查看nginx运行状态的数据

[root@monitor-server2 conf]# curl localhost/nginx_status
Active connections: 12 
server accepts handled requests
 34645574 34645574 52413191 
Reading: 0 Writing: 1 Waiting: 11 
1.3、nginx status数据含义说明:
zabbix定制监控之php和nginx,第5张

二、配置php-fpm的status

2.1、启动php-fpm的status

修改php-fpm.conf文件,去掉status页面的注释,并改如下名字,修改完之后重启php-fpm。

[root@monitor-server2 ~]# cat /opt/php5/etc/php-fpm.conf |grep -v '^;'
pm.status_path = /php_fpm-status
2.2、修改nginx.conf

修改nginx.conf文件,在默认server中增加一个如下的location,最终支持nginx和php-fpm的server配置如下:

server
    {

        listen  80 default_server;
        server_name localhost;
        root /home/www;

        index index.php index.html index.htm;

        ......

        #open nginx status (zabbix used)
        location /nginx_status {
                  stub_status on;
                  access_log off;
                  allow 127.0.0.1;   #主动式只需要允许本机访问
                  deny all;
        }
        #open php-fpm status (zabbix used)
        location /php_fpm-status {
                fastcgi_pass  127.0.0.1:9000;
                include fastcgi_params;
                fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
                allow 127.0.0.1;  #主动式只需要允许本机访问
                access_log off;
                deny all;
        }
    }
2.3、查看php-fpm的status
[root@monitor-server2 conf]# curl localhost/php_fpm-status
pool:                 www
process manager:      dynamic
start time:           16/Nov/2020:12:33:17 +0800
start since:          15400563
accepted conn:        35031633
listen queue:         0
max listen queue:     129
listen queue len:     128
idle processes:       34
active processes:     1
total processes:      35
max active processes: 50
max children reached: 1
2.4、php-fpm status的含义说明
zabbix定制监控之php和nginx,第6张

三、编写数据提取脚本

3.1、nginx数据提取脚本,脚本保存于/opt/zabbix/etc/zabbix_agentd.conf.d/sh/目录。
[root@monitor-server2 sh]# cat nginx_status.sh 
#!/bin/bash
#check nginx status
ip=127.0.0.1
function ping() {                              #用于检测nginx进程是否存在
    /sbin/pidof nginx | wc -l
}

function active() {                 #用于提取status中的active数值
    /usr/bin/curl http://$ip/nginx_status 2>/dev/null | sed -n '1p' | awk '{print $NF}'
}

function accepts() {            #用于提取status中的accepts数值
    /usr/bin/curl http://$ip/nginx_status 2>/dev/null | sed -n '3p' | awk '{print }'
}

function handled() {          #用于提取status中的handled数值
    /usr/bin/curl http://$ip/nginx_status 2>/dev/null | sed -n '3p' | awk '{print }'
}

function requests() {        #用于提取status中的request数值
    /usr/bin/curl http://$ip/nginx_status 2>/dev/null | sed -n '3p' | awk '{print }'
}

function reading() {        #用于提取status中的reading数值
    /usr/bin/curl http://$ip/nginx_status 2>/dev/null | sed -n '4p' | awk '{print }'
}

function writing() {        #用于提取status中的writing数值
    /usr/bin/curl http://$ip/nginx_status 2>/dev/null | sed -n '4p' | awk '{print }'
}

function waiting() {     #用于提取status中的waiting数值
    /usr/bin/curl http://$ip/nginx_status 2>/dev/null | sed -n '4p' | awk '{print }'
}

                           #通过第一个位置参数的值来调用相应的函数 
3.2、php-fpm数据提取脚本
[root@monitor-server2 sh]# cat php_fpm_status.sh 
#!/bin/bash
#check php-fpm status
case  in
    ping)                           #检测php-fpm进程是否存在
    /sbin/pidof php-fpm | wc -l
    ;;
    start_since)             #提取status中的start since数值
    /usr/bin/curl localhost/php_fpm-status 2>/dev/null  | awk 'NR==4{print }'
    ;;
    conn)                     #提取status中的accepted conn数值
    /usr/bin/curl localhost/php_fpm-status 2>/dev/null  | awk 'NR==5{print }'
    ;;
    listen_queue)         #提取status中的listen queue数值
    /usr/bin/curl localhost/php_fpm-status 2>/dev/null  | awk 'NR==6{print }'
    ;;
     max_listen_queue)  #提取status中的max listen queue数值
    /usr/bin/curl localhost/php_fpm-status 2>/dev/null  | awk 'NR==7{print }'
    ;;
    listen_queue_len)    #提取status中的listen queue len
    /usr/bin/curl localhost/php_fpm-status 2>/dev/null  | awk 'NR==8{print }'
    ;;
    idle_processes)      #提取status中的idle processes数值
    /usr/bin/curl localhost/php_fpm-status 2>/dev/null  | awk 'NR==9{print }'
    ;;
    active_processes)   #提取status中的active processes数值
    /usr/bin/curl localhost/php_fpm-status 2>/dev/null  | awk 'NR==10{print }'
    ;;
     total_processes)    #提取status中的total processess数值
    /usr/bin/curl localhost/php_fpm-status 2>/dev/null  | awk 'NR==11{print }'
    ;;
    max_active_processes)     #提取status中的max active processes数值
    /usr/bin/curl localhost/php_fpm-status 2>/dev/null  | awk 'NR==12{print }'
    ;;
     max_children_reached)    #提取status中的max children reached数值
    /usr/bin/curl localhost/php_fpm-status 2>/dev/null  | awk 'NR==13{print }'
    ;;
    slow_requests)   #提取status中的slow requests数值
    /usr/bin/curl localhost/php_fpm-status 2>/dev/null  | awk 'NR==14{print }'  
    ;;
    *)
    echo "Usage: 

四、创建zabbix_agentd的配置文件

{conn|listen_queue|max_listen_queue|listen_queue_len|idle_processes|active_processess|total_processes|max_active_processes|max_children_reached|slow_requests}" exit 1 ;; esac
4.1、nginx监控配置文件
[root@ECSecd9faede0db ~]# cat /opt/zabbix/etc/zabbix_agentd.conf.d/userparameter_nginx.conf UserParameter=nginx.status[*],/opt/zabbix/etc/zabbix_agentd.conf.d/sh/nginx_status.sh UserParameter=nginx.version,/opt/nginx/sbin/nginx -v
4.2、php-fpm监控配置文件
[root@ECSecd9faede0db ~]# cat /opt/zabbix/etc/zabbix_agentd.conf.d/userparameter_php-fpm.conf UserParameter=php-fpm.status[*],/opt/zabbix/etc/zabbix_agentd.conf.d/sh/php_fpm_status.sh UserParameter=php-fpm.version,/opt/php5/sbin/php-fpm -v | awk 'NR==1{print

五,zabbix后台添加相应的模板

}'
5.1、nginx模板文件:
<?xml version="1.0" encoding="UTF-8"?> <zabbix_export> <version>3.4</version> <date>2021-05-13T11:33:29Z</date> <groups> <group> <name>Linux servers</name> </group> </groups> <templates> <template> <template>Template nginx status</template> <name>Template nginx status</name> <description>监控nginx的状态</description> <groups> <group> <name>Linux servers</name> </group> </groups> <applications> <application> <name>Nginx</name> </application> </applications> <items> <item> <name>nginx accepts</name> <type>7</type> <snmp_community/> <snmp_oid/> <key>nginx.status[accepts]</key> <delay>30s</delay> <history>90d</history> <trends>365d</trends> <status>0</status> <value_type>3</value_type> <allowed_hosts/> <units/> <snmpv3_contextname/> <snmpv3_securityname/> <snmpv3_securitylevel>0</snmpv3_securitylevel> <snmpv3_authprotocol>0</snmpv3_authprotocol> <snmpv3_authpassphrase/> <snmpv3_privprotocol>0</snmpv3_privprotocol> <snmpv3_privpassphrase/> <params/> <ipmi_sensor/> <authtype>0</authtype> <username/> <password/> <publickey/> <privatekey/> <port/> <description>接收到客户端发来的链接数</description> <inventory_link>0</inventory_link> <applications> <application> <name>Nginx</name> </application> </applications> <valuemap/> <logtimefmt/> <preprocessing/> <jmx_endpoint/> <master_item/> </item> <item> <name>nginx active</name> <type>7</type> <snmp_community/> <snmp_oid/> <key>nginx.status[active]</key> <delay>30s</delay> <history>90d</history> <trends>365d</trends> <status>0</status> <value_type>3</value_type> <allowed_hosts/> <units/> <snmpv3_contextname/> <snmpv3_securityname/> <snmpv3_securitylevel>0</snmpv3_securitylevel> <snmpv3_authprotocol>0</snmpv3_authprotocol> <snmpv3_authpassphrase/> <snmpv3_privprotocol>0</snmpv3_privprotocol> <snmpv3_privpassphrase/> <params/> <ipmi_sensor/> <authtype>0</authtype> <username/> <password/> <publickey/> <privatekey/> <port/> <description>当前活动连接数,包含处于等待状态的链接</description> <inventory_link>0</inventory_link> <applications> <application> <name>Nginx</name> </application> </applications> <valuemap/> <logtimefmt/> <preprocessing/> <jmx_endpoint/> <master_item/> </item> <item> <name>nginx handled</name> <type>7</type> <snmp_community/> <snmp_oid/> <key>nginx.status[handled]</key> <delay>30s</delay> <history>90d</history> <trends>365d</trends> <status>0</status> <value_type>3</value_type> <allowed_hosts/> <units/> <snmpv3_contextname/> <snmpv3_securityname/> <snmpv3_securitylevel>0</snmpv3_securitylevel> <snmpv3_authprotocol>0</snmpv3_authprotocol> <snmpv3_authpassphrase/> <snmpv3_privprotocol>0</snmpv3_privprotocol> <snmpv3_privpassphrase/> <params/> <ipmi_sensor/> <authtype>0</authtype> <username/> <password/> <publickey/> <privatekey/> <port/> <description>已处理完成的连接数</description> <inventory_link>0</inventory_link> <applications> <application> <name>Nginx</name> </application> </applications> <valuemap/> <logtimefmt/> <preprocessing/> <jmx_endpoint/> <master_item/> </item> <item> <name>nginx status</name> <type>7</type> <snmp_community/> <snmp_oid/> <key>nginx.status[ping]</key> <delay>30s</delay> <history>90d</history> <trends>365d</trends> <status>0</status> <value_type>3</value_type> <allowed_hosts/> <units/> <snmpv3_contextname/> <snmpv3_securityname/> <snmpv3_securitylevel>0</snmpv3_securitylevel> <snmpv3_authprotocol>0</snmpv3_authprotocol> <snmpv3_authpassphrase/> <snmpv3_privprotocol>0</snmpv3_privprotocol> <snmpv3_privpassphrase/> <params/> <ipmi_sensor/> <authtype>0</authtype> <username/> <password/> <publickey/> <privatekey/> <port/> <description/> <inventory_link>0</inventory_link> <applications> <application> <name>Nginx</name> </application> </applications> <valuemap> <name>Zabbix agent ping status</name> </valuemap> <logtimefmt/> <preprocessing/> <jmx_endpoint/> <master_item/> </item> <item> <name>nginx reading</name> <type>7</type> <snmp_community/> <snmp_oid/> <key>nginx.status[reading]</key> <delay>30s</delay> <history>90d</history> <trends>365d</trends> <status>0</status> <value_type>3</value_type> <allowed_hosts/> <units/> <snmpv3_contextname/> <snmpv3_securityname/> <snmpv3_securitylevel>0</snmpv3_securitylevel> <snmpv3_authprotocol>0</snmpv3_authprotocol> <snmpv3_authpassphrase/> <snmpv3_privprotocol>0</snmpv3_privprotocol> <snmpv3_privpassphrase/> <params/> <ipmi_sensor/> <authtype>0</authtype> <username/> <password/> <publickey/> <privatekey/> <port/> <description>正在读取请求头信息的连接数</description> <inventory_link>0</inventory_link> <applications> <application> <name>Nginx</name> </application> </applications> <valuemap/> <logtimefmt/> <preprocessing/> <jmx_endpoint/> <master_item/> </item> <item> <name>nginx requests</name> <type>7</type> <snmp_community/> <snmp_oid/> <key>nginx.status[requests]</key> <delay>30s</delay> <history>90d</history> <trends>365d</trends> <status>0</status> <value_type>3</value_type> <allowed_hosts/> <units/> <snmpv3_contextname/> <snmpv3_securityname/> <snmpv3_securitylevel>0</snmpv3_securitylevel> <snmpv3_authprotocol>0</snmpv3_authprotocol> <snmpv3_authpassphrase/> <snmpv3_privprotocol>0</snmpv3_privprotocol> <snmpv3_privpassphrase/> <params/> <ipmi_sensor/> <authtype>0</authtype> <username/> <password/> <publickey/> <privatekey/> <port/> <description>客户端请求总数</description> <inventory_link>0</inventory_link> <applications> <application> <name>Nginx</name> </application> </applications> <valuemap/> <logtimefmt/> <preprocessing/> <jmx_endpoint/> <master_item/> </item> <item> <name>nginx waiting</name> <type>7</type> <snmp_community/> <snmp_oid/> <key>nginx.status[waiting]</key> <delay>30s</delay> <history>90d</history> <trends>365d</trends> <status>0</status> <value_type>3</value_type> <allowed_hosts/> <units/> <snmpv3_contextname/> <snmpv3_securityname/> <snmpv3_securitylevel>0</snmpv3_securitylevel> <snmpv3_authprotocol>0</snmpv3_authprotocol> <snmpv3_authpassphrase/> <snmpv3_privprotocol>0</snmpv3_privprotocol> <snmpv3_privpassphrase/> <params/> <ipmi_sensor/> <authtype>0</authtype> <username/> <password/> <publickey/> <privatekey/> <port/> <description>处于闲置状态的连接数</description> <inventory_link>0</inventory_link> <applications> <application> <name>Nginx</name> </application> </applications> <valuemap/> <logtimefmt/> <preprocessing/> <jmx_endpoint/> <master_item/> </item> <item> <name>nginx writing</name> <type>7</type> <snmp_community/> <snmp_oid/> <key>nginx.status[writing]</key> <delay>30s</delay> <history>90d</history> <trends>365d</trends> <status>0</status> <value_type>3</value_type> <allowed_hosts/> <units/> <snmpv3_contextname/> <snmpv3_securityname/> <snmpv3_securitylevel>0</snmpv3_securitylevel> <snmpv3_authprotocol>0</snmpv3_authprotocol> <snmpv3_authpassphrase/> <snmpv3_privprotocol>0</snmpv3_privprotocol> <snmpv3_privpassphrase/> <params/> <ipmi_sensor/> <authtype>0</authtype> <username/> <password/> <publickey/> <privatekey/> <port/> <description>正在发送相应报文的连接数</description> <inventory_link>0</inventory_link> <applications> <application> <name>Nginx</name> </application> </applications> <valuemap/> <logtimefmt/> <preprocessing/> <jmx_endpoint/> <master_item/> </item> <item> <name>nginx version</name> <type>7</type> <snmp_community/> <snmp_oid/> <key>nginx.version</key> <delay>30s</delay> <history>90d</history> <trends>0</trends> <status>0</status> <value_type>4</value_type> <allowed_hosts/> <units/> <snmpv3_contextname/> <snmpv3_securityname/> <snmpv3_securitylevel>0</snmpv3_securitylevel> <snmpv3_authprotocol>0</snmpv3_authprotocol> <snmpv3_authpassphrase/> <snmpv3_privprotocol>0</snmpv3_privprotocol> <snmpv3_privpassphrase/> <params/> <ipmi_sensor/> <authtype>0</authtype> <username/> <password/> <publickey/> <privatekey/> <port/> <description/> <inventory_link>0</inventory_link> <applications> <application> <name>Nginx</name> </application> </applications> <valuemap/> <logtimefmt/> <preprocessing/> <jmx_endpoint/> <master_item/> </item> </items> <discovery_rules/> <httptests/> <macros/> <templates/> <screens/> </template> </templates> <triggers> <trigger> <expression>{Template nginx status:nginx.status[ping].last()}=0</expression> <recovery_mode>1</recovery_mode> <recovery_expression>{Template nginx status:nginx.status[ping].last()}=1</recovery_expression> <name>nginx run state</name> <correlation_mode>0</correlation_mode> <correlation_tag/> <url/> <status>0</status> <priority>4</priority> <description/> <type>0</type> <manual_close>0</manual_close> <dependencies/> <tags/> </trigger> </triggers> <graphs> <graph> <name>nginx current status</name> <width>900</width> <height>200</height> <yaxismin>0.0000</yaxismin> <yaxismax>100.0000</yaxismax> <show_work_period>1</show_work_period> <show_triggers>1</show_triggers> <type>0</type> <show_legend>1</show_legend> <show_3d>0</show_3d> <percent_left>0.0000</percent_left> <percent_right>0.0000</percent_right> <ymin_type_1>0</ymin_type_1> <ymax_type_1>0</ymax_type_1> <ymin_item_1>0</ymin_item_1> <ymax_item_1>0</ymax_item_1> <graph_items> <graph_item> <sortorder>0</sortorder> <drawtype>0</drawtype> <color>1A7C11</color> <yaxisside>0</yaxisside> <calc_fnc>2</calc_fnc> <type>0</type> <item> <host>Template nginx status</host> <key>nginx.status[active]</key> </item> </graph_item> <graph_item> <sortorder>1</sortorder> <drawtype>0</drawtype> <color>F63100</color> <yaxisside>0</yaxisside> <calc_fnc>2</calc_fnc> <type>0</type> <item> <host>Template nginx status</host> <key>nginx.status[reading]</key> </item> </graph_item> <graph_item> <sortorder>2</sortorder> <drawtype>0</drawtype> <color>2774A4</color> <yaxisside>0</yaxisside> <calc_fnc>2</calc_fnc> <type>0</type> <item> <host>Template nginx status</host> <key>nginx.status[waiting]</key> </item> </graph_item> <graph_item> <sortorder>3</sortorder> <drawtype>0</drawtype> <color>A54F10</color> <yaxisside>0</yaxisside> <calc_fnc>2</calc_fnc> <type>0</type> <item> <host>Template nginx status</host> <key>nginx.status[writing]</key> </item> </graph_item> </graph_items> </graph> </graphs> <value_maps> <value_map> <name>Zabbix agent ping status</name> <mappings> <mapping> <value>1</value> <newvalue>Up</newvalue> </mapping> </mappings> </value_map> </value_maps> </zabbix_export>

模板文件直接复制以xml文件格式保存后,直接导入zabbix后台即可。

5.2、php-fpm文件
<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
    <version>3.4</version>
    <date>2021-05-13T11:33:42Z</date>
    <groups>
        <group>
            <name>Linux servers</name>
        </group>
    </groups>
    <templates>
        <template>
            <template>Template php-fpm status</template>
            <name>Template php-fpm status</name>
            <description/>
            <groups>
                <group>
                    <name>Linux servers</name>
                </group>
            </groups>
            <applications>
                <application>
                    <name>php-fpm</name>
                </application>
            </applications>
            <items>
                <item>
                    <name>php-fpm active_processes</name>
                    <type>7</type>
                    <snmp_community/>
                    <snmp_oid/>
                    <key>php-fpm.status[active_processes]</key>
                    <delay>30s</delay>
                    <history>90d</history>
                    <trends>365d</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts/>
                    <units/>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <params/>
                    <ipmi_sensor/>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description>处于活跃状态的连接数</description>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>php-fpm</name>
                        </application>
                    </applications>
                    <valuemap/>
                    <logtimefmt/>
                    <preprocessing/>
                    <jmx_endpoint/>
                    <master_item/>
                </item>
                <item>
                    <name>php-fpm conn</name>
                    <type>7</type>
                    <snmp_community/>
                    <snmp_oid/>
                    <key>php-fpm.status[conn]</key>
                    <delay>30s</delay>
                    <history>90d</history>
                    <trends>365d</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts/>
                    <units>k</units>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <params/>
                    <ipmi_sensor/>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description>pool接收到的请求数</description>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>php-fpm</name>
                        </application>
                    </applications>
                    <valuemap/>
                    <logtimefmt/>
                    <preprocessing/>
                    <jmx_endpoint/>
                    <master_item/>
                </item>
                <item>
                    <name>php-fpm idle_processes</name>
                    <type>7</type>
                    <snmp_community/>
                    <snmp_oid/>
                    <key>php-fpm.status[idle_processes]</key>
                    <delay>30s</delay>
                    <history>90d</history>
                    <trends>365d</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts/>
                    <units/>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <params/>
                    <ipmi_sensor/>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description>处于空闲状态的连接数</description>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>php-fpm</name>
                        </application>
                    </applications>
                    <valuemap/>
                    <logtimefmt/>
                    <preprocessing/>
                    <jmx_endpoint/>
                    <master_item/>
                </item>
                <item>
                    <name>php-fpm listen_queue</name>
                    <type>7</type>
                    <snmp_community/>
                    <snmp_oid/>
                    <key>php-fpm.status[listen_queue]</key>
                    <delay>30s</delay>
                    <history>90d</history>
                    <trends>365d</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts/>
                    <units/>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <params/>
                    <ipmi_sensor/>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description>处于等待状态的连接数</description>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>php-fpm</name>
                        </application>
                    </applications>
                    <valuemap/>
                    <logtimefmt/>
                    <preprocessing/>
                    <jmx_endpoint/>
                    <master_item/>
                </item>
                <item>
                    <name>php-fpm max_active_processes</name>
                    <type>7</type>
                    <snmp_community/>
                    <snmp_oid/>
                    <key>php-fpm.status[max_active_processes]</key>
                    <delay>30s</delay>
                    <history>90d</history>
                    <trends>365d</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts/>
                    <units/>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <params/>
                    <ipmi_sensor/>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description>启动至今最多有几个进程处于活跃状态</description>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>php-fpm</name>
                        </application>
                    </applications>
                    <valuemap/>
                    <logtimefmt/>
                    <preprocessing/>
                    <jmx_endpoint/>
                    <master_item/>
                </item>
                <item>
                    <name>php-fpm max_children_reached</name>
                    <type>7</type>
                    <snmp_community/>
                    <snmp_oid/>
                    <key>php-fpm.status[max_children_reached]</key>
                    <delay>30s</delay>
                    <history>90d</history>
                    <trends>365d</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts/>
                    <units/>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <params/>
                    <ipmi_sensor/>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description>当pm试图启动更多的子进程时,却达到了进程数的限制。时记录一次</description>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>php-fpm</name>
                        </application>
                    </applications>
                    <valuemap/>
                    <logtimefmt/>
                    <preprocessing/>
                    <jmx_endpoint/>
                    <master_item/>
                </item>
                <item>
                    <name>php-fpm max_listen_queue</name>
                    <type>7</type>
                    <snmp_community/>
                    <snmp_oid/>
                    <key>php-fpm.status[max_listen_queue]</key>
                    <delay>30s</delay>
                    <history>90d</history>
                    <trends>365d</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts/>
                    <units/>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <params/>
                    <ipmi_sensor/>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description>启动至今等待状态的连接数</description>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>php-fpm</name>
                        </application>
                    </applications>
                    <valuemap/>
                    <logtimefmt/>
                    <preprocessing/>
                    <jmx_endpoint/>
                    <master_item/>
                </item>
                <item>
                    <name>php-fpm status</name>
                    <type>7</type>
                    <snmp_community/>
                    <snmp_oid/>
                    <key>php-fpm.status[ping]</key>
                    <delay>30s</delay>
                    <history>90d</history>
                    <trends>365d</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts/>
                    <units/>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <params/>
                    <ipmi_sensor/>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>php-fpm</name>
                        </application>
                    </applications>
                    <valuemap>
                        <name>Zabbix agent ping status</name>
                    </valuemap>
                    <logtimefmt/>
                    <preprocessing/>
                    <jmx_endpoint/>
                    <master_item/>
                </item>
                <item>
                    <name>php-fpm slow_requests</name>
                    <type>7</type>
                    <snmp_community/>
                    <snmp_oid/>
                    <key>php-fpm.status[slow_requests]</key>
                    <delay>30s</delay>
                    <history>90d</history>
                    <trends>365d</trends>
                    <status>1</status>
                    <value_type>3</value_type>
                    <allowed_hosts/>
                    <units/>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <params/>
                    <ipmi_sensor/>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description>处于慢状态查询的总数</description>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>php-fpm</name>
                        </application>
                    </applications>
                    <valuemap/>
                    <logtimefmt/>
                    <preprocessing/>
                    <jmx_endpoint/>
                    <master_item/>
                </item>
                <item>
                    <name>php-fpm total_processes</name>
                    <type>7</type>
                    <snmp_community/>
                    <snmp_oid/>
                    <key>php-fpm.status[total_processes]</key>
                    <delay>30s</delay>
                    <history>90d</history>
                    <trends>365d</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts/>
                    <units/>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <params/>
                    <ipmi_sensor/>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description>进程总数</description>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>php-fpm</name>
                        </application>
                    </applications>
                    <valuemap/>
                    <logtimefmt/>
                    <preprocessing/>
                    <jmx_endpoint/>
                    <master_item/>
                </item>
                <item>
                    <name>php-fpm version</name>
                    <type>7</type>
                    <snmp_community/>
                    <snmp_oid/>
                    <key>php-fpm.version</key>
                    <delay>30s</delay>
                    <history>90d</history>
                    <trends>0</trends>
                    <status>0</status>
                    <value_type>4</value_type>
                    <allowed_hosts/>
                    <units/>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <params/>
                    <ipmi_sensor/>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description>php  版本号</description>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>php-fpm</name>
                        </application>
                    </applications>
                    <valuemap/>
                    <logtimefmt/>
                    <preprocessing/>
                    <jmx_endpoint/>
                    <master_item/>
                </item>
            </items>
            <discovery_rules/>
            <httptests/>
            <macros/>
            <templates/>
            <screens/>
        </template>
    </templates>
    <triggers>
        <trigger>
            <expression>{Template php-fpm status:php-fpm.status[ping].last()}=0</expression>
            <recovery_mode>1</recovery_mode>
            <recovery_expression>{Template php-fpm status:php-fpm.status[ping].last()}=1</recovery_expression>
            <name>php-fpm status</name>
            <correlation_mode>0</correlation_mode>
            <correlation_tag/>
            <url/>
            <status>0</status>
            <priority>4</priority>
            <description/>
            <type>0</type>
            <manual_close>0</manual_close>
            <dependencies/>
            <tags/>
        </trigger>
    </triggers>
    <graphs>
        <graph>
            <name>php-fpm status</name>
            <width>900</width>
            <height>200</height>
            <yaxismin>0.0000</yaxismin>
            <yaxismax>100.0000</yaxismax>
            <show_work_period>1</show_work_period>
            <show_triggers>1</show_triggers>
            <type>0</type>
            <show_legend>1</show_legend>
            <show_3d>0</show_3d>
            <percent_left>0.0000</percent_left>
            <percent_right>0.0000</percent_right>
            <ymin_type_1>0</ymin_type_1>
            <ymax_type_1>0</ymax_type_1>
            <ymin_item_1>0</ymin_item_1>
            <ymax_item_1>0</ymax_item_1>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <drawtype>0</drawtype>
                    <color>1A7C11</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template php-fpm status</host>
                        <key>php-fpm.status[max_active_processes]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>1</sortorder>
                    <drawtype>0</drawtype>
                    <color>F63100</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template php-fpm status</host>
                        <key>php-fpm.status[max_children_reached]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>2</sortorder>
                    <drawtype>0</drawtype>
                    <color>2774A4</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template php-fpm status</host>
                        <key>php-fpm.status[max_listen_queue]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>3</sortorder>
                    <drawtype>0</drawtype>
                    <color>A54F10</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template php-fpm status</host>
                        <key>php-fpm.status[active_processes]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>4</sortorder>
                    <drawtype>0</drawtype>
                    <color>6C59DC</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template php-fpm status</host>
                        <key>php-fpm.status[idle_processes]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>5</sortorder>
                    <drawtype>0</drawtype>
                    <color>AC8C14</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template php-fpm status</host>
                        <key>php-fpm.status[listen_queue]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>6</sortorder>
                    <drawtype>0</drawtype>
                    <color>611F27</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template php-fpm status</host>
                        <key>php-fpm.status[max_active_processes]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>7</sortorder>
                    <drawtype>0</drawtype>
                    <color>F230E0</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template php-fpm status</host>
                        <key>php-fpm.status[max_children_reached]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>8</sortorder>
                    <drawtype>0</drawtype>
                    <color>5CCD18</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template php-fpm status</host>
                        <key>php-fpm.status[max_listen_queue]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>9</sortorder>
                    <drawtype>0</drawtype>
                    <color>89ABF8</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template php-fpm status</host>
                        <key>php-fpm.status[total_processes]</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
    </graphs>
    <value_maps>
        <value_map>
            <name>Zabbix agent ping status</name>
            <mappings>
                <mapping>
                    <value>1</value>
                    <newvalue>Up</newvalue>
                </mapping>
            </mappings>
        </value_map>
    </value_maps>
</zabbix_export>

全文到此结束,下篇我们开始【zabbix定制监控之MySQL】。有不清楚请留言,拜了个拜。


https://www.xamrdz.com/backend/3xb1995587.html

相关文章: