ngx_req_status用來展現nginx請求狀態信息,相似於apache的status,nginx自帶的模塊只能顯示鏈接數等等信息,咱們並不能知道到底有哪些請求、以及各url域名所消耗的帶寬是多少。ngx_req_status提供了這些功能.css
其功能特性:html
(1)按域名、url、ip等等統計信息nginx
(2)統計總流量apache
(3)統計當前帶寬\峯值帶寬api
(4)統計總請求數量測試
安裝:整個過程官網上也描述的比較清楚了。ui
wget "http://nginx.org/download/nginx-1.3.5.tar.gz" tar -xzvf nginx-1.3.5.tar.gz cd nginx-1.3.5/ patch -p1 < /path/to/ngx_req_status/write_filter-VERSION.patch ./configure --prefix=/usr/local/nginx \ --add-module=/path/to/ngx_req_status make -j2 make install
可是實際安裝過程當中 始終沒法編譯經過,試了好幾個版本,同時也在不一樣機器環境上作了測試可是都報了相同的錯誤。url
../ngx_req_status//ngx_http_req_status_module.c: In function ?.gx_http_req_status_handler?.spa
../ngx_req_status//ngx_http_req_status_module.c:306:41: error: variable ?.p?.set but not used [-Werror=unused-but-set-variable]code
cc1: all warnings being treated as errors
make[1]: *** [objs/addon/ngx_req_status/ngx_http_req_status_module.o] Error 1
make[1]: Leaving directory `/usr/local/src/nginx-1.4.2'
make: *** [build] Error 2
最終經過萬能百度的幫助解決了:
修改 objs/Makefile 去除文件中的 -Werror
從新編譯 OK
配置nginx.conf
啓用ngx_req_status
http {
req_status_zone server_name $server_name 256k;
req_status_zone server_addr $server_addr 256k;
req_status_zone server_url $server_name$uri 256k;
req_status server_name server_addr server_url;
server {
server_name localhost;
location /req-status {
req_status_show on;
}
}
}
測試:
zone_name key max_active max_bw traffic requests active bandwidth server_addr 172.16.25.197 99 12M 195M 3243 2 266K server_name localhost 99 12M 195M 3243 2 266K server_url localhost/ 1 55K 437K 7 0 0 server_url localhost/50x.html 1 0 293K 14 0 0 server_url localhost/aggregators 1 9760 75K 7 0 0 server_url localhost/api/put 2 565K 14M 1321 0 34K server_url localhost/api/query 99 244K 21M 471 0 0 server_url localhost/api/uid/tsmeta 3 4M 77M 1142 0 18K server_url localhost/favicon.ico 1 268K 5M 86 0 65K server_url localhost/nginx_status 1 0 71K 6 0 0 server_url localhost/req-status 2 341K 7M 152 2 122K server_url localhost/s/D8B88BDFA9330E29B3DF79564AD522C2.cache.html 1 5M 30M 3 0 0 server_url localhost/s/E1458A159371228D537FF6556C2AF8CE.cache.html 1 3M 30M 3 0 0 server_url localhost/s/gwt/standard/images/corner.png 1 55K 376K 6 0 0 server_url localhost/s/gwt/standard/images/hborder.png 1 66K 444K 6 0 0 server_url localhost/s/gwt/standard/images/vborder.png 1 11K 90K 6 0 0 server_url localhost/s/gwt/standard/standard.css 1 1M 7M 6 0 0 server_url localhost/s/queryui.nocache.js 1 250K 2M 7 0 0