zabbix4.0监控php-fpm

php-fpm模板
启用php-fpm的状态功能
vim /etc/php-fpm.d/www.conf
修改
pm.status_path = /status

pm.status_path = /phpfpm_status

nginx中开启php的状态访问
vim /etc/nginx/nginx.conf
进行七层负载的建议(前提 监控服务器和被监控端在同一内网)
server{
listen 81;
location /php_status {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME html$fastcgi_script_name;
include fastcgi_params;
}
}
重启
systemctl restart php-fpm.service nginx.service
访问
curl 127.0.0.1:81/php_status
pool: www
process manager: dynamic
start time: 08/Jul/2020:15:58:55 +0800
start since: 545
accepted conn: 2
listen queue: 0
max listen queue: 0
listen queue len: 128
idle processes: 4
active processes: 1
total processes: 5
max active processes: 1
max children reached: 0
slow requests: 0
php-fpm status的含义

pool #fpm池名称,大多数为www
process manager #进程管理方式dynamic或者static
start time #启动日志,如果reload了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,那说明你的最大进程数量过小,可以适当调整。

脚本获取php-fpm状态值,并给脚本添加可执行权限
vim /etc/zabbix/scripts/phpfpm_status.sh
#!/bin/bash
PHPFPM_COMMAND=KaTeX parse error: Expected '}', got 'EOF' at end of input: …p://localhost:"PHPFPM_PORT"/phpfpm_status" |awk '/^start since:/ {print KaTeX parse error: Expected 'EOF', got '}' at position 3: NF}̲' } accepted_co…PHPFPM_PORT"/phpfpm_status" |awk '/^accepted conn:/ {print KaTeX parse error: Expected 'EOF', got '}' at position 3: NF}̲' } listen_queu…PHPFPM_PORT"/phpfpm_status" |awk '/^listen queue:/ {print KaTeX parse error: Expected 'EOF', got '}' at position 3: NF}̲' } max_listen_…PHPFPM_PORT"/phpfpm_status" |awk '/^max listen queue:/ {print KaTeX parse error: Expected 'EOF', got '}' at position 3: NF}̲' } listen_queu…PHPFPM_PORT"/phpfpm_status" |awk '/^listen queue len:/ {print KaTeX parse error: Expected 'EOF', got '}' at position 3: NF}̲' } idle_proces…PHPFPM_PORT"/phpfpm_status" |awk '/^idle processes:/ {print KaTeX parse error: Expected 'EOF', got '}' at position 3: NF}̲' } active_proc…PHPFPM_PORT"/phpfpm_status" |awk '/^active processes:/ {print KaTeX parse error: Expected 'EOF', got '}' at position 3: NF}̲' } total_proce…PHPFPM_PORT"/phpfpm_status" |awk '/^total processes:/ {print KaTeX parse error: Expected 'EOF', got '}' at position 3: NF}̲' } max_active_…PHPFPM_PORT"/phpfpm_status" |awk '/^max active processes:/ {print KaTeX parse error: Expected 'EOF', got '}' at position 3: NF}̲' } max_childre…PHPFPM_PORT"/phpfpm_status" |awk '/^max children reached:/ {print KaTeX parse error: Expected 'EOF', got '}' at position 3: NF}̲' } slow_reques…PHPFPM_PORT"/phpfpm_status" |awk ‘/^slow requests:/ {print $NF}’
}

case $PHPFPM_COMMAND in
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;
;;
slow_requests)
slow_requests;
;;
*)
echo $“USAGE:$0 {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

chmod a+x /etc/zabbix/scripts/phpfpm_status.sh

自定义获取php-fpm的key
vim /etc/zabbix/zabbix_agentd.d/phpfpm_status.conf
UserParameter=phpfpm_status[*],/usr/bin/sh /etc/zabbix/scripts/phpfpm_status.sh “$1”
systemctl restart zabbix-agent.service

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值