最新消息:其实接手服务器,最最最重要的还是要看下数据库、文件备份情况!!!非常重要!!!

phpfpm status状态说明

application shang 3116浏览 0评论

说明:
phpfpm跟nginx一样有个status状态监控页。可能通过status状态监控页了解phpfpm的运行状态,如并发数,总进程数等。

具体:
1. 启用php-fpm状态功能

# vim /usr/local/php/etc/php-fpm.conf | grep status_path
pm.status_path = /phpfpm_status  //这个要与第2步nginx上的location上一致,写成这样也是zabbix监控时与nginx的区分开来

 
2. nginx配置
在默认主机里面加上location或者你希望能访问到的主机里面。

server {
    listen  80;
    server_name 127.0.0.1;
    location /phpfpm_status {
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                include fastcgi.conf;
    }
}

 
3. 重启nginx,php-fpm

# service nginx restart
# service php-fpm restart

 
4. 打开status页面

# curl http://127.0.0.1/phpfpm_status
pool:                 www
process manager:      static
start time:           30/Jan/2015:13:58:14 +0800
start since:          1186
accepted conn:        6955
listen queue:         0
max listen queue:     1
listen queue len:     0
idle processes:       159
active processes:     1
total processes:      160
max active processes: 13
max children reached: 0
slow requests:        7

 
5. php-fpm status详解

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,缓慢请求的数量

 
6. php-fpm其他参数
php-fpm状态页比较个性化的一个地方是它可以带参数,可以带参数json、xml、html并且前面三个参数可以分别和full做一个组合。

6.1 json

# curl http://127.0.0.1/phpfpm_status?json
{"pool":"www","process manager":"static","start time":1422597494,"start since":3033,"accepted conn":38690,"listen queue":0,"max listen queue":1,"listen queue len":0,"idle processes":159,"active processes":1,"total processes":160,"max active processes":13,"max children reached":0,"slow requests":9}

 
6.2 xml

# curl http://127.0.0.1/phpfpm_status?xml
<?xml version="1.0" ?>
<status>
<pool>www</pool>
<process-manager>static</process-manager>
<start-time>1422597494</start-time>
<start-since>3087</start-since>
<accepted-conn>40297</accepted-conn>
<listen-queue>0</listen-queue>
<max-listen-queue>1</max-listen-queue>
<listen-queue-len>0</listen-queue-len>
<idle-processes>159</idle-processes>
<active-processes>1</active-processes>
<total-processes>160</total-processes>
<max-active-processes>13</max-active-processes>
<max-children-reached>0</max-children-reached>
<slow-requests>9</slow-requests>

 
6.3 html

# curl http://127.0.0.1/phpfpm_status?html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head><title>PHP-FPM Status Page</title></head>
<body>
<table>
<tr><th>pool</th><td>www</td></tr>
<tr><th>process manager</th><td>static</td></tr>
<tr><th>start time</th><td>30/Jan/2015:13:58:14 +0800</td></tr>
<tr><th>start since</th><td>3156</td></tr>
<tr><th>accepted conn</th><td>41985</td></tr>
<tr><th>listen queue</th><td>0</td></tr>
<tr><th>max listen queue</th><td>1</td></tr>
<tr><th>listen queue len</th><td>0</td></tr>
<tr><th>idle processes</th><td>159</td></tr>
<tr><th>active processes</th><td>1</td></tr>
<tr><th>total processes</th><td>160</td></tr>
<tr><th>max active processes</th><td>13</td></tr>
<tr><th>max children reached</th><td>0</td></tr>
<tr><th>slow requests</th><td>9</td></tr>
</table>
</body></html>

 
6.4 full

# curl http://127.0.0.1/phpfpm_status?full
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0pool:                 www
process manager:      static
start time:           30/Jan/2015:13:58:14 +0800
start since:          2769
accepted conn:        30459
listen queue:         0
max listen queue:     1
listen queue len:     0
idle processes:       158
active processes:     2
total processes:      160
max active processes: 13
max children reached: 0
slow requests:        9

************************
pid:                  7635
state:                Idle
start time:           30/Jan/2015:13:58:14 +0800
start since:          2769
requests:             529
request duration:     2937
request method:       POST
100 73963    0 73963    0     0  40.9M      0 --:--:-- --:--:-- --:--:-- 70.5M
request URI:          /index.php
content length:       106
user:                 -
script:               /data/site/coolnull.com/index.php
last request cpu:     340.48
last request memory:  1310720

 
6.5 full详解

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 – 上一个请求使用的内存

 
7. 完成
php-fpm状态页很实用,使用zabbix或者nagios监控可以考虑使用xml或者默认方式。用web的话,推荐使用html,表格会比较清晰。

转载请注明:酷喃|coolnull| » phpfpm status状态说明

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址