开启php-status状态

     从php5.3开始内部也内置了一个status的状态查看工具.默认是没有开启的,有需要监控php-status的可以去php-fpm.conf打开 ,并在nginx设置相应的配置即可.

一 配置php-status

; 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      #此处可以更改为其他的名字以免被nginx没有设置allow访问

二 在Nginx配置

image

三 重启nginx和php-fpm

四 打开php的ststua页面

image

五 输出信息解释

pool – fpm池子名称,大多数为www
process manager – 进程管理方式,值:static, dynamic or ondemand. dynamic
start time – 启动日期,如果reload了php-fpm,时间会更新
start since – 运行时长
accepted conn – 当前池子接受的请求数
listen queue – 请求等待队列,如果这个值不为0,那么要增加FPM的进程数量
max listen queue – 请求等待队列最高的数量
listen queue len – socket等待队列长度
idle processes – 空闲进程数量
active processes – 活跃进程数量
total processes – 总进程数量
max active processes – 最大的活跃进程数量(FPM启动开始算)
max children reached – 大道进程最大数量限制的次数,如果这个数量不为0,那说明你的最大进程数量太小了,请改大一点。
slow requests – 启用了php-fpm slow-log,缓慢请求的数量

六 其他输出格式

json,xml,html的输出格式如下,方便输出给其他的监控工具获取

image

full格式的输出以及输出信息解释

image

信息解释

pid – 进程PID,可以单独kill这个进程. You can use this PID to kill a long running process.
state – 当前进程的状态 (Idle, Running, …)
start time – 进程启动的日期
start since – 当前进程运行时长
requests – 当前进程处理了多少个请求
request duration – 请求时长(微妙)
request method – 请求方法 (GET, POST, …)
request URI – 请求URI
content length – 请求内容长度 (仅用于 POST)
user – 用户 (PHP_AUTH_USER) (or ‘-’ 如果没设置)
script – PHP脚本 (or ‘-’ if not set)
last request cpu – 最后一个请求CPU使用率。
last request memorythe – 上一个请求使用的内存

此条目发表在Php分类目录,贴了标签。将固定链接加入收藏夹。

发表评论

电子邮件地址不会被公开。 必填项已用*标注