zoukankan      html  css  js  c++  java
  • zabbix监控php-fpm的性能

    zabbix监控php-fpm主要是通过nginx配置php-fpm的状态输出页面,在正则取值

    要nginx能输出php-fpm的状态必须要先修改php-fpm的配置,这个配置没有开启nginx 就没有办法输出php-fpm status

    修改/usr/local/php/etc/php-fpm.conf 文件

    注意:不是php.ini,如果没有配置添加配置

    pm.status_path = /status
    重启php-fpm
    service php-fpm restart
    添加nginx的配置
    打开/usr/local/nginx/conf/nginx.conf

    location ~ .php|^/status$ {
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_connect_timeout 180;
    fastcgi_read_timeout 600;
    fastcgi_send_timeout 600;
    include fastcgi.conf;
    }

    配置好之后重启一下nginx
    service nginx restart

    添加监控的shlle脚本
    php-fpm_status.sh
    添加zabbix-agent配置
    php-fpm_status.conf
    重启zabbix-agent
    service zabbix-agent restart
    测试
    zabbix_get -s 127.0.0.1 -k slow.requests
    如果没有问题导入模板
    php-fpm_status.xml
    现在就能看到数据了

    脚本和模板如下:

    vim php-fpm_status.sh
    #!/bin/bash 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

     

    vim php-fpm_status.conf
    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

      

  • 相关阅读:
    浅析JNI
    网易云音乐歌词下载器
    如何用一个SQL“搞挂”一个服务模块
    SpingBoot 1.5.2,MultipartFile保存图片时的不稳定异常(好像和内置tomcat有关)
    double 去除小数点后的0
    项目中时间处理----今天:时分(10:15),昨天/前天:(昨天/前天),除此之外的本周(星期几),再往前年.月.日(2017.06.15)
    SpringMvc 静态内部类 封装请求数据
    jsp页面 ajax提交数组 到struts2的action
    Struts2 s:if test判断时遇到的问题
    Struts2中 iterator隔行变色
  • 原文地址:https://www.cnblogs.com/pythonal/p/7744437.html
Copyright © 2011-2022 走看看