如何通过 CLI 或纯 FastCGI 获取 PHP-FPM 状态

How to get PHP-FPM status via CLI or pure FastCGI

我想通过 CLI 获取 PHP-FPM /status?full 页面。在一个命令中,或使用 bash 脚本,我需要显示 PHP 进程管理器可以 return 但不使用 nginx 或 apache 的最详细的输出。我正在使用位于 /var/run/php5.6-fpm.sock

的 unix 套接字

在 debian 中,您可以使用这些命令:

sudo apt install -y libfcgi0ldbl
sudo -u www-data SCRIPT_NAME=/status \
                 SCRIPT_FILENAME=/status \
                 QUERY_STRING=full \
                 REQUEST_METHOD=GET \
                 cgi-fcgi -bind -connect /var/run/php5.6-fpm.sock

这是输出

pool:                 www
process manager:      ondemand
start time:           21/Jul/2017:11:44:35 +0200
start since:          48122714
accepted conn:        23412055
listen queue:         0
max listen queue:     0
listen queue len:     0
idle processes:       1
active processes:     1
total processes:      2
max active processes: 5
max children reached: 622
slow requests:        0

************************
pid:                  21554
state:                Idle
start time:           29/Jan/2019:09:55:19 +0100
start since:          870
requests:             171
request duration:     109
request method:       GET
request URI:          -?full
content length:       0
user:                 -
script:               -
last request cpu:     0.00
last request memory:  2097152

************************
pid:                  20633
state:                Running
start time:           29/Jan/2019:09:24:04 +0100
start since:          2745
requests:             563
request duration:     122
request method:       GET
request URI:          /status?full
content length:       0
user:                 -
script:               -
last request cpu:     0.00
last request memory:  0