zabbix监控php状态

环境介绍:

php /usr/loca/php

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

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

 

 

 

 pm.status_path = /status

 

配置nginx虚拟主机的配置

 

 

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服务

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

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的脚本文件

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

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

 

posted @ 2019-10-09 22:35  linux——quan  阅读(438)  评论(0编辑  收藏  举报