Technology Blog

Scripts Running in PHP FPM Process Status

0

Show the scripts that are running at any given time on php-fpm with nginx in centos 6. This is helpful if you need to troubleshoot a script that is being bombarded by bots, has bugs, or is causing excessively high load.

The process status only works for php 5.4.x and greater. 5.3.x will show you an average of other stats, eg:

pool:                 www
process manager:      dynamic
start time:           28/Apr/2014:14:52:39 -0500
start since:          1778
accepted conn:        1
listen queue:         0
max listen queue:     0
listen queue len:     128
idle processes:       4
active processes:     1
total processes:      5
max active processes: 1
max children reached: 0

Fist edit /etc/php-fpm.d/www.conf to include pm.status_path = /status
You should only need to uncomment it and change the path to whatever you’d like.

Create a new vhost. For nginx, it’s something like this:

server {
listen   8080;
server_name stats;
access_log /var/log/nginx/stats-access.log;
error_log /var/log/nginx/stats-error.log;

location ~ ^/(status)$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass    127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param  SCRIPT_FILENAME $ document_root$ fastcgi_script_name;

allow 127.0.0.1;
deny all;
}
}

Also keep in mind, unless something is currently going haywire, the part you probably care about over time is the cpu/memory required for each requests. Something like xhprof with xhgui does a better job of looking at that data over time and aggregating it. Though might not be something you want to run on production on a regular basis. And if possible, I’d run it against a list of URL’s using apache benchmark or something similar to generate your xhgui data.

Then access it with

http://stats/status?full

http://stackoverflow.com/questions/15465333/php-fpm-processes-monitoring-profiling

https://rtcamp.com/tutorials/php/fpm-status-page/