当前位置: 首页 > news >正文

zabbix监控php,zabbix监控php状态

zabbix监控php状态

通过nginx调用php-fpm来查询php的状态信息

首先,在php的配置文件中添加一行

vim /usr/local/php/etc/php-fpm.conf

pm.status_path = /phpfpmstatus

保存后重启php-fpm

在nginx配置文件中添加代码

server

{

listen localhost:80;

server_name localhost;

location /nginxstatus {

stub_status on;

access_log off;

allow 127.0.0.1;

allow 10.6.0.187;

deny all;

}

location ~ ^/(phpfpmstatus)$ {

include fastcgi_params;

fastcgi_pass unix:/tmp/php-fcgi.sock;

fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;

}

}

保存后重启nginx

然后,在zabbix的脚本目录里面编辑执行脚本

#!/bin/bash

#monitor php-fpm status from zabbix

#lincense:GPL

#mail:admin@huxianglin.cn

#date:2015.04.15

source /etc/bashrc >/dev/null 2>&1

source /etc/profile >/dev/null 2>&1

LOG=/usr/local/zabbix-2.4.4/scripts/phpfpmstatus.log

curl -s http://localhost/phpfpmstatus >$LOG

pool(){

awk '/pool/ {print $NF}' $LOG

}

process_manager(){

awk '/process manager/ {print $NF}' $LOG

}

start_since(){

awk '/start since:/ {print $NF}' $LOG

}

accepted_conn(){

awk '/accepted conn:/ {print $NF}' $LOG

}

listen_queue(){

awk '/^(listen queue:)/ {print $NF}' $LOG

}

max_listen_queue(){

awk '/max listen queue:/ {print $NF}' $LOG

}

listen_queue_len(){

awk '/listen queue len:/ {print $NF}' $LOG

}

idle_processes(){

awk '/idle processes:/ {print $NF}' $LOG

}

active_processes(){

awk '/^(active processes:)/ {print $NF}' $LOG

}

total_processes(){

awk '/total processes:/ {print $NF}' $LOG

}

max_active_processes(){

awk '/max active processes:/ {print $NF}' $LOG

}

max_children_reached(){

awk '/max children reached:/ {print $NF}' $LOG

}

case "$1" in

pool)

pool

;;

process_manager)

process_manager

;;

start_since)

start_since

;;

accepted_conn)

accepted_conn

;;

listen_queue)

listen_queue

;;

max_listen_queue)

max_listen_queue

;;

listen_queue_len)

listen_queue_len

;;

idle_processes)

idle_processes

;;

active_processes)

active_processes

;;

total_processes)

total_processes

;;

max_active_processes)

max_active_processes

;;

max_children_reached)

max_children_reached

;;

*)

echo "Usage: $0 {pool|process_manager|start_since|accepted_conn|listen_queue|max_listen_queue|listen_queue_len|idle_processes|active_processes|total_processes|max_active_processes|max_children_reached}"

esac

保存后退出,修改权限为

-rwxr-xr-x 1 zabbix zabbix 1770 4月  15 14:50 phpstatus.sh

然后编辑zabbix_agentd.conf文件,在最后添加上下面这段代码,并重启zabbix_agentd服务

#to monitor php-fpmstatus

UserParameter=phpfpm.status.pool,/usr/local/zabbix-2.4.4/scripts/phpstatus.sh pool

UserParameter=phpfpm.status.process.manager,/usr/local/zabbix-2.4.4/scripts/phpstatus.sh process_manager

UserParameter=phpfpm.status.start.since,/usr/local/zabbix-2.4.4/scripts/phpstatus.sh start_since

UserParameter=phpfpm.status.accepted.conn,/usr/local/zabbix-2.4.4/scripts/phpstatus.sh accepted_conn

UserParameter=phpfpm.status.listen.queue,/usr/local/zabbix-2.4.4/scripts/phpstatus.sh listen_queue

UserParameter=phpfpm.status.max.listen.queue,/usr/local/zabbix-2.4.4/scripts/phpstatus.sh max_listen_queue

UserParameter=phpfpm.status.listen.queue.len,/usr/local/zabbix-2.4.4/scripts/phpstatus.sh listen_queue_len

UserParameter=phpfpm.status.idle.processes,/usr/local/zabbix-2.4.4/scripts/phpstatus.sh idle_processes

UserParameter=phpfpm.status.active.processes,/usr/local/zabbix-2.4.4/scripts/phpstatus.sh active_processes

UserParameter=phpfpm.status.total.processes,/usr/local/zabbix-2.4.4/scripts/phpstatus.sh total_processes

UserParameter=phpfpm.status.max.active.processes,/usr/local/zabbix-2.4.4/scripts/phpstatus.sh max_active_processes

UserParameter=phpfpm.status.max.children.reached,/usr/local/zabbix-2.4.4/scripts/phpstatus.sh max_children_reached

然后就可以在web端配置item监控php状态了

1a7c9b4424a87e4c3c8dce840d557e36.png

相关文章:

  • php语言的form,PHP语言 HTTP请求类,支持GET,POST,Multipart、form-data
  • JAVA定义一个狗看门,为什么我用接口实现狗看门的功能出错?
  • 查看php-fpm配置文件,php-fpm 配置文件检测
  • 用php查ip,php – 有效的ip-位置查询
  • php 怎么取出一个最大值,php max() min() 返回最大值和最小值
  • 公示系统php,企业信用查询公示系统
  • oracle判断单数双数,代码中你所不知道的偶数与奇数的判断方法
  • c 访问oracle视图,Oracle视图
  • Oracle+12c+国家字符集,Oracle 12C CDB字符集修改
  • 确认32位oracle client,32位oracle client
  • 2012安装oracle客户端安装,Windows 2012群集标准版安装Oracle11G
  • linux提示有交换文件,Linux下如何设置交换文件?Linux下设置交换文件的方法
  • linux smartctl 命令,使用smartctl命令检查磁盘
  • printf linux 头文件,Linux C 格式化输出时要注意的问题
  • linux取消挂载并将分区释放,linux硬盘分区:分区,格式化,挂载,取消挂载,删除分区...