我正在运行nginx + php-fpm.有什么方法我怎么知道每个PHP进程在做什么?像apache中的扩展mod_status,我可以看到使用PID x的apache进程处理URL y.我不确定PHP进程是否知道URL,但获取脚本路径和名称就足够了.
Mar*_*555 27
经过一些谷歌搜索和浏览PHP.net错误跟踪系统后,我找到了解决方案.它自PHP 5.3.8或5.3.9起可用,但似乎没有记录.根据功能请求#54577,状态页面支持选项full,该选项将分别显示每个工作程序的状态.例如,URL将是http://server.com/php-status?full和示例输出如下所示:
pid: 22816
state: Idle
start time: 22/Feb/2013:15:03:42 +0100
start since: 10933
requests: 28352
request duration: 1392
request method: GET
request URI: /ad.php?zID=597
content length: 0
user: -
script: /home/web/server.com/ad/ad.php
last request cpu: 718.39
last request memory: 1310720
Run Code Online (Sandbox Code Playgroud)
sjd*_*aws 11
PHP-FPM有一个内置的状态监视器,虽然它不像mod_status那样详细.来自php-fpm配置文件/etc/php-fpm.d/www.conf(在CentOS 6上)
; The URI to view the FPM status page. If this value is not set, no URI will be
; recognized as a status page. By default, the status page shows the following
; information:
; accepted conn - the number of request accepted by the pool;
; pool - the name of the pool;
; process manager - static or dynamic;
; idle processes - the number of idle processes;
; active processes - the number of active processes;
; total processes - the number of idle + active processes.
; The values of 'idle processes', 'active processes' and 'total processes' are
; updated each second. The value of 'accepted conn' is updated in real time.
; Example output:
; accepted conn: 12073
; pool: www
; process manager: static
; idle processes: 35
; active processes: 65
; total processes: 100
; By default the status page output is formatted as text/plain. Passing either
; 'html' or 'json' as a query string will return the corresponding output
; syntax. Example:
; http://www.foo.bar/status
; http://www.foo.bar/status?json
; http://www.foo.bar/status?html
; Note: The value must start with a leading slash (/). The value can be
; anything, but it may not be a good idea to use the .php extension or it
; may conflict with a real PHP file.
; Default Value: not set
;pm.status_path = /status
Run Code Online (Sandbox Code Playgroud)
如果启用此功能,则可以将路径从nginx传递到PHP-FPM的套接字/端口,然后可以查看状态页面.
nginx.conf:
location /status {
include fastcgi_params;
fastcgi_pass unix:/var/lib/php/php-fpm.sock;
}
Run Code Online (Sandbox Code Playgroud)
cgi命令行更方便:
SCRIPT_NAME=/status \
SCRIPT_FILENAME=/status \
REQUEST_METHOD=GET \
cgi-fcgi -bind -connect 127.0.0.1:9000
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
28521 次 |
| 最近记录: |