• zabbixp-监控 php-fpm


    1.php-fpm工作模式常用与nginx结合使用

    //修改php-fpm.conf

    [root@web01 ~]# vim /etc/php-fpm.d/www.conf

    pm.status_path = /phpfpm_status 将前面的注释删除“;”

    [root@web01 ~]# systemctl restart php-fpm.service

    2.在nginx.conf的配置文件中添加php-fpm的状态信息

    [root@web01 ~]# cat /etc/nginx/conf.d/status.conf
    server {
    listen 80;
    server_name _;

    location /nginx_status {
    stub_status;
    access_log off;
    # allow 127.0.0.1;
    # deny all;
    }
    location ~ ^/(phpfpm_status)$ {
    include fastcgi_params;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include proxy_params;
    }

    }

    3.访问测试phpfpm_status

    [root@web01 ~]# curl http://127.0.0.1/phpfpm_status

    #PHP-FPM状态解释:
    pool #fpm池名称,大多数为www
    process manager #进程管理方式dynamic或者static
    start time #启动日志,如果reload了fpm,时间会更新
    start since #运行时间
    accepted conn #当前池接受的连接数
    listen queue #请求等待队列,如果这个值不为0,那么需要增加FPM的进程数量 (长时间大于0)
    max listen queue #请求等待队列最高的数量
    listen queue len #socket等待队列长度
    idle processes #空闲进程数量0 (空闲持续多长时间0则报警)
    active processes #活跃进程数量200
    total processes #总进程数量200
    max active processes #最大的活跃进程数量(FPM启动开始计算)
    max children reached #最大数量限制的次数,如果这个数量不为0,那说明你的最大进程数量过小,可以适当调整。
    slow requests # 超过5s在执行,这就算慢

    4.取值

    curl -s http://127.0.0.1/phpfpm_status|grep "$1"|awk '{print $NF}'

    2.定义监控项
    [root@web02 zabbix_agentd.d]# cat php.conf
    UserParameter=fpm[*],curl -s http://127.0.0.1/phpfpm_status|grep ^"$1":|awk '{print $NF}'

    3.zabbix-server获取对应的监控项
    [root@zabbix-server ~]# zabbix_get -s 172.16.1.7 -k fpm["accepted conn"]
    50077

    4.web界面添加模板,模板添加监控项,基于监控项创建触发器,触发则发送邮件报警。

  • 相关阅读:
    [转]手工实现RTTI
    小楫轻舟
    百年孤独
    The power of now
    [转帖]Android平台下OpenGL初步
    设计模式六大原则(5):迪米特法则
    设计模式六大原则(4):接口隔离原则
    设计模式六大原则(3):依赖倒置原则
    设计模式六大原则(1):单一职责原则
    设计模式六大原则(2):里氏替换原则
  • 原文地址:https://www.cnblogs.com/fangdecheng/p/9841879.html
Copyright © 2020-2023  润新知