nginx系列(十三)nginx下的监控模块

nginx里面,默认监控模块是不安装的要自行安装才可以。
安装命令:关键是(--with-http_stub_status_module)
./configure --prefix=/opt/nginx/nginx-1.9.5   --with-http_stub_status_module
make -j4
make install -j4


增加配置:
location /nginx_status {
    # Turn on nginx stats
    stub_status on;
    # I do not need logs for stats
    access_log   off;
    # Security: Only allow access from 192.168.1.100 IP
    allow 192.168.56.0/24;
    allow 172.19.136.0/24; #pc
    allow 172.19.137.0/24; #wifi
    # Send rest of the world to /dev/null #
    deny all;
    }

其中访问策略配置很关键,否则这个技术等于垃圾,公网访问安全性会很差。前面的IP表示网段,斜杠后面的24表示子网。细节请大家自行学习,或者跟帖交流。

访问监控地址:返回如下:
Active connections: 70
server accepts handled requests
14553819 14553819 19239266
Reading: 0 Writing: 3 Waiting: 67

NginxStatus 显示的内容意思如下:
active connections – 当前 Nginx 正处理的活动连接数。
server accepts handled requests -- 总共处理了 14553819 个连接 , 成功创建 14553819 次握手 ( 证明中间没有失败的 ), 总共处理了 19239266 个请求 ( 平均每次握手处理了 1.3 个数据请求 )。
reading -- nginx 读取到客户端的 Header 信息数。
writing -- nginx 返回给客户端的 Header 信息数。
waiting -- 开启 keep-alive 的情况下,这个值等于 active - (reading + writing),意思就是 Nginx 已经处理完正在等候下一次请求指令的驻留连接。

参考文章
请求返回参数含义
http://www.ibm.com/developerworks/cn/web/wa-lo-nginx/
安装参考
http://www.cnblogs.com/94cool/p/3872492.html
allow和deny
http://www.111cn.net/sys/nginx/63713.htm
子网划分
http://zhidao.baidu.com/link?url=av8E4A20cMw6VYBb-1JRHFnOnoPpATuPs2pTR64dSsLs2XJ-d2UOeqEB_wWL0L21BiA5x17gs3Iugl8Eq8yCCa

猜你喜欢

转载自phl.iteye.com/blog/2251017