Nginx – Enable PHP-FPM Status Page
2015-02-11 17:43
429 查看
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.
process manager – possible values static, dynamic or ondemand. We never use static. Tryingondemand is on todo list.
start time – the date and time FPM has started or reloaded. Reloading PHP-FPM (
start since – number of seconds since FPM has started
accepted conn – the number of request accepted by the pool
listen queue – the number of request in the queue of pending connections. If this number is non-zero, then you better increase number of process FPM can spawn.
max listen queue – the maximum number of requests in the queue of pending connections since FPM has started
listen queue len – the size of the socket queue of pending connections
idle processes – the number of idle processes
active processes – the number of active processes
total processes – the number of idle + active processes
max active processes – the maximum number of active processes since FPM has started
max children reached – number of times, the process limit has been reached, when pm tries to start more children. If that value is not zero, then you may need to increase max process limit for your PHP-FPM pool. Like this, you can find other useful information to tweak your pool better way.
slow requests – Enable php-fpm slow-log before you consider this. If this value is non-zero you may have slow php processes. Poorly written mysql queries are generally culprit.
state – the state of the process (Idle, Running, …)
start time – the date and time the process has started
start since – the number of seconds since the process has started
requests – the number of requests the process has served
request duration – the duration in μs of the requests
request method – the request method (GET, POST, …)
request URI – the request URI with the query string
content length – the content length of the request (only with POST)
user – the user (PHP_AUTH_USER) (or ‘-‘ if not set)
script – the main PHP script called (or ‘-‘ if not set)
last request cpu – the %cpu the last request consumed. it’s always 0 if the process is not in Idle state because CPU calculation is done when the request processing has terminated
last request memorythe max amount of memory the last request consumed. it’s always 0 if the process is not in Idle state because memory calculation is done when the request processing has terminated
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.
http://example.com/status?json http://example.com/status?html http://example.com/status?xml
Example for detailed status page:http://example.com/status?full
http://example.com/status?json&full http://example.com/status?html&full http://example.com/status?xml&full
You can use json or xml format to process status page output programatically. HTML is useful when viewing detailed status report.
Enabling PHP-FPM Status Page
Edit PHP-FPM Config
In file/etc/php5/fpm/pool.d/www.conf, find
pm.status_pathvariable.
vim +/pm.status_path /etc/php5/fpm/pool.d/www.confUncomment 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 forexample.comadd a location block like below:
location ~ ^/(status|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, openhttp://example.com/statusin 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
pool – the name of the pool. Mostly it will be www.process manager – possible values static, dynamic or ondemand. We never use static. Tryingondemand is on todo list.
start time – the date and time FPM has started or reloaded. Reloading PHP-FPM (
service php5-fpm reload) reset this value.
start since – number of seconds since FPM has started
accepted conn – the number of request accepted by the pool
listen queue – the number of request in the queue of pending connections. If this number is non-zero, then you better increase number of process FPM can spawn.
max listen queue – the maximum number of requests in the queue of pending connections since FPM has started
listen queue len – the size of the socket queue of pending connections
idle processes – the number of idle processes
active processes – the number of active processes
total processes – the number of idle + active processes
max active processes – the maximum number of active processes since FPM has started
max children reached – number of times, the process limit has been reached, when pm tries to start more children. If that value is not zero, then you may need to increase max process limit for your PHP-FPM pool. Like this, you can find other useful information to tweak your pool better way.
slow requests – Enable php-fpm slow-log before you consider this. If this value is non-zero you may have slow php processes. Poorly written mysql queries are generally culprit.
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?fullIn 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
pid – the PID of the process. You can use this PID to kill a long running process.state – the state of the process (Idle, Running, …)
start time – the date and time the process has started
start since – the number of seconds since the process has started
requests – the number of requests the process has served
request duration – the duration in μs of the requests
request method – the request method (GET, POST, …)
request URI – the request URI with the query string
content length – the content length of the request (only with POST)
user – the user (PHP_AUTH_USER) (or ‘-‘ if not set)
script – the main PHP script called (or ‘-‘ if not set)
last request cpu – the %cpu the last request consumed. it’s always 0 if the process is not in Idle state because CPU calculation is done when the request processing has terminated
last request memorythe max amount of memory the last request consumed. it’s always 0 if the process is not in Idle state because memory calculation is done when the request processing has terminated
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:http://example.com/statushttp://example.com/status?json http://example.com/status?html http://example.com/status?xml
Example for detailed status page:http://example.com/status?full
http://example.com/status?json&full http://example.com/status?html&full http://example.com/status?xml&full
You can use json or xml format to process status page output programatically. HTML is useful when viewing detailed status report.
相关文章推荐
- 开启nginx的status和php-fpm的status页面
- debug note-- nginx php-fpm : Error:The page you are looking for is temporarily unavailable.
- 开启nginx和php-fpm的status状态监控
- nginx php-fpm调优
- nginx php-fpm调优
- 装好nginx后安装php及php-fpm
- 网站运维架构设计及安装过程(linux+nginx+php-fpm+pgsql+memcached+varnish+mysql)
- 1分钟完美安装最新 CentOS + Nginx + PHP-FPM + MySQL
- 安装Nginx与使用PHP5(和PHP-FPM Nginx)和MySQL在 CentOS支持6.0的支持
- 1分钟完美安装最新 CentOS + Nginx + PHP-FPM + MySQL
- centos 5.6安装nginx+mysql+php(php-fpm)+phpmyadmin总结
- shell 之 lnmp(nginx-1.0.5+php-fpm5.3.6+mysql)安装脚本
- How to install Nginx, PHP, PHP-FPM and MySQL under Windows with Cygwin
- nginx_笔记分享_2_php-fpm详解
- linux(centos)上配置nginx、mysql、php-fpm开机启动
- ubuntu 10.10 nginx+php+php-fpm+mysql简单搭建实现
- nginx+PHP+PHP-FPM(FastCGI)在Ubuntu上的安装和配置
- 1分钟完美安装最新 CentOS + Nginx + PHP-FPM + MySQL
- 1分钟完美安装 CentOS + Nginx + PHP-FPM + MySQL
- nginx_笔记分享_1_安装篇(nginx-1.0.5+php-fpm5.3.6+mysql) 推荐