温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

zabbix 监控phpfpm_status

发布时间:2020-04-01 23:05:57 来源:网络 阅读:591 作者:lvnian2009 栏目:web开发


zabbix 监控phpfpm_status


1. 启用php-fpm状态功能

# cat  /usr/local/php-5.5.10/etc/php-fpm.conf | grep status_path
pm.status_path = /status
###打开上面的内容即可

默认情况下为/status,当然也可以改成其他的,例如/php_status等等

2. nginx配置

在默认主机里面加上location或者你希望能访问到的主机里面

server {
    listen  *:80 default_server;
    server_name _;
    location ~ ^/(status|ping)$
    {
        include fastcgi_params;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
    }
}


3. 重启nginx/php-fpm
请依照你的环境重启你的nginx和php-fpm

4. 测试打开status页面

# curl http://127.0.0.1/status
pool:                 www
process manager:      dynamic
start time:           08/Sep/2016:16:15:12 +0800
start since:          4313
accepted conn:        1783
listen queue:         0
max listen queue:     0
listen queue len:     128
idle processes:       29
active processes:     1
total processes:      30
max active processes: 3
max children reached: 0
slow requests:        0


5. php-fpm status详解

pool – fpm池子名称,大多数为www
process manager – 进程管理方式,值:static, dynamic or ondemand. dynamic
start time – 启动日期,如果reload了php-fpm,时间会更新
start since – 运行时长
accepted conn – 当前池子接受的请求数
listen queue – 请求等待队列,如果这个值不为0,那么要增加FPM的进程数量
max listen queue – 请求等待队列最高的数量
listen queue len – socket等待队列长度
idle processes – 空闲进程数量
active processes – 活跃进程数量
total processes – 总进程数量
max active processes – 最大的活跃进程数量(FPM启动开始算)
max children reached - 大道进程最大数量限制的次数,如果这个数量不为0,那说明你的最大进程数量太小了,请改大一点。
slow requests – 启用了php-fpm slow-log,缓慢请求的数量


php-fpm的监控相关信息可以参考:http://www.ttlsa.com/php/use-php-fpm-status-page-detail/


6. 编写脚本监控php-fpm

[root@iZ23qinwbndZ etc]# cat script/zabbix_linux_php.sh 
#!/bin/bash
############################################################
# $Name:         zabbix_linux_php.sh
# $Version:      v1.0
# $Function:     zabbix plugins
# $Author:       GAOGD
# $organization: http://lvnian.blog.51cto.com/
# $Create Date:  20160908
# $Description:  Monitor Linux Service Status
############################################################
php_status_fun(){
      case $1 in
        accepted_conn)
            /usr/bin/curl -s "http://127.0.0.1"/status  |grep '^accepted conn' |awk '{print $NF}'
            ;;
        listen_queue)
            /usr/bin/curl -s "http://127.0.0.1"/status  |grep '^listen queue:' |awk '{print $NF}'
            ;;
        listen_queue_len)
            /usr/bin/curl -s "http://127.0.0.1"/status  |grep '^listen queue len' |awk '{print $NF}'
            ;;
        idle_processes)
            /usr/bin/curl -s "http://127.0.0.1"/status  |grep '^idle processes' |awk '{print $NF}'
            ;;
        active_processe)
            /usr/bin/curl -s "http://127.0.0.1"/status  |grep '^active processes' |awk '{print $NF}'
            ;;
        total_processes)
            /usr/bin/curl -s "http://127.0.0.1"/status  |grep '^total processes' |awk '{print $NF}'
        ;;
        slow_requests)
            /usr/bin/curl -s "http://127.0.0.1"/status  |grep '^slow requests' |awk '{print $NF}'
        ;;
        esac 
}

php_status_fun $1
[root@iZ23qinwbndZ etc]#


7.把脚本应用到zabbix客户端

[root@iZ23qinwbndZ etc]# tail -4 zabbix_agentd.conf
UserParameter=nginx_status[*],/etc/zabbix/etc/script/zabbix_linux_plugin.sh nginx_status  $1
UserParameter=php_status[*],/etc/zabbix/etc/script/zabbix_linux_php.sh  $1
UserParameter=CheckMem,free -m |awk '/Mem/{print $4}'
[root@iZ23qinwbndZ etc]#


8.重启zabbix客户端



9.zabbix web界面添加对应的监控模块



zabbix 监控phpfpm_status

zabbix 监控phpfpm_status

zabbix 监控phpfpm_status










向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI