当前位置:网站首页>PHP FPM custom ZABBIX monitoring
PHP FPM custom ZABBIX monitoring
2022-07-21 17:32:00 【Bandiaozi refining whole stack】
Customize php-fpm zabbix Monitoring template
According to the above experiment
In the device 1、 equipment 2 On the basis of
equipment 1 192.168.70.10 zabbix-server
equipment 2 192.168.70.20 zabbix-agent
equipment 2:
install php-rpm service
[[email protected]]# yum -y install php-fpm
modify php-fpm The configuration file opens the status page function ( Search for :status)
[[email protected]]# vim /etc/php-fpm.d/www.conf
pm.status_path = /php_status # Uncomment and rename php_status
start-up php-fpm
[[email protected]]# systemctl start php-fpm
Set power on self start
[[email protected]]#systemctl enable php-fpm
modify nginx The configuration file specifies php To configure (Ctrl+v Decline in Visual block appears uncomment )
[[email protected]]#vim /etc/nginx/conf.d/default.conf
……
location /php_status { # Appoint php page name
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # Configuration environment
include fastcgi_params;
}
restart nginx
[[email protected]]#systemctl restart nginx
Test access php Status page :http://192.168.70.20/php_status
php-fpm status Detailed explanation of status value
pool:fpm Pool name , Most of them are www
process manager: Process management , value :static,dynamic or ondemand
start time: Start date , If reload 了 php-fpm, Time will be more new
start since: Run time
accepted conn: The number of requests currently accepted by the pool
listen queue: Request waiting queue , If the value is not 0, Then increase Add FPM The number of processes
max listen queue: The highest number of request waiting queues
listen queue len:socket Waiting queue length
idle processes: Number of idle processes
active processes: Number of active processes
total processes: Total number of processes
max active processes: Maximum number of active processes (FPM Start on Initial calculation ) max children reached: The number of times the maximum number of processes is limited , If this The number of pieces is not 0, That means your maximum number of processes is too small , It needs to be set larger
slow requests When enabled php-fpm slow-log When the function , Such as Fruit appears php-fpm The slow request counter will increase , Generally inappropriate Mysql check Inquiry will trigger this value
Customize phpfpm Monitoring item ( Monitor the above status )
[[email protected] script]# vim/etc/zabbix/zabbix_agentd.d/phpfpm_status.conf UserParameter=phpfpm_status[*],/bin/bash /etc/zabbix/script/phpfpm_status.sh "$1"
Upload the script to /etc/zabbix/script Path and add execution permission
[[email protected] script]#/etc/zabbix/script
[[email protected] script]#ls
phpfpm_status.sh
[[email protected] script]# cat phpfpm_status.sh
#!/bin/bash
PHPFPM_COMMAND=$1
# Adjust according to different listening ports
PHPFPM_PORT=80
start_since(){
/usr/bin/curl -s "http://127.0.0.1:"$PHPFPM_PORT"/php_status" |awk '/^start since:/ {print $NF}'
}
accepted_conn(){
/usr/bin/curl -s "http://127.0.0.1:"$PHPFPM_PORT"/php_status" |awk '/^accepted conn:/ {print $NF}'
}
listen_queue(){
/usr/bin/curl -s "http://127.0.0.1:"$PHPFPM_PORT"/php_status" |awk '/^listen queue:/ {print $NF}'
}
max_listen_queue(){
/usr/bin/curl -s "http://127.0.0.1:"$PHPFPM_PORT"/php_status" |awk '/^max listen queue:/ {print $NF}'
}
listen_queue_len(){
/usr/bin/curl -s "http://127.0.0.1:"$PHPFPM_PORT"/php_status" |awk '/^listen queue len:/ {print $NF}'
}
idle_processes(){
/usr/bin/curl -s "http://127.0.0.1:"$PHPFPM_PORT"/php_status" |awk '/^idle processes:/ {print $NF}'
}
active_processes(){
/usr/bin/curl -s "http://127.0.0.1:"$PHPFPM_PORT"/php_status" |awk '/^active processes:/ {print $NF}'
}
total_processes(){
/usr/bin/curl -s "http://127.0.0.1:"$PHPFPM_PORT"/php_status" |awk '/^total processes:/ {print $NF}'
}
max_active_processes(){
/usr/bin/curl -s "http://127.0.0.1:"$PHPFPM_PORT"/php_status" |awk '/^max active processes:/ {print $NF}'
}
max_children_reached(){
/usr/bin/curl -s "http://127.0.0.1:"$PHPFPM_PORT"/php_status" |awk '/^max children reached:/ {print $NF}'
}
slow_requests(){
/usr/bin/curl -s "http://127.0.0.1:"$PHPFPM_PORT"/php_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
Script Authorization
[[email protected] script]# chmod +x phpfpm_status.sh
restart zabbix agent Service monitoring items take effect
[[email protected] script]# systemctl restart zabbix-agent
Turn on php-rpm
[[email protected] script]# systemctl restart php-fpm
Check the server
[[email protected] script]# netstat -ntlp
equipment 1
analysis
[[email protected]]#vim /etc/hosts
192.168.70.20 host-20
zabbix server Get monitoring item data
[[email protected]]#zabbix_get -s 192.168.0.111 -k phpfpm_status[start_since] #php-fpm Runtime Long
[[email protected]]#zabbix_get -s 192.168.0.111 -k phpfpm_status[accepted_conn] # Current number of connections received
[[email protected]]#zabbix_get -s 192.168.0.111 -k phpfpm_status[listen_queue] # Number of requests waiting to connect
[[email protected]]# zabbix_get -s 192.168.0.111 -k phpfpm_status[max_listen_queue] # The request waiting queue is the highest The number of
[[email protected]]#zabbix_get -s 192.168.0.111 -k phpfpm_status[listen_queue_len] #socket Waiting in line length
[[email protected]]#zabbix_get -s 192.168.0.111 -k phpfpm_status[idle_processes] # Number of idle processes ` Insert a code chip here `
[[email protected]]#zabbix_get -s 192.168.0.111 -k phpfpm_status[active_processes] # Number of active processes
[[email protected]]#zabbix_get -s 192.168.0.111 -k phpfpm_status[total_processes] # Total number of processes
[[email protected]]#zabbix_get -s 192.168.0.111 -k phpfpm_status[max_active_processes] # The most active Number of processes
[[email protected]]#zabbix_get -s 192.168.0.111 -k phpfpm_status[max_children_reached] # Maximum number of processes Quantity limit times
[[email protected]]#zabbix_get -s 192.168.0.111 -k phpfpm_status[slow_requests] #php-fpm slow request
To configure ——> Templates ——> Create a template
In the newly created template ——> establish Application set
In the new template ——> establish Monitoring item
Monitoring item name :php-fpm Run time
type : client
Key value :phpfpm_status[start_since]( Select the name in the script )
Message type : Numbers ( No plus or minus ) ( Those involving decimals are Floating point numbers )
Update interval :1m ( Express 1 minute )
How long the historical data is kept :7d(7 God )
Trend storage time :365d(365 God )
Application set :PHP ( Our new building )
add to
Add other data in the script in turn
Add to complete
complete
边栏推荐
- 【RViz2】导入urdf模型时报错:Could not load resource xxx,Unable to open file xxx,Error retrieving file xxx
- 第2讲 Hi3861的WiFi实验-Station模式
- Analysis of tars source code 27
- Regression prediction analysis of jujube genetics based on support vector machine
- 如何分析并设计性能测试场景
- C#(四十五)之线程池
- Analysis of tars source code 24
- JS-添加方式(行内 内嵌 外部)
- Power Bi ---- slicer to make the report more beautiful
- 华为无线设备配置同一业务VLAN的AP间快速漫游
猜你喜欢
C#(三十八)之StreamWriter StreamWriter使用方法及与FileStream类的区别
JS--循环--猜数字(生成随机数存在小数Math.random)
JS -- basic grammar
rsync 结合 inotify 实现文件实时同步(二)
IP第十一天笔记
What resources cannot be shared between threads?
静态通讯录的实现
JS add method (inline and external)
SAP FIORI专题之二:用webide构建带导航栏的fiori
Ccs3 comprehensive experiment -- stylesheet file -- design a menu page
随机推荐
WiFi Authentication&Omnipeek抓包分析
支持向量机进行枣类遗传的回归预测分析
IT运维管理指什么?如何建立有效的IT运维管理系统?
卷积神经网络单图超分辨率的深度学习方法
mysql 常用的时间相关操作
Jmeter-正则、xpath、JSON
Huawei wireless device WLAN QoS configuration command
华为无线设备配置流量监管
同城两中心自适应同步模式部署
在线博客系统设计
JS syntax variables (declaration, naming conventions, declaration of multiple variables at one time, use)
Deep learning method of convolutional neural network single image super-resolution
Regression prediction analysis of jujube genetics based on support vector machine
同城多数据中心部署 TiDB
Restful风格真的有必要吗?
Huawei wireless devices are configured with ACL based message filtering
[基础架构] [Flink] Flink/Flink-CDC代码实现业务接入
OpenCV学习——ArUco模块
Kruskal 重构树
C#(四十一)之线程