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

时间:2019-01-29 09:18:00

标签: php bash monitoring fastcgi fpm

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

中的unix套接字

1 个答案:

答案 0 :(得分:3)

在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