CentOS 6.x 開啟Nginx和Php-fpm狀態統計
Nginx和PHP-FPM都在安裝的時候建立了一個狀態頁,用於統計Nginx和PHP-FPM的相關狀態資訊。下面介紹一下如何開啟Nginx和PHP-FPM的狀態統計,以及介紹各引數的含義。
(一)開啟Nginx的狀態統計以及各引數詳解
在/etc/nginx/conf.d/(根據自己的Nginx路徑)中建立nginx_status.conf,並新增如下內容:
[root@iZ256vh2adfZ conf.d] # cat nginx_status.conf server { listen 80; server_name 127.0.0.1; location /nginx_status { stub_status on; access_log off; #allow 127.0.0.1; #deny all; } }
|
重啟Nginx:
[root@iZ256vh2adfZ vhost] # /etc/init.d/nginx restart nginx: the configuration file /usr/local/nginx/conf/nginx .conf syntax is ok nginx: configuration file /usr/local/nginx/conf/nginx .conf test is successful Stopping nginx: [ OK ] Starting nginx: [ OK ]
|
測試:
[root@iZ256vh2adfZ conf.d] # curl 127.0.0.1:80/nginx_status Active connections: 4 server accepts handled requests 8 8 12 Reading: 0 Writing: 1 Waiting: 3
|
(二)開啟PHP-FPM的狀態統計以及各引數詳解
開啟php-fpm.conf開用php-fpm狀態功能:
vim php-fpm.conf:
pm.status_path = /phpfpm_status
預設情況下為/status,當然也可以改成/php_status等,我這裡是改成/php_status啦
vim /etc/nginx/conf.d/php_fpm_status.conf
server {
listen 80;
server_name 127.0.0.1;
location /php_status {
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
#allow x.x.x.x;
access_log off;
#deny all;
}
}
重啟Nginx、PHP-FPM。
測試:
[root@iZ256vh2adfZ conf.d]# curl
pool: www
process manager: dynamic
start time: 25/Feb/2017:10:27:57 +0800
start since: 7
accepted conn: 1
listen queue: 0
max listen queue: 0
listen queue len: 128
idle processes: 4
active processes: 1
total processes: 5
max active processes: 1
max children reached: 0
slow requests: 0
PHP-FPM status狀態詳解:
pool – fpm池子名稱,大多數為wwwprocess manager – 程式管理方式,值:static, dynamic or ondemand. dynamicstart 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,緩慢請求的數量
nginx、php-fpm狀態頁可以透過帶引數實現個性化,可以帶引數json、xml、html並且前面三個引數可以分別和full做一個組合,下面以php-fpm status為例:
(1)json格式:
[root@iZ25fueqyvvZ vhost]# curl ?json
{"pool":"www","process manager":"dynamic","start time":1487989605,"start since":3187,"accepted conn":179,"listen queue":0,"max listen queue":0,"listen queue len":128,"idle processes":14,"active processes":1,"total processes":15,"max active processes":5,"max children reached":0}
(2)xml格式:
[root@iZ25fueqyvvZ vhost]# curl ?xml
(3)html格式:
[root@iZ25fueqyvvZ vhost]# curl ?html
pool | www |
---|---|
process manager | dynamic |
start time | 25/Feb/2017:10:26:45 +0800 |
start since | 3272 |
accepted conn | 186 |
listen queue | 0 |
max listen queue | 0 |
listen queue len | 128 |
idle processes | 14 |
active processes | 1 |
total processes | 15 |
max active processes | 5 |
max children reached | 0 |
(4)full格式:
[root@iZ25fueqyvvZ vhost]# curl ?full
pool: www
process manager: dynamic
start time: 25/Feb/2017:10:26:45 +0800
start since: 3341
accepted conn: 188
listen queue: 0
max listen queue: 0
listen queue len: 128
idle processes: 14
active processes: 1
total processes: 15
max active processes: 5
max children reached: 0
************************
pid: 4496
state: Idle
start time: 25/Feb/2017:10:26:45 +0800
start since: 3341
requests: 13
request duration: 13932
request method: POST
request URI: /managerlogin/index.php?ctl=default&act=status
content length: 0
user: -
script: /data/website/index.php
last request cpu: 71.78
last request memory: 5767168
此處省略了很多個PID!
full格式詳解:
pid – 程式PID,可以單獨kill這個程式.state – 當前程式的狀態 (Idle, Running, …)start time – 程式啟動的日期start since – 當前程式執行時長requests – 當前程式處理了多少個請求request duration – 請求時長(微妙)request method – 請求方法 (GET, POST, …)request URI – 請求URIcontent length – 請求內容長度 (僅用於 POST)user – 使用者 (PHP_AUTH_USER) (or ‘-’ 如果沒設定)script – PHP指令碼 (or ‘-’ if not set)last request cpu – 最後一個請求CPU使用率。last request memorythe - 上一個請求使用的記憶體
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/2249/viewspace-2803114/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- centos php-fpm nginx配置CentOSPHPNginx
- 【PHP】啟用php-fpm狀態詳解PHP
- centos7重啟apache、nginx、mysql、php-fpm命令CentOSApacheNginxMySqlPHP
- Nginx PHP-FPM and MySQL on CentOS 5NginxPHPMySqlCentOS
- 配置 nginx location 實時檢視 php-fpm 的狀態NginxPHP
- PHP-FPM和nginx配置PHPNginx
- 系統狀態統計和檢視
- CentOS6.3下nginx、php-fpm、drupal快速部署CentOSNginxPHP
- 統計TCP連線數和狀態TCP
- Linux CentOS7 系統中部署 Nginx + PHP-fpm + MySQL 環境LinuxCentOSNginxPHPMySql
- 雲伺服器CentOS 6.X 系統更改核心啟動順序伺服器CentOS
- CentOS8檢視防火牆狀態,開啟/關閉防火牆CentOS防火牆
- nginx 和 PHP-fpm 的互動NginxPHP
- PHP-fpm + nginxPHPNginx
- centos 6.x 7.x防火牆開啟埠範圍IP地址 配置CentOS防火牆
- Centos安裝PHP7及配置php-fpm開機啟動CentOSPHP
- nginx狀態資訊頁面Nginx
- 判斷Nginx存活狀態Nginx
- mac系統,php-fpm加入開機啟動項MacPHP
- centos 6.x 安裝 gogsCentOSGo
- CentOS 6.x 升級 GitCentOSGit
- 系統設計架構:有狀態與無狀態架構
- 監控Nginx的工作狀態Nginx
- Nginx服務狀態監控Nginx
- centos下nginx啟動、重啟、關閉CentOSNginx
- 開啟nginx狀態監控,檢視web伺服器的併發連線數NginxWeb伺服器
- iOS-OC-監聽藍芽是否開啟(開啟狀態)iOS藍芽
- nginx + PHP-fpm 配置示例NginxPHP
- centos6.5伺服器安裝Nginx設定服務和開機自啟CentOS伺服器Nginx
- SAP Fiori和WebClient UI的有狀態和無狀態行為設計原理WebclientUI
- centos:開啟和關閉selinuxCentOSLinux
- CentOS系統安裝NginxCentOSNginx
- CentOS 6.X怎麼更改網路卡名稱?CentOS 6.X更改網路卡名稱的方法CentOS
- CentOS7 nginx啟動指令碼CentOSNginx指令碼
- Centos7啟動Nginx報錯。CentOSNginx
- Mac下Nginx、PHP、MySQL 和 PHP-fpm安裝配置MacNginxPHPMySql
- CentOS 7 下安裝PHP環境並且配置Nginx支援php-fpm模組CentOSPHPNginx
- 架構設計(五):有狀態服務和無狀態服務架構