设为首页 收藏本站
查看: 846|回复: 0

[经验分享] Nginx – Enable PHP-FPM Status Page

[复制链接]

尚未签到

发表于 2018-11-15 06:54:16 | 显示全部楼层 |阅读模式
  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 = /statusEdit Nginx config
  Next, in Nginx config for example.com add 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, 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

  •   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>service php5-fpm>) 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>

  •   idle processes – the number of>
  •   active processes – the number of active processes

  •   total processes – the number of>
  •   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?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

  •   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>

  •   last request memorythe max amount of memory the last request consumed. it’s always 0 if the process is not in>

  Note: If the process is in>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/status
  •   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.



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-635130-1-1.html 上篇帖子: Nginx+Tomcat动静分离集群配置 下篇帖子: 整合nginx,tomcat,mysql的安装与配置
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表