1. 啓用 php-fpm 狀態功能php
修改 php-fpm.conf 文件,若是沒有則建立此文件. 在文件夾: php/etc 目錄下建立.
pm.status_path=/status listen = 9000 #此處是監聽 status 的端口, 能夠自定義, 要跟等會在 nginx 中配置的一致.
2. nginx配置html
在要監控的主機裏添加上 locaction.nginx
location ~^/(status|ping)$ { include fastcgi_params; fastcgi_pass 127.0.0.1:9000; #對應 php-fpm 裏的配置 fastcgi_param SCRIPT_FILENAME $fastcgi_script_name; }
3. 重啓 nginx 和php-fpmjson
service nginx restart service php-fpm restart
**4. 打開 status 頁面 **瀏覽器
在瀏覽器裏打開或者用 curl 命令打開均可以 http://127.0.0.1/status
//若是你的 nginx 默認端口是80的話curl
pool: www process manager: dynamic start time: 10/Nov/2015:16:36:48 +0800 start since: 1859 accepted conn: 3 listen queue: 0 max listen queue: 0 listen queue len: 128 idle processes: 19 active processes: 1 total processes: 20 max active processes: 1 max children reached: 0 slow requests: 0
5. php-fpm status 詳解socket
pool – fpm池子名稱,大多數爲www process manager – 進程管理方式,值:static, dynamic or ondemand. dynamic start time – 啓動日期,若是reload了php-fpm,時間會更新 start since – 運行時長 accepted conn – 當前池子接受的請求數 listen queue – 請求等待隊列,若是這個值不爲0,那麼要增長FPM的進程數量 max listen queue – 請求等待隊列最高的數量 listen queue len – socket等待隊列長度 idle processes – 空閒進程數量 active processes – 活躍進程數量 total processes – 總進程數量 max active processes – 最大的活躍進程數量(FPM啓動開始算) max children reached - 大道進程最大數量限制的次數,若是這個數量不爲0,那說明你的最大進程數量過小了,請改大一點。 slow requests – 啓用了php-fpm slow-log,緩慢請求的數量
**6. php-fpm 其餘參數 **php-fpm
php-fpm狀態頁比較個性化的一個地方是它能夠帶參數,能夠帶參數json、xml、html而且前面三個參數能夠分別和full作一個組合。 http://127.0.0.1/status?html http://127.0.0.1/status?xml http://127.0.0.1/status?json http://127.0.0.1/status?full full詳解: pid – 進程PID,能夠單獨kill這個進程. You can use this PID to kill a long running process. state – 當前進程的狀態 (Idle, Running, …) start time – 進程啓動的日期 start since – 當前進程運行時長 requests – 當前進程處理了多少個請求 request duration – 請求時長(微妙) request method – 請求方法 (GET, POST, …) request URI – 請求URI content length – 請求內容長度 (僅用於 POST) user – 用戶 (PHP_AUTH_USER) (or ‘-’ 若是沒設置) script – PHP腳本 (or ‘-’ if not set) last request cpu – 最後一個請求CPU使用率。 last request memorythe - 上一個請求使用的內存