PHP-FPMには、Apacheやnginx同様、プロセス数などが見られるステータスページが用意されている。
以下のようにすると見られる。
PHP-FPM側の設定
以下のようにコメントアウトする
/etc/php-fpm.d/www.conf
pm.status_path = /phpfpm_status
nginx側の設定
以下のように、うえで書いたlocationを渡せばOK
/etc/nginx/conf.d/default.conf
server {
listen 80 default_server;
server_name _;
location /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
}
確認する
curl http://localhost/nginx_status curl http://localhost/nginx_status?full # フルバージョン curl http://localhost/nginx_status?json # JSON版 jqとかに渡せば簡単に処理できそう
例
[koni@localhost ~]$ curl 'http://localhost/phpfpm_status' pool: www process manager: dynamic start time: 12/Jan/2016:18:18:13 +0900 start since: 1087 accepted conn: 63 listen queue: 0 max listen queue: 0 listen queue len: 128 idle processes: 6 active processes: 1 total processes: 7 max active processes: 3 max children reached: 0 slow requests: 0
listen queue: ペンディングとなっているコネクションのキューの数。0でない場合はもう少しプロセスを増やした方がいい max listen queue: FPMを起動してからのlisten queueの最大値。0でない場合はもう少しプロセスを増やした方がいい
nginxのステータスページ
ついでに、nginxのステータスページは以下で追加できる。
server {
listen 80 default_server;
server_name _;
location /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
}
例
[koni@localhost ~]$ curl 'http://localhost/nginx_status?full' Active connections: 1 server accepts handled requests 112 112 309 Reading: 0 Writing: 1 Waiting: 0