1. MagicESP
  2. Ubuntu Server 22.04
  3. Monitor PHP-FPM Performance

Monitor PHP-FPM Performance

monitor php-fpm that listen to linux socket is a bit complicated.

install libfcgi0ldbl

sudo apt install libfcgi0ldbl

create bash script

sudo {{ texteditor.value }} ~/php-fpm-status.sh
#!/bin/bash
 
LISTEN=$1
 
export SCRIPT_NAME=/status
export SCRIPT_FILENAME=/status
 
if <a class="red-text disabled"></a>
then
        export QUERY_STRING+="full&"
fi
if <a class="red-text disabled"></a>
then
        export QUERY_STRING+="json&"
fi
 
export REQUEST_METHOD=GET
 
CGI2FCGI=/usr/bin/cgi-fcgi
 
if [ ! -x ${CGI2FCGI} ]
then
        echo "cgi-fcgi does not appear to be installed:"
        echo -e "\t* On debian this can be installed with: $ sudo apt-get install libfcgi0ldbl\n"
        exit 1
fi
 
if [ ! -S ${LISTEN} ]
then
        echo "${LISTEN} does not appear to be a socket"
        exit 1
fi
 
${CGI2FCGI} -bind -connect ${LISTEN}

execute permission

chmod u+x php-fpm-status.sh

modify php-fpm config

sudo {{ texteditor.value }} /etc/php/7.0/fpm/pool.d/www.conf
pm.status_path = /status

restart php-fpm config

sudo /etc/init.d/php7.0-fpm restart

monitor php-fpm

sudo ./php-fpm-status.sh /var/run/php/php7.0-fpm.sock

sample output

Expires: Thu, 01 Jan 1970 00:00:00 GMT
Cache-Control: no-cache, no-store, must-revalidate, max-age=0
Content-type: text/plain;charset=UTF-8

pool:                 www
process manager:      dynamic
start time:           27/Nov/2016:05:11:36 +0000
start since:          512
accepted conn:        3
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