柳暗花明笔记

    开启nginx和php-fpm监控 nginx_status,status

    所属分类:[ php&web ] 猫哲学家 发表于:2017-09-06 11:52 浏览:120

    php-fpm.conf 里添加:
    pm.status_path = /status

    在nginx的默认配置文件里添加:
    location /nginx_status {
    stub_status on;
    access_log off;
    }

    location /status {
    fastcgi_pass unix:/tmp/php-cgi.sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    }

    效果查看:

    http://127.0.0.1/nginx_status
    Active connections: 6
    server accepts handled requests
    1422259 1422259 2194619
    Reading: 0 Writing: 1 Waiting: 5


    http://127.0.0.1/status?full
    pool: www
    process manager: dynamic
    start time: 06/Sep/2017:11:36:50 +0800
    start since: 777
    accepted conn: 161
    listen queue: 0
    max listen queue: 0
    listen queue len: 0
    idle processes: 1
    active processes: 1
    total processes: 2
    max active processes: 2
    max children reached: 0

    ************************
    pid: 27415
    state: Running
    start time: 06/Sep/2017:11:36:50 +0800
    start since: 777
    requests: 80
    request duration: 525
    request method: GET
    request URI: /status?full
    content length: 0
    user: -
    script: /home/wwwroot/default/status
    last request cpu: 0.00
    last request memory: 0

    ************************
    pid: 27416
    state: Idle
    start time: 06/Sep/2017:11:36:50 +0800
    start since: 777
    requests: 81
    request duration: 361
    request method: GET
    request URI: /status?full
    content length: 0
    user: -
    script: /home/wwwroot/default/status
    last request cpu: 0.00
    last request memory: 524288


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

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

    标签: php  nginx 
    上一编文章 某种情况下,好用的 natsort 排序方法 下一编文章 技术人如何修炼内功
    最近文章
    发表评论