Rumah  >  Artikel  >  pembangunan bahagian belakang  >  Ajar anda cara menggunakan status php-fpm untuk melihat maklumat terperinci

Ajar anda cara menggunakan status php-fpm untuk melihat maklumat terperinci

藏色散人
藏色散人ke hadapan
2021-12-09 16:26:006321semak imbas

status php-fpm boleh melihat maklumat ringkasan dan maklumat terperinci


fail konfigurasi nginx.conf

server {
    listen       80;
    server_name  localhost;

    index index.php index.html;
    root  /home/tinywan/zabbix;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        fastcgi_pass   unix:/var/run/php7.0.9-fpm.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    location /nginx_status {
          stub_status on;
          access_log off;
          allow 127.0.0.1;
          ##allow 192.168.249.0/24;
          deny all;
    }

    location ~ /php_fpm-status$ {
            allow 127.0.0.1;
            #deny all;
            fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
            include fastcgi_params;
            fastcgi_pass unix:/var/run/php7.0.9-fpm.sock;
    }
}

Dayakan fungsi status php-fpm

tinywan@tinywan:/opt/php-7.0.9$ cat /opt/php-7.0.9/etc/php-fpm.d/www.conf | grep status_path
;pm.status_path = /status

Secara lalai, ia adalah /status, tetapi sudah tentu ia boleh ditukar kepada yang lain, seperti /ttlsa_status, dsb.

vim /opt/php-7.0.9/etc/php-fpm.d/www.conf
pm.status_path = /php_fpm-status           #去掉了前面的;注释符,并更名为php_fpm-status

Selepas mengubah suai php-fpm.conf, gunakan perkhidmatan php-fpm reload untuk memuat semula fail konfigurasi

tinywan@tinywan:/opt/php-7.0.9$ sudo /opt/php-7.0.9/sbin/php-fpm
tinywan@tinywan:/opt/php-7.0.9$ ps -aux | grep php-fpm
root       2769  4.1  0.1 212532 14676 ?        Ss   09:50   0:00 php-fpm: master process (/opt/php-7.0.9/etc/php-fpm.conf)
tinywan    2770  3.2  0.1 212532 11084 ?        S    09:50   0:00 php-fpm: pool www
tinywan    2771  5.9  0.1 212532 11084 ?        S    09:50   0:00 php-fpm: pool www
tinywan    2773  0.0  0.0  15984   944 pts/21   S+   09:50   0:00 grep --color=auto php-fpm

Gunakan arahan curl untuk melihat status php-fpm

tinywan@tinywan:/usr/local/nginx$ curl localhost/php_fpm-status
pool:                 www
process manager:      dynamic
start time:           13/May/2017:09:50:43 +0800
start since:          986
accepted conn:        2
listen queue:         0
max listen queue:     0
listen queue len:     0
idle processes:       1
active processes:     1
total processes:      2
max active processes: 1
max children reached: 0
slow requests:        0

status php-fpm boleh melihat maklumat ringkasan dan maklumat terperinci Maklumat terperinci mempunyai lebih banyak maklumat tentang setiap proses php-fpm daripada maklumat ringkasan Ia juga menyokong output berbilang format, seperti xml , html dan json, secara lalai menggunakan arahan if masing-masing:

format json

tinywan@tinywan:~$ curl localhost/php_fpm-status?json
{"pool":"www","process manager":"dynamic","start time":1494640243,

"start since":1609,"accepted conn":13,"listen queue":0,"max listen queue":0,

"listen queue len":0,"idle processes":1,"active processes":1,"total processes":2,

"max active processes":1,"max children reached":0,"slow requests":0}

format xml

tinywan@tinywan:~$ curl localhost/php_fpm-status?xml
<?xml version="1.0" ?>
<status>
<pool>www</pool>
<process-manager>dynamic</process-manager>
<start-time>1494640243</start-time>
<start-since>1692</start-since>
<accepted-conn>15</accepted-conn>
<listen-queue>0</listen-queue>
<max-listen-queue>0</max-listen-queue>
<listen-queue-len>0</listen-queue-len>
<idle-processes>1</idle-processes>
<active-processes>1</active-processes>
<total-processes>2</total-processes>
<max-active-processes>1</max-active-processes>
<max-children-reached>0</max-children-reached>
<slow-requests>0</slow-requests>
</status>

Semua format:

Examples for summary status page:
http://127.0.0.1/php_fpm-status
http://127.0.0.1/php_fpm-status?json
http://127.0.0.1/php_fpm-status?html
http://127.0.0.1/php_fpm-status?xml

Example for detailed status page:
http://127.0.0.1/php_fpm-status?full
http://127.0.0.1/php_fpm-status?json&full
http://127.0.0.1/php_fpm-status?html&full
http://127.0.0.1/php_fpm-status?xml&full

Skrin skrin pelayar yang mengakses fail xml

Maksud status php-fpm

字段 含义
pool php-fpm pool的名称,大多数情况下为www
process manager 进程管理方式,现今大多都为dynamic,不要使用static
start time php-fpm上次启动的时间
start since php-fpm已运行了多少秒
accepted conn pool接收到的请求数
listen queue 处于等待状态中的连接数,如果不为0,需要增加php-fpm进程数
max listen queue 从php-fpm启动到现在处于等待连接的最大数量
listen queue len 处于等待连接队列的套接字大小
idle processes 处于空闲状态的进程数
active processes 处于活动状态的进程数
total processess 进程总数
max active process 从php-fpm启动到现在最多有几个进程处于活动状态
max children reached 当pm试图启动更多的children进程时,却达到了进程数的限制,达到一次记录一次,如果不为0,需要增加php-fpm pool进程的最大数
slow requests 当启用了php-fpm slow-log功能时,如果出现php-fpm慢请求这个计数器会增加,一般不当的Mysql查询会触发这个值

Atas ialah kandungan terperinci Ajar anda cara menggunakan status php-fpm untuk melihat maklumat terperinci. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!

Kenyataan:
Artikel ini dikembalikan pada:cnblogs.com. Jika ada pelanggaran, sila hubungi admin@php.cn Padam