zabbix php进程,zabbix 监控phpfpm_status

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,缓慢请求的数量

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界面添加对应的监控模块

672f7917213da2df92c18df94c350b6a.png

bb2dcf94fccc37b62b0e89e8e6fd055c.png

d8a5f2ee71a45c9948f8659b99832b70.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值