博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
zabbix监控nginx、php-fpm的状态
阅读量:4107 次
发布时间:2019-05-25

本文共 3303 字,大约阅读时间需要 11 分钟。

转自http://blog.csdn.net/kerncai/article/details/15812785

添加脚本之前,需要将所监控php-fpm需要在nginx内配置php-fpm的状态并转发出来,nginx内配置如下配置完成后,可以打开浏览器查看下状态,是否可以正常访问

配置完成后,将脚本放在所需要监控的机器上面,模板导入到web即可

nginx配置如下:

server {

listen 40080;    server_name _;    allow 127.0.0.1;    deny all;    access_log off;    location /php-fpm_status {    fastcgi_pass unix:/tmp/php-fpm.sock;    include fastcgi_params;    fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;    }

location /nginx_status { #这里配置的是nginx的状态,和php-fpm的监控一样

stub_status on;   }

}

脚本:

#########################################################################  
# File Name: php-fpm_status.sh
# Author: kerncai
# mail: kernkerncai@gmail.com
# Created Time: 2013年11月13日 星期三 14时02分35秒
#########################################################################
#!/bin/bash
idle
(){
        wget --quiet -O - http://127.0.0.1:40080/php-fpm_status?auto |grep
"idle processes" |awk
'{print$3}'
}
total
(){
        wget --quiet -O - http://127.0.0.1:40080/php-fpm_status?auto |grep
"total processes" |awk
'{print$3}'
}
active
(){
        wget --quiet -O - http://127.0.0.1:40080/php-fpm_status?auto |grep
"active" |awk
'{print$3}'|grep -v
"process"
}
mactive
(){
        wget --quiet -O - http://127.0.0.1:40080/php-fpm_status?auto |grep
"max active processes:" |awk
'{print$4}'
}
listenqueuelen
(){
        wget --quiet -O - http://127.0.0.1:40080/php-fpm_status?auto |grep
"listen queue len" |awk
'{print$4}'
}
listenqueue
(){
        wget --quiet -O - http://127.0.0.1:40080/php-fpm_status?auto |grep
"listen queue:"|grep -vE
"len|max"|awk
'{print$3}'
}
since
(){
        wget --quiet -O - http://127.0.0.1:40080/php-fpm_status?auto |grep
"start since: " |awk
'{print$3}'
}
conn
(){
        wget --quiet -O - http://127.0.0.1:40080/php-fpm_status?auto |grep
"accepted conn" |awk
'{print$3}'
}
$1

zabbix.agentd.conf的配置文件如下 :

UnsafeUserParameters=1(自定义脚本必开)

UserParameter=idle.processe,/usr/local/zabbix-agent-ops/bin/php-fpm_status.sh idle

UserParameter=total.processes,/usr/local/zabbix-agent-ops/bin/php-fpm_status.sh total
UserParameter=active.processes,/usr/local/zabbix-agent-ops/bin/php-fpm_status.sh active
UserParameter=max.active.processes,/usr/local/zabbix-agent-ops/bin/php-fpm_status.sh mactive
UserParameter=listen.queue.len,/usr/local/zabbix-agent-ops/bin/php-fpm_status.sh listenqueuelen
UserParameter=listen.queue,/usr/local/zabbix-agent-ops/bin/php-fpm_status.sh listenqueue
UserParameter=start.since,/usr/local/zabbix-agent-ops/bin/php-fpm_status.sh since
UserParameter=accepted.conn,/usr/local/zabbix-agent-ops/bin/php-fpm_status.sh conn

模板的话根据配置文件创建,本来向贴个github的链接的,不过貌似csdn不给贴链接 ~~~

  github 上面有模板和脚本~

个人博客:

你可能感兴趣的文章
Mysql-高可用
查看>>
influxdb-配置文件说明
查看>>
Mysql-账户管理
查看>>
linux top详解
查看>>
01.InfluxDB系统化学习-配置文件
查看>>
02.InfluxDB系统化学习-InfluxDB初始化
查看>>
03.InfluxDB系统化学习-MetaStore
查看>>
04.InfluxDB系统化学习-TSDBStore
查看>>
我心中最伟大的程序员
查看>>
盖茨接班人Ray Ozzie: 盖茨称他为宇宙中最顶尖的5位程序员之一
查看>>
让人目瞪口呆的三位世界级电脑大师
查看>>
程序之父: BT之父的辛酸奋斗血泪史
查看>>
程序之父: Delphi和.NET之父:Anders Hejlsberg
查看>>
程序之父: Java语言之父James Gosling
查看>>
程序之父: Pascal之父:尼克劳斯·沃思(一)
查看>>
程序之父: Pascal之父:尼克劳斯·沃思(二)
查看>>
纪念关系数据库之父:Edgar F. Codd
查看>>
程序员和黑客的区别
查看>>
四个程序员的一天
查看>>
IT厕所的遭遇(爆笑)
查看>>