欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

phpfpm使用自带的status优化步骤

程序员文章站 2022-04-23 16:05:42
...
php-fpm和nginx一样内建了一个状态页,对于想了解php-fpm的状态以及监控php-fpm非常有帮助。为了后续的zabbix监控,我们需要先了解php-fpm状态页是怎么回事。

1. 启用php-fpm状态功能

# cat  /usr/local/php-5.5.10/etc/php-fpm.conf | grep status_path
pm.status_path = /status

2. nginx配置

server {
    listen  *:80 default_server;
    server_name _;
    location ~ ^/(status|ping)$
    {
        include fastcgi_params;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
    }
}

3. 重启nginx/php-fpm

service nginx restart
service php-fpm restart

4. 打开status页面

# curl http://www.ttlsa.com/status
pool:                 www
process manager:      dynamic
start time:           14/May/2014:22:40:15 +0800
start since:          58508
accepted conn:        33
listen queue:         0
max listen queue:     8
listen queue len:     0
idle processes:       2
active processes:     1
total processes:      3
max active processes: 5
max children reached: 0
slow requests:        2091

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状态页比较个性化的一个地方是它可以带参数,可以带参数jsonxmlhtml并且前面三个参数可以分别和full做一个组合。
  • 6.1 json
# curl http://127.0.0.1/status?json
{"pool":"www","process manager":"dynamic","start time":1400078415,"start since":59624,"accepted conn":27,"listen queue":0,"max listen queue":8,"listen queue len":0,"idle processes":2,"active processes":1,"total processes":3,"max active processes":5,"max children reached":0,"slow requests":2145}
  • 6.2 xml
# curl http://127.0.0.1/status?xml
status>