您的位置:首页 > 理论基础 > 计算机网络

NGINX服务器工作状态NGX_HTTP_STUB_STATUS_MODULE 模块

2015-12-09 13:28 1126 查看
NGINX服务器工作状态NGX_HTTP_STUB_STATUS_MODULE 模块
ngx_http_stub_status_module
这个模块能够获取Nginx自上次启动以来的工作状态
此模块非核心模块,需要在编译的时候手动添加编译参数 –with-http_stub_status_module
./configure –with-http_stub_status_module
配置说明
location /nginx_status {
stub_status on;
access_log off;
allow SOME.IP.ADD.RESS;
deny all;
}
或配置成认证:
location /nginx_status {
stub_status on;
access_log off;
auth_basic “nginx_status”;
auth_basic_user_file conf/htpasswd;
}
其中htpasswd,可用apache htpasswd工具生成或者用在线生成工具生成
指令:stub_status
语法: stub_status on
默认值: None
作用域: location
创建一个 location 区域启用 stub_status
“stub status” 模块返回的状态信息跟 mathopd’s 的状态信息很相似. 返回的状态信息如下:
Active connections: 291
server accepts handled requests
16630948 16630948 31070465
Reading: 6 Writing: 179 Waiting: 106
active connections — 对后端发起的活动连接数
server accepts handled requests — nginx 总共处理了 16630948 个连接, 成功创建 16630948 次握手 (证明中间没有失败的), 总共处理了 31070465 个请求 (平均每次握手处理了 1.8个数据请求)
reading — nginx 读取到客户端的Header信息数
writing — nginx 返回给客户端的Header信息数
waiting — 开启 keep-alive 的情况下,这个值等于 active – (reading + writing),意思就是Nginx说已经处理完正在等候下一次请求指令的驻留连接
POSTED ON 2011-11-15 11:27 小马歌 阅读(1385) 评论(0) 编辑 收藏 所属分类: WEB SERVER

1 编译nginx,加上参数 --with-http_stub_status_module以我自己的编译选项为例:
#配置指令
./configure --prefix=/usr/local
--user=nginx
--group=nginx
--with-http_ssl_module
--with-http_realip_module
--http-client-body-temp-path=/usr/local/var/tmp/nginx/client
--http-proxy-temp-path=/usr/local/var/tmp/nginx/proxy
--http-fastcgi-temp-path=/usr/local/var/tmp/nginx/fcgi
--http-scgi-temp-path=/usr/local/var/tmp/nginx/scgi
--http-uwsgi-temp-path=/usr/local/var/tmp/nginx/uwsgi
--with-http_geoip_module
--with-http_stub_status_module
2 修改nginx配置文件,添加监控状态配置在nginx.conf的server块中添加如下代码
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.1.100;
# Send rest of the world to /dev/null #
#deny all;
}
这段代码是加在默认的server里的, 假设默认server的配置为
listen 127.0.0.1:80;
server_name 127.0.0.1;
那么访问nginx的状态,就可以通过 curl 127.0.0.1/nginx_status访问了返回结果类似于:
Active connections: 1
server accepts handled requests
655 655 1985
Reading: 0 Writing: 1 Waiting: 0
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息