您好,欢迎访问一九零五行业门户网

在浏览器里查看Nginx和PHP-FPM的运行状态

查看nginx状态 location /nginx_status {
    stub_status on;
    access_log off;
    allow 127.0.0.1;
    deny all;
}
curl http://127.0.0.1/nginx_status
http://nginx.org/en/docs/http/ngx_http_status_module.html
输出样例:
active connections: 3
server accepts handled requests
 17737 17737 49770
reading: 0 writing: 1 waiting: 2
各项解释:
active connections: 当前 nginx 正处理的活动连接数.
server accepts handled requests: 总共处理了 17737 个连接, 成功创建 17737 次握手(证明中间没有失败的), 总共处理了 49770 个请求.
reading: nginx 读取到客户端的 header 信息数.
writing: nginx 返回给客户端的 header 信息数.
waiting: 开启 keep-alive 的情况下, 这个值等于 active - (reading + writing), 意思就是 nginx 已经处理完正在等候下一次请求指令的驻留连接.
查看php-fpm状态 php-fpm.conf 中开启 pm.status_path = /status
nginx.conf 中配置:
location /status {
    include        fastcgi_params;
    fastcgi_param  script_filename $document_root$fastcgi_script_name;
    fastcgi_index  index.php;
    fastcgi_pass   127.0.0.1:9000;
}
访问 http://127.0.0.1/status?full 查看状态信息(我只开了一个php-fpm工作进程):
pool:                 www
process manager:      static
start time:           27/dec/2014:13:29:00 +0800
start since:          2571
accepted conn:        28
listen queue:         0
max listen queue:     0
listen queue len:     128
idle processes:       0
active processes:     1
total processes:      1
max active processes: 1
max children reached: 0
slow requests:        0
************************
pid:                  1275
state:                running
start time:           27/dec/2014:13:29:00 +0800
start since:          2571
requests:             28
request duration:     100
request method:       get
request uri:          /status?full
content length:       0
user:                 -
script:               -
last request cpu:     0.00
last request memory:  0
附: 下面是php-fpm.conf里的说明
; the uri to view the fpm status page. if this value is not set, no uri will be
; recognized as a status page. it shows the following informations:
;   pool                 - the name of the pool;
;   process manager      - static, dynamic or ondemand;
;   start time           - the date and time fpm has started;
;   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 (see backlog in listen(2));
;   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 (works only for
;                          pm 'dynamic' and 'ondemand');
; value are updated in real time.
; example output:
;   pool:                 www
;   process manager:      static
;   start time:           01/jul/2011:17:53:49 +0200
;   start since:          62636
;   accepted conn:        190460
;   listen queue:         0
;   max listen queue:     1
;   listen queue len:     42
;   idle processes:       4
;   active processes:     11
;   total processes:      15
;   max active processes: 12
;   max children reached: 0
;
; 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. example:
;   http://www.foo.bar/status
;   http://www.foo.bar/status?json
;   http://www.foo.bar/status?html
;   http://www.foo.bar/status?xml
;
; by default the status page only outputs short status. passing 'full' in the
; query string will also return status for each pool process.
; example:
;   http://www.foo.bar/status?full
;   http://www.foo.bar/status?json&full
;   http://www.foo.bar/status?html&full
;   http://www.foo.bar/status?xml&full
; the full status returns for each process:
;   pid                  - the pid of the 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 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 memory  - the 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;
; 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.
; example output:
;   ************************
;   pid:                  31330
;   state:                running
;   start time:           01/jul/2011:17:53:49 +0200
;   start since:          63087
;   requests:             12808
;   request duration:     1250261
;   request method:       get
;   request uri:          /test_mem.php?n=10000
;   content length:       0
;   user:                 -
;   script:               /home/fat/web/docs/php/test_mem.php
;   last request cpu:     0.00
;   last request memory:  0
;
; note: there is a real-time fpm status monitoring sample web page available
;       it's available in: ${prefix}/share/fpm/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
其它类似信息

推荐信息