zabbix监控php状态

环境介绍:php

php /usr/loca/phpnginx

nignx /usr/loca/nginx  配置文件都是放在extra中git

修改php-fpm的配置文件启动状态页面github

 

 

 

 pm.status_path = /statusweb

 

配置nginx虚拟主机的配置sql

 

 

server {
        listen       80;
        server_name  localhost;

        location ~ ^/(status)$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_param  SCRIPT_FILENAME $fastcgi_script_name;
            include        fastcgi_params;
        }
}

 

重启nginx服务shell

[root@localhost ~]# curl http://127.0.0.1/statusvim

pool:                 www
process manager:      dynamic
start time: 26/Jun/2018:18:21:48 +0800 start since: 209 accepted conn: 33 listen queue: 0 max listen queue: 0 listen queue len: 128 idle processes: 1 active processes: 1 total processes: 2 max active processes: 1 max children reached: 0 slow requests: 0

 

php-fpm status的含义

pool                    php-fpm pool(资源池)的名称,大多数状况下为www

process manager        进程管理方式,现今大多都为dynamic,不要使用static

start time                上次启动的时间

start since            已运行了多少秒

accepted conn    pool        接收到的请求数

listen queue            处于等待状态中的链接数,若是不为0,须要增长php-fpm进程数

max listen queue        从php-fpm启动到如今处于等待链接的最大数量

listen queue len        处于等待链接队列的套接字大小

idle processes            处于空闲状态的进程数

active processes        处于活动状态的进程数

total processess        进程总数

max active process        从php-fpm启动到如今最多有几个进程处于活动状态

max children reached    当php-fpm试图启动更多的children进程时,却达到了进程数的限制,达到一次记录一次,若是不为0,须要增长php-fpm pool进程的最大数

 

建立php_ststus的脚本文件bash

[root@web01 zabbix_agentd.d]# vim php_status.shcurl

listenqueue(){
        wget --quiet -O - http://127.0.0.1:80/status?auto |grep "listen queue:"|grep -vE "len|max"|awk '{print$3}'
}
 
listenqueuelen(){
        wget --quiet -O - http://127.0.0.1:80/status?auto |grep "listen queue len" |awk '{print$4}'
}
 
idle(){
        wget --quiet -O - http://127.0.0.1:80/status?auto |grep "idle processes" |awk '{print$3}'
}
active(){
        wget --quiet -O - http://127.0.0.1:80/status?auto |grep "active" |awk '{print$3}'|grep -v "process"
}
total(){
        wget --quiet -O - http://127.0.0.1:80/status?auto |grep "total processes" |awk '{print$3}'
}
 
mactive(){
 
        wget --quiet -O - http://127.0.0.1:80/status?auto |grep "max active processes:" |awk '{print$4}'
}
 
since(){
        wget --quiet -O - http://127.0.0.1:80/status?auto |grep "start since: " |awk '{print$3}'
}
 
conn(){
        wget --quiet -O - http://127.0.0.1:80/status?auto |grep "accepted conn" |awk '{print$3}'
}
 
reached(){
        wget --quiet -O - http://127.0.0.1:80/status?auto |grep "max children reached" |awk '{print$4}'
}
requests(){
        wget --quiet -O - http://127.0.0.1:80/status?auto |grep "slow requests" |awk '{print$3}'
}
$1

 

编辑自配置文件

UserParameter=idle.processe,/scripts/php-fpm_status.sh idle

UserParameter=total.processes, /scripts/php-fpm_status .sh total
UserParameter=active.processes, /scripts/php-fpm_status .sh active
UserParameter=max.active.processes, /scripts/php-fpm_status .sh mactive
UserParameter=listen.queue.len, /scripts/php-fpm_status .sh listenqueuelen
UserParameter=listen.queue, /scripts/php-fpm_status .sh listenqueue
UserParameter=start.since, /scripts/php-fpm_status .sh since
UserParameter=accepted.conn, /scripts/php-fpm_status .sh conn
UserParameter=max.children.reached, /scripts/php-fpm_status .sh reached
UserParameter=slow.requests, /scripts/php-fpm_status .sh requests
相关文章
相关标签/搜索