Site icon rtCamp

Nginx – Enable PHP-FPM Status Page

PHP-FPM has a very useful built-in status page.

You can access it over web and also write scripts to monitor your PHP-FPM sites health remotely.

Enabling PHP-FPM Status Page

Edit PHP-FPM Config

In file /etc/php5/fpm/pool.d/www.conf, find pm.status_path variable.

vim +/pm.status_path /etc/php5/fpm/pool.d/www.conf

Uncomment that line (if its commented).

Default value is /status. You can change it to something else. May be you can add pool-prefix if you are running multiple PHP pools.

pm.status_path = /status

Edit Nginx config

Next, in Nginx config for example.com add a location block like below:

location = /status {
access_log off;
allow 127.0.0.1;
allow 1.2.3.4#your-ip;
deny all;
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
}

location = /ping {
access_log off;
allow 127.0.0.1;
allow 1.2.3.4#your-ip;
deny all;
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
}

Do not forget to replace your IP address. For security reasons, its better to keep your PHP-FPM status page private.

Reload PHP-FPM and Nginx config for changes to take effect.

PHP-FPM Status Sample

Default PHP-FPM Status Sample

Now, open http://example.com/status in browser to see summarised stats like below

pool:                 www
process manager:      dynamic
start time:           17/May/2013:13:54:02 +0530
start since:          886617
accepted conn:        1619617
listen queue:         0
max listen queue:     0
listen queue len:     0
idle processes:       28
active processes:     2
total processes:      30
max active processes: 31
max children reached: 0
slow requests:        0

Below is meaning of different values

Full PHP-FPM Status Sample

If you want detailed stats, you can pass argument ?fullto status page URL. It will become http://example.com/status?full

In additional to pool-level summary we have seen above, this will show extra details for per process. A sample is below:

pid:                  1419692
state:                Idle
start time:           27/May/2013:20:06:12 +0530
start since:          287
requests:             32
request duration:     188927
request method:       GET
request URI:          /feed.php?uid=12997446135571490564
content length:       0
user:                 -
script:               /var/www/example.com/htdocs/feed.php
last request cpu:     5.29
last request memory:  524288

Below is meaning of different values

Note: If the process is in Idle state, then informations are related to the last request the process has served. Otherwise informations are related to the current request being served.

PHP-FPM Status Page Output formats

By default the status page output is formatted as text/plain. Passing either ‘html’, ‘xml’ or ‘json’ in the query string will return the corresponding output syntax.

Examples for summary status page:

Example for detailed status page:

You can use json or xml format to process status page output programatically. HTML is useful when viewing detailed status report.

Exit mobile version