11.php-fpm模板(监控页面取值)

php-fpm模板(监控页面取值)

开启监控页面配置

#修改php配置文件
vim /etc/php-fpm.d/www.conf 
pm.status_path = /php_status#修改nginx配置文件,添加到nginx配置文件中
vim /etc/nginx/conf.d/default.conflocation /php_status {root           html;fastcgi_pass   127.0.0.1:9000;fastcgi_index  index.php;fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;include        fastcgi_params;}#重启nginx和php服务
systemctl restart nginx php-fpm.service

web界面浏览器访问
在这里插入图片描述

导入模板fpm.xml

<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export><version>2.0</version><date>2015-10-12T08:46:18Z</date><groups><group><name>Templates</name></group></groups><templates><template><template>Template php-fpm</template><name>Template php-fpm</name><description/><groups><group><name>Templates</name></group></groups><applications><application><name>php-fpm</name></application></applications><items><item><name>$1</name><type>0</type><snmp_community/><multiplier>0</multiplier><snmp_oid/><key>php-fpm[&quot;total processes&quot;,{$PHP_FPM_STATUS_URL}]</key><delay>60</delay><history>90</history><trends>365</trends><status>0</status><value_type>0</value_type><allowed_hosts/><units/><delta>0</delta><snmpv3_contextname/><snmpv3_securityname/><snmpv3_securitylevel>0</snmpv3_securitylevel><snmpv3_authprotocol>0</snmpv3_authprotocol><snmpv3_authpassphrase/><snmpv3_privprotocol>0</snmpv3_privprotocol><snmpv3_privpassphrase/><formula>1</formula><delay_flex/><params/><ipmi_sensor/><data_type>0</data_type><authtype>0</authtype><username/><password/><publickey/><privatekey/><port/><description/><inventory_link>0</inventory_link><applications><application><name>php-fpm</name></application></applications><valuemap/><logtimefmt/></item><item><name>$1</name><type>0</type><snmp_community/><multiplier>0</multiplier><snmp_oid/><key>php-fpm[&quot;listen queue&quot;,{$PHP_FPM_STATUS_URL}]</key><delay>60</delay><history>90</history><trends>365</trends><status>0</status><value_type>0</value_type><allowed_hosts/><units/><delta>0</delta><snmpv3_contextname/><snmpv3_securityname/><snmpv3_securitylevel>0</snmpv3_securitylevel><snmpv3_authprotocol>0</snmpv3_authprotocol><snmpv3_authpassphrase/><snmpv3_privprotocol>0</snmpv3_privprotocol><snmpv3_privpassphrase/><formula>1</formula><delay_flex/><params/><ipmi_sensor/><data_type>0</data_type><authtype>0</authtype><username/><password/><publickey/><privatekey/><port/><description/><inventory_link>0</inventory_link><applications><application><name>php-fpm</name></application></applications><valuemap/><logtimefmt/></item><item><name>$1</name><type>0</type><snmp_community/><multiplier>0</multiplier><snmp_oid/><key>php-fpm[&quot;listen queue len&quot;,{$PHP_FPM_STATUS_URL}]</key><delay>60</delay><history>90</history><trends>365</trends><status>0</status><value_type>0</value_type><allowed_hosts/><units/><delta>0</delta><snmpv3_contextname/><snmpv3_securityname/><snmpv3_securitylevel>0</snmpv3_securitylevel><snmpv3_authprotocol>0</snmpv3_authprotocol><snmpv3_authpassphrase/><snmpv3_privprotocol>0</snmpv3_privprotocol><snmpv3_privpassphrase/><formula>1</formula><delay_flex/><params/><ipmi_sensor/><data_type>0</data_type><authtype>0</authtype><username/><password/><publickey/><privatekey/><port/><description/><inventory_link>0</inventory_link><applications><application><name>php-fpm</name></application></applications><valuemap/><logtimefmt/></item><item><name>$1</name><type>0</type><snmp_community/><multiplier>0</multiplier><snmp_oid/><key>php-fpm[&quot;active processes&quot;,{$PHP_FPM_STATUS_URL}]</key><delay>60</delay><history>90</history><trends>365</trends><status>0</status><value_type>0</value_type><allowed_hosts/><units/><delta>0</delta><snmpv3_contextname/><snmpv3_securityname/><snmpv3_securitylevel>0</snmpv3_securitylevel><snmpv3_authprotocol>0</snmpv3_authprotocol><snmpv3_authpassphrase/><snmpv3_privprotocol>0</snmpv3_privprotocol><snmpv3_privpassphrase/><formula>1</formula><delay_flex/><params/><ipmi_sensor/><data_type>0</data_type><authtype>0</authtype><username/><password/><publickey/><privatekey/><port/><description/><inventory_link>0</inventory_link><applications><application><name>php-fpm</name></application></applications><valuemap/><logtimefmt/></item><item><name>$1</name><type>0</type><snmp_community/><multiplier>0</multiplier><snmp_oid/><key>php-fpm[&quot;idle processes&quot;,{$PHP_FPM_STATUS_URL}]</key><delay>60</delay><history>90</history><trends>365</trends><status>0</status><value_type>0</value_type><allowed_hosts/><units/><delta>0</delta><snmpv3_contextname/><snmpv3_securityname/><snmpv3_securitylevel>0</snmpv3_securitylevel><snmpv3_authprotocol>0</snmpv3_authprotocol><snmpv3_authpassphrase/><snmpv3_privprotocol>0</snmpv3_privprotocol><snmpv3_privpassphrase/><formula>1</formula><delay_flex/><params/><ipmi_sensor/><data_type>0</data_type><authtype>0</authtype><username/><password/><publickey/><privatekey/><port/><description/><inventory_link>0</inventory_link><applications><application><name>php-fpm</name></application></applications><valuemap/><logtimefmt/></item><item><name>$1/sec</name><type>0</type><snmp_community/><multiplier>0</multiplier><snmp_oid/><key>php-fpm[&quot;accepted conn&quot;,{$PHP_FPM_STATUS_URL}]</key><delay>60</delay><history>90</history><trends>365</trends><status>0</status><value_type>0</value_type><allowed_hosts/><units/><delta>1</delta><snmpv3_contextname/><snmpv3_securityname/><snmpv3_securitylevel>0</snmpv3_securitylevel><snmpv3_authprotocol>0</snmpv3_authprotocol><snmpv3_authpassphrase/><snmpv3_privprotocol>0</snmpv3_privprotocol><snmpv3_privpassphrase/><formula>1</formula><delay_flex/><params/><ipmi_sensor/><data_type>0</data_type><authtype>0</authtype><username/><password/><publickey/><privatekey/><port/><description/><inventory_link>0</inventory_link><applications><application><name>php-fpm</name></application></applications><valuemap/><logtimefmt/></item><item><name>$1/sec</name><type>0</type><snmp_community/><multiplier>0</multiplier><snmp_oid/><key>php-fpm[&quot;slow requests&quot;,{$PHP_FPM_STATUS_URL}]</key><delay>60</delay><history>90</history><trends>365</trends><status>0</status><value_type>0</value_type><allowed_hosts/><units/><delta>1</delta><snmpv3_contextname/><snmpv3_securityname/><snmpv3_securitylevel>0</snmpv3_securitylevel><snmpv3_authprotocol>0</snmpv3_authprotocol><snmpv3_authpassphrase/><snmpv3_privprotocol>0</snmpv3_privprotocol><snmpv3_privpassphrase/><formula>1</formula><delay_flex/><params/><ipmi_sensor/><data_type>0</data_type><authtype>0</authtype><username/><password/><publickey/><privatekey/><port/><description/><inventory_link>0</inventory_link><applications><application><name>php-fpm</name></application></applications><valuemap/><logtimefmt/></item></items><discovery_rules/><macros><macro><macro>{$PHP_FPM_STATUS_URL}</macro><value>http://127.0.0.1:10061/php-fpm_status</value></macro></macros><templates/><screens/></template></templates><triggers><trigger><expression>{Template php-fpm:php-fpm[&quot;active processes&quot;,{$PHP_FPM_STATUS_URL}].nodata(220)}=1 or {Template php-fpm:php-fpm[&quot;active processes&quot;,{$PHP_FPM_STATUS_URL}].last(0)}&lt;0</expression><name>PHP-fpm of {HOSTNAME} is down</name><url/><status>0</status><priority>5</priority><description/><type>0</type><dependencies><dependency><name>Zabbix agent on {HOST.NAME} is unreachable for 5 minutes</name><expression>{Template OS Linux:agent.ping.nodata(5m)}=1</expression></dependency></dependencies></trigger></triggers><graphs><graph><name>php-fpm Accepted Connections / sec</name><width>900</width><height>200</height><yaxismin>0.0000</yaxismin><yaxismax>100.0000</yaxismax><show_work_period>1</show_work_period><show_triggers>1</show_triggers><type>0</type><show_legend>1</show_legend><show_3d>0</show_3d><percent_left>0.0000</percent_left><percent_right>0.0000</percent_right><ymin_type_1>0</ymin_type_1><ymax_type_1>0</ymax_type_1><ymin_item_1>0</ymin_item_1><ymax_item_1>0</ymax_item_1><graph_items><graph_item><sortorder>0</sortorder><drawtype>0</drawtype><color>C80000</color><yaxisside>0</yaxisside><calc_fnc>2</calc_fnc><type>0</type><item><host>Template php-fpm</host><key>php-fpm[&quot;accepted conn&quot;,{$PHP_FPM_STATUS_URL}]</key></item></graph_item></graph_items></graph><graph><name>php-fpm Listen Queue</name><width>900</width><height>200</height><yaxismin>0.0000</yaxismin><yaxismax>100.0000</yaxismax><show_work_period>1</show_work_period><show_triggers>1</show_triggers><type>0</type><show_legend>1</show_legend><show_3d>0</show_3d><percent_left>0.0000</percent_left><percent_right>0.0000</percent_right><ymin_type_1>0</ymin_type_1><ymax_type_1>0</ymax_type_1><ymin_item_1>0</ymin_item_1><ymax_item_1>0</ymax_item_1><graph_items><graph_item><sortorder>0</sortorder><drawtype>0</drawtype><color>EE0000</color><yaxisside>0</yaxisside><calc_fnc>2</calc_fnc><type>0</type><item><host>Template php-fpm</host><key>php-fpm[&quot;listen queue len&quot;,{$PHP_FPM_STATUS_URL}]</key></item></graph_item><graph_item><sortorder>1</sortorder><drawtype>0</drawtype><color>00EE00</color><yaxisside>0</yaxisside><calc_fnc>2</calc_fnc><type>0</type><item><host>Template php-fpm</host><key>php-fpm[&quot;listen queue&quot;,{$PHP_FPM_STATUS_URL}]</key></item></graph_item></graph_items></graph><graph><name>php-fpm Processes</name><width>900</width><height>200</height><yaxismin>0.0000</yaxismin><yaxismax>100.0000</yaxismax><show_work_period>1</show_work_period><show_triggers>1</show_triggers><type>1</type><show_legend>1</show_legend><show_3d>0</show_3d><percent_left>0.0000</percent_left><percent_right>0.0000</percent_right><ymin_type_1>0</ymin_type_1><ymax_type_1>0</ymax_type_1><ymin_item_1>0</ymin_item_1><ymax_item_1>0</ymax_item_1><graph_items><graph_item><sortorder>0</sortorder><drawtype>0</drawtype><color>EE0000</color><yaxisside>0</yaxisside><calc_fnc>4</calc_fnc><type>0</type><item><host>Template php-fpm</host><key>php-fpm[&quot;active processes&quot;,{$PHP_FPM_STATUS_URL}]</key></item></graph_item><graph_item><sortorder>1</sortorder><drawtype>0</drawtype><color>00EE00</color><yaxisside>0</yaxisside><calc_fnc>1</calc_fnc><type>0</type><item><host>Template php-fpm</host><key>php-fpm[&quot;idle processes&quot;,{$PHP_FPM_STATUS_URL}]</key></item></graph_item></graph_items></graph><graph><name>php-fpm Slow Requests / sec</name><width>900</width><height>200</height><yaxismin>0.0000</yaxismin><yaxismax>100.0000</yaxismax><show_work_period>1</show_work_period><show_triggers>1</show_triggers><type>0</type><show_legend>1</show_legend><show_3d>0</show_3d><percent_left>0.0000</percent_left><percent_right>0.0000</percent_right><ymin_type_1>0</ymin_type_1><ymax_type_1>0</ymax_type_1><ymin_item_1>0</ymin_item_1><ymax_item_1>0</ymax_item_1><graph_items><graph_item><sortorder>0</sortorder><drawtype>0</drawtype><color>C80000</color><yaxisside>0</yaxisside><calc_fnc>2</calc_fnc><type>0</type><item><host>Template php-fpm</host><key>php-fpm[&quot;slow requests&quot;,{$PHP_FPM_STATUS_URL}]</key></item></graph_item></graph_items></graph></graphs>
</zabbix_export>

在这里插入图片描述

上传脚本文件fpm.sh

#!/bin/bash
##################################
# Zabbix monitoring script
#
# php-fpm:
#  - anything available via FPM status page
#
##################################
# Contact:
#  vincent.viallet@gmail.com
##################################
# ChangeLog:
#  20100922	VV	initial creation
################################### Zabbix requested parameter
ZBX_REQ_DATA="$1"
ZBX_REQ_DATA_URL="$2"# Nginx defaults
NGINX_STATUS_DEFAULT_URL="http://localhost/fpm/status"
WGET_BIN="/usr/bin/wget"#
# Error handling:
#  - need to be displayable in Zabbix (avoid NOT_SUPPORTED)
#  - items need to be of type "float" (allow negative + float)
#
ERROR_NO_ACCESS_FILE="-0.91"
ERROR_NO_ACCESS="-0.92"
ERROR_WRONG_PARAM="-0.93"
ERROR_DATA="-0.94" # either can not connect /	bad host / bad port# Handle host and port if non-default
if [ ! -z "$ZBX_REQ_DATA_URL" ]; thenURL="$ZBX_REQ_DATA_URL"
elseURL="$NGINX_STATUS_DEFAULT_URL"
fi# save the nginx stats in a variable for future parsing
NGINX_STATS=$($WGET_BIN -q $URL -O - 2>/dev/null)# error during retrieve
if [ $? -ne 0 -o -z "$NGINX_STATS" ]; thenecho $ERROR_DATAexit 1
fi# 
# Extract data from nginx stats
#
#RESULT=$(echo "$NGINX_STATS" | awk 'print $0;match($0, "^'"$ZBX_REQ_DATA"':[[:space:]]+(.*)", a) { print a[1] }')
#RESULT=$(echo "$NGINX_STATS" | grep "$ZBX_REQ_DATA" | awk -F : '{print $2}')
RESULT=$(echo "$NGINX_STATS" | awk -F : "{if(\$1==\"$ZBX_REQ_DATA\") print \$2}")
if [ $? -ne 0 -o -z "$RESULT" ]; thenecho $ERROR_WRONG_PARAMexit 1
fiecho $RESULTexit 0

在这里插入图片描述

准备zabbix的配置文件
在这里插入图片描述

并测试脚本

sh fpm.sh "total processes" http://127.0.0.1/php_status

在这里插入图片描述

在zabbix-server上zabbix-get测试取值
在这里插入图片描述

链接模板
在这里插入图片描述

注意修改模板宏的值
在这里插入图片描述

查看检测最新数据
在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/web/11750.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

肥猫“也能变“型男“?揭秘福派斯牛肉高脂猫粮的神奇效果!

福猫养成指南&#xff1a;福派斯牛肉高脂猫粮的优点与考虑因素 福派斯牛肉高脂猫粮&#xff0c;这款富含蛋白质与脂肪的猫粮&#xff0c;仿佛是猫咪世界中的美味佳肴&#xff0c;让无数猫咪为之倾倒。然而&#xff0c;这款猫粮的利与弊&#xff0c;你是否都了解呢&#xff1f;接…

AI模型部署实战:利用OpenCV的CUDA模块加速视觉模型部署流程

本文首发于公众号【DeepDriving】&#xff0c;欢迎关注。 一. 前言 我在之前的文章《AI模型部署实战&#xff1a;利用CV-CUDA加速视觉模型部署流程》中介绍了如何使用CV-CUDA库来加速视觉模型部署的流程&#xff0c;但是CV-CUDA对系统版本和CUDA版本的要求比较高&#xff0c;在…

大模型介绍

大模型通常指的是参数量超过亿级别&#xff0c;甚至千亿级别的深度学习模型。这类模型能够处理更加复杂的任务&#xff0c;并在各项基准测试中取得了优异的成绩。大模型在自然语言处理、计算机视觉、推荐系统等领域都取得了显著的成果。 大模型的主要优势在于其强大的表征能力&…

k8s的核心组件etcd功能详解【含etcd各类参数详细说明】

etcd 是 Kubernetes 中的一个关键组件&#xff0c;用于存储集群的配置信息、状态和元数据。它通常作为 Kubernetes 集群的数据存储后端&#xff0c;为其他组件提供可靠的分布式键值存储服务。下面我会详细介绍 etcd 的功能以及常见的参数&#xff0c;以及如何配置和使用 etcd。…

Linux实验 Shell编程

实验目的&#xff1a; 熟练掌握Shell程序的建立与执行&#xff1b;掌握Shell变量的两种类型&#xff08;Shell环境变量和用户自定义变量&#xff09;及其用法&#xff1b;掌握Shell中的特殊字符、算术与逻辑运算&#xff1b;掌握Shell中输入输出命令&#xff1b;掌握Shell程序…

在Windows环境下安装CPU版的PyTorch

PytTorch是基于Python开发的&#xff0c;首先需要安装Python&#xff0c;Python的安装很简单&#xff0c;这里不再赘述。而 Windows用户能直接通过conda、pip和源码编译三种方式来安装PyTorch。 打开PyTorch官网&#xff08;PyTorch&#xff09;&#xff0c;在主页中根据自己的…

基于OpenCV年龄与性别识别系统

深入解析基于OpenCV年龄与性别识别系统 在这篇博客中&#xff0c;我们将详细解析一个使用OpenCV进行年龄和性别识别的Python脚本。这个脚本展示了如何利用深度学习模型&#xff0c;从视频或图像中检测人脸并预测每个人脸的年龄和性别。 1. 导入必要的模块 import cv2 as cv …

ELK的详解

ELK是由Elasticsearch、Logstash和Kibana三个开源软件&#xff08;后来又新加了一个FileBeat&#xff09;组成的日志管理解决方案&#xff0c;这一组合在近年来得到了广泛的关注和应用。以下是对这三个组件的详细说明&#xff1a; Elasticsearch&#xff1a; Elasticsearch是…

nginx 负载均衡配置详解

基于 ${nginx_home}/conf/nginx.conf 文件配置实现&#xff0c;如下&#xff1a; http {# 定义server地址upstream server_group {server 192.168.xxx.1:8080;server 192.168.xxx.2:8080;server 192.168.xxx.3:8080;}server {listen 80;location / {root html;index …

python数据分析——时间序列

时间序列 前言一、Datetime 模块常用函数和数据结构的详细解释datetime模块示例一示例二 二、时间运算示例一示例二示例三 三、时间序列分析自回归(Autoregressive model/AR)模型示例 滑动平均(moving average model/MA)模型示例 自回归滑动平均(Autoregressive moving average…

持续总结中!2024年面试必问 100 道 Java基础面试题(四十五)

上一篇地址&#xff1a;持续总结中&#xff01;2024年面试必问 100 道 Java基础面试题&#xff08;四十四&#xff09;-CSDN博客 八十九、在Java中&#xff0c;什么是线程局部变量&#xff08;ThreadLocal变量&#xff09;&#xff1f; 在Java中&#xff0c;ThreadLocal变量是…

企业微信hook接口协议,ipad协议http,发送链接的方式邀请成员进群

发送链接的方式邀请成员进群 参数名必选类型说明uuid是String每个实例的唯一标识&#xff0c;根据uuid操作具体企业微信 请求示例 {"uuid":"3240fde0-45e2-48c0-90e8-cb098d0ebe43","roomid":10696052955013729, "vids":[788130334…

Flutter 中的 CircleAvatar 小部件:全面指南

Flutter 中的 CircleAvatar 小部件&#xff1a;全面指南 在 Flutter 中&#xff0c;CircleAvatar 是一个用于显示头像的圆形控件&#xff0c;通常包含一个图标、图片或者一个简单的文本字符。它在设计上与 Material Design 指南中的头像规范相匹配&#xff0c;常用于展示用户信…

C# 常用汇总

时间处理 public static class DateTimeHelper{/// <summary>/// 获取当前时间戳&#xff08;Unix时间戳&#xff09; /// </summary>/// <returns></returns>public static long GetCurrentUnixTimestamp(){DateTimeOffset offset DateTimeOffset.…

Qt---文件系统

一、基本文件操作 1. QFile对文件进行读和写 QFile file( path 文件路径) 读&#xff1a; file.open(打开方式) QlODevice::readOnly 全部读取->file.readAll()&#xff0c;按行读->file.readLine()&#xff0c;atend()->判断是否读到文件尾 …

Java网络编程基础

Java网络编程基础主要涉及进程间通信、网络通信协议、IP地址和端口以及Java提供的网络应用编程接口等核心概念。 进程间通信是Java网络编程的基础。进程是运行中的程序&#xff0c;而进程间通信则是指不同进程之间进行数据交换和共享信息的过程。在Java中&#xff0c;进程间的…

STM32存储左右互搏 USB接口FATS文件读写U盘

STM32存储左右互搏 USB接口FATS文件读写U盘 STM32的USB接口可以例化为Host主机从而对U盘进行操作。SD卡/MicroSD/TF卡也可以通过读卡器转换成U盘使用。这里介绍STM32CUBEIDE开发平台HAL库实现U盘FATS文件访问的例程。 USB接口介绍 常见的USB接口电路部分相似而有不同的连接器…

K8S -----二进制搭建 Kubernetes v1.20

目录 一、准备环境 1.1 修改主机名 1.2 关闭防火墙&#xff08;三台一起&#xff0c;这里只展示master01&#xff09; 1.3 在master添加hosts&#xff08;依旧是三台一起&#xff09; 1.4 调整内核参数并开启网桥模式 二、部署docker引擎 三、部署 etcd 集群 1.在mast…

15.JUC原子类

文章目录 JUC原子类1.JUC中的Atomic原子操作包1.1. 基本原子类&#xff08;Basic Atomic Classes&#xff09;1.2. 数组原子类&#xff08;Array Atomic Classes&#xff09;1.3. 引用原子类&#xff08;Reference Atomic Classes&#xff09;4. 字段更新原子类&#xff08;Fie…

StackQueue+泛型简单理解

&#x1f341; 个人主页&#xff1a;爱编程的Tom&#x1f4ab; 本篇博文收录专栏&#xff1a;Java专栏&#x1f449; 目前其它专栏&#xff1a;c系列小游戏 c语言系列--万物的开始_ &#x1f389; 欢迎 &#x1f44d;点赞✍评论⭐收藏&#x1f496;三连支持一…