码迷,mamicode.com
首页 > Web开发 > 详细

zabbix监控php状态

时间:2019-10-10 00:21:05      阅读:140      评论:0      收藏:0      [点我收藏+]

标签:资源池   status   span   file   word   ESS   状态   agentd   nignx   

环境介绍:

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

 

zabbix监控php状态

标签:资源池   status   span   file   word   ESS   状态   agentd   nignx   

原文地址:https://www.cnblogs.com/betterquan/p/11644886.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!