码迷,mamicode.com
首页 > 其他好文 > 详细

nginx更多信息监控

时间:2015-09-22 11:35:16      阅读:393      评论:0      收藏:0      [点我收藏+]

标签:


    ngx_req_status用来展示nginx请求状态信息,类似于apache的status,nginx自带的模块只能显示连接数等等信息,我们并不能知道到底有哪些请求、以及各url域名所消耗的带宽是多少。ngx_req_status提供了这些功能.


其功能特性:

(1)按域名、url、ip等等统计信息

(2)统计总流量

(3)统计当前带宽\峰值带宽

(4)统计总请求数量


安装:整个过程官网上也描述的比较清楚了。

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


但是实际安装过程中 始终无法编译通过,试了好几个版本,同时也在不同机器环境上做了测试但是都报了相同的错误。

../ngx_req_status//ngx_http_req_status_module.c: In function ?.gx_http_req_status_handler?.

../ngx_req_status//ngx_http_req_status_module.c:306:41: error: variable ?.p?.set but not used [-Werror=unused-but-set-variable]

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




nginx更多信息监控

标签:

原文地址:http://my.oschina.net/yjwxh/blog/509478

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!