Zabbix monitors PHP status
Zabbix monitors the PHP status and uses nginx to call php-fpm to query the php status information.
First, add a line to the php configuration file.
Vim/usr/local/php/etc/php-fpm.conf
Pm. status_path =/phpfpmstatus
Restart php-fpm after saving
Add code to the nginx configuration file
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;
}
}
Restart nginx after saving
Then use curl-s http: // localhost/phpfpmstatus to check whether php status information can be obtained.
Then, edit the execution script in the zabbix Script directory.
#! /Bin/bash
# Monitor php-fpm status from zabbix
# Lincense: GPL
# Mail: [email protected]
# 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 | queue | idle_processes | active_processes | total_processes | max_active_processes | cost }"
Esac
Save and exit. Change the permission
-Rwxr-xr-x 1 zabbix 1770 14:50 phpstatus. sh
Edit the zabbix_agentd.conf file, add the code above and below, and restart the zabbix_agentd service.
# 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 = maid. 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
Then, you can configure items on the web side to monitor the php status.
Some Zabbix Tutorials:
Install and deploy the distributed monitoring system Zabbix 2.06
Install and deploy the distributed monitoring system Zabbix 2.06
Install and deploy Zabbix in CentOS 6.3
Zabbix distributed monitoring system practice
Under CentOS 6.3, Zabbix monitors apache server-status
Monitoring MySQL database Parameters Using Zabbix in CentOS 6.3
Install Zabbix 2.0.6 in 64-bit CentOS 6.2
ZABBIX details: click here
ZABBIX: click here
This article permanently updates the link address: