PHP-FPM and Nginx have built a status page that is very helpful to understand the status of PHP-FPM and to monitor php-fpm. For subsequent Zabbix monitoring, we need to first understand how the PHP-FPM status page is going.
1. Enable PHP-FPM State function
# cat /usr/local/php-5.5.10/etc/php-fpm.conf | grep status_path
pm.status_path =/status
2. Nginx Configuration
server {
listen *:80 default_server;
server_name _;
Location ~ ^/(status|ping) $
{
include fastcgi_params;
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_param script_filename $fastcgi _script_name
}
}
3. Restart NGINX/PHP-FPM
Service nginx Restart
service php-fpm restart
4. Open Status Page
# Curl Http://www.ttlsa.com/status
pool: www
process Manager: dynamic
start time: 14/may/ 2014:22:40:15 +0800
start since: 58508
accepted Conn:
Listen queue: 0
Max Listen Queue: 8
Listen queue len: 0
idle processes: 2
Active Processes: 1
Total Processes: 3
max active processes:5
max children reached:0
slow requests: 2091
5. PHP-FPM Status DetailedPOOL–FPM pool name, most of which are www
Process manager– processes management method, value: Static, dynamic or OnDemand. Dynamic
Start time– launch date, if Reload php-fpm, time will be updated
Start since– run time long
Accepted conn– the number of requests received by the current pool
Listen queue– request Wait queue, if this value is not 0, then increase the number of FPM processes
Max Listen queue– request wait queue highest number
Listen queue Len–socket wait queues length
Idle processes– number of idle processes
Active processes– dynamic number of processes
Total processes– Process Quantity
Max Active processes– Maximum activity number (FPM start count)
Max children reached-the number of maximum limit of the path process, if this number is not 0, that means that your maximum number of processes is too small, please change the larger.
Slow requests– enabled PHP-FPM Slow-log, number of slow requests
6. PHP-FPM Other Parameters
PHP-FPM Status Page a more personalized place is that it can take parameters, can have parameter JSON, XML, HTML, and the previous three parameters can be combined separately and full. 6.1 JSON
# Curl Http://127.0.0.1/status?json
{"Pool": "www", "Process Manager": "Dynamic", "Start Time": 1400078415, "start Since ": 59624," Accepted conn ":" Listen queue ": 0," Max Listen queue ": 8," Listen queue Len ": 0," Idle Processes ": 2," active Processes ": 1," Total Processes ": 3," Max Active Processes ": 5," Max Children reached ": 0," slow requests ": 2145}
6.2 XML
# Curl Http://127.0.0.1/status?xml
<?xml version= "1.0"?>
<status>
<pool>www</ pool>
<process-manager>dynamic</process-manager>
<start-time>1400078415</ start-time>
<start-since>59640</start-since>
<accepted-conn>36</accepted-conn >
<listen-queue>0</listen-queue>
<max-listen-queue>8</max-listen-queue>
<listen-queue-len>0</listen-queue-len>
<idle-processes>2</idle-processes>
<active-processes>1</active-processes>
<total-processes>3</total-processes>
<max-active-processes>5</max-active-processes>
<max-children-reached>0</ Max-children-reached>
<slow-requests>2145</slow-requests>
6.3 HTML
# Curl Http://127.0.0.1/status?html <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 strict//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > < HTML xmlns= "http://www.w3.org/1999/xhtml" xml:lang= "en" lang= "en" > 6.4 Full
# Curl Http://127.0.0.1/status?full
pool: www
process Manager: dynamic
start time: 14/may/ 2014:22:40:15 +0800
start since: 59695
accepted Conn: 1
Listen queue: 0
Max Listen Queue: 8
Listen queue len: 0
idle processes: 2
Active Processes: 1
Total Processes: 3
max active processes:5
max children reached:0
slow requests: 2148
PID: 29050 State
: Idle
start time: 15/may/2014:15:09:32 +0800
start Since: 338
requests:
request Duration: 1025585 Request method
: Get
request URI: /index.php
Content Length: 0
User: -
script: /data/site /www.ttlsa.com/index.php last
request CPUs: 45.83 last
request memory: 24903680
... Omit several pid ....
6.5 Full detailed pid– process PID, you can kill this process alone. You can use this PID to kill a long running process.
state– the status of the current process (Idle, Running, ...)
Start time– The date the process started
Start since– Current process run time length
requests– how many requests are processed by the current process
Request duration– Length (subtle)
Request method– Requests method (GET, POST, ...)
Request uri– URI
Content length– Request Length (POST only)
user– User (Php_auth_user) (or '-' if not set)
script–php script (or '-' if not set ')
Last request cpu– final requests for CPU usage.
Last request Memorythe-memory used on previous requests
7. Complete
The PHP-FPM Status page is very useful, using Zabbix or Nagios monitoring to consider using XML or the default method. Using the web, it is recommended to use HTML, the table will be more clear.