View the status of php-fpm
Description: Like nginx, php-fpm has a built-in status page, which is very helpful for understanding the status of php-fpm and monitoring php-fpm
Step 1: Turn on pm.status_path in the php-fpm configuration file, the default is not turned on, remove the previous one; you can turn it on
pm.status_path = /status
Step 2: Add a redirected location to the server that needs to check the php-fpm status in nginx (the location is in addition to the url, because the url is used later to access the viewing status, other fastcgi configurations can be increased or decreased automatically, as long as it can be guaranteed nginx can connect with php-fpm )
location ~ /status {
root /data/web/;
fastcgi_pass fzjh; #The address and port are the same as those set in php_fpm, the upstream name is used here
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
Step 3: Restart nginx and php-fpm
Viewing method: You can enter the following url in the browser or curl + url under linux to view
The connection to view the status: Assuming that the location in the second step is set in a domain name called www.tp.com, then the access url is: www.tp.com/status
View the corresponding valid process using the url: www.tp.com/status?full
The viewed data is displayed in html: www.tp.com/status?html
The viewed data is displayed in json: www.tp.com/status?json
The meanings of the status fields viewed at www.tp.com/statusde are as follows:
pool – fpm pool name, mostly www
process manager – process management method, value: static, dynamic or ondemand.dynamic
start time - start date, if php-fpm is reloaded, the time will be updated
start since - how long to run
accepted conn - the number of requests accepted by the current pool
listen queue - request waiting queue, if this value is not 0, then the number of processes to increase the FPM
max listen queue – the highest number of requests to wait in the queue
listen queue len - socket wait queue length
idle processes – the number of idle processes
active processes – the number of active processes
total processes – the total number of processes
max active processes - the maximum number of active processes (counted from the start of FPM)
max children reached - The number of times the maximum number of avenue processes is limited. If this number is not 0, it means that your maximum number of processes is too small, please change it to a larger number.
slow requests - php-fpm slow-log enabled, the number of slow requests
View the corresponding valid process using the url: www.tp.com/status?full The meaning of the status field in the corresponding process is as follows:
pid - Process PID, you can kill this process alone. You can use this PID to kill a long running process.
state – the state of the current process (Idle, Running, …)
start time – the date the process was started
start since - how long the current process has been running
requests – how many requests are being processed by the current process
request duration – request duration (in micros)
request method – the request method (GET, POST, …)
request URI – request URI
content length – 请求内容长度 (仅用于 POST)
user – 用户 (PHP_AUTH_USER) (or ‘-’ 如果没设置)
script – PHP脚本 (or ‘-’ if not set)
last request cpu – 最后一个请求CPU使用率。
last request memorythe - 上一个请求使用的内存