ngx_http_stub_status_module模块说明

用于输出nginx的基本状态信息

Syntax:    stub_status;
Default:    —
Context:    server, location

输出信息示例:

Active connections: 291
server accepts handled requests #下面三个数分别对应accepts,handled,requests
16630948 16630948 31070465
Reading: 6 Writing: 179 Waiting: 106
Active connections:#当前状态,活动状态的连接数
accepts:#统计总值,已经接受的客户端请求的总数
handled:#统计总值,已处理完成的客户端请求总数,一般和accepts相同,除非拒绝
requests:#统计总值,客户端发来的总的请求数
Reading:#当前状态,正在读取客户端请求报文首部的连接的连接数
Writing:#当前状态,正在向客户端发送响应报文过程中的连接数
Waiting:#当前状态,正在等待客户端发出请求的空闲连接数

测试实例

实验环境

[root@node1 ~]# uname -r
3.10.0-957.el7.x86_64
[root@node1 ~]# cat /etc/redhat-release 
CentOS Linux release 7.6.1810 (Core) 
[root@node1 ~]# nginx -V
nginx version: nginx/1.16.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) 
built with OpenSSL 1.0.2k-fips  26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --user=www --group=www --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_module

ip: 10.0.0.101

实验要求

配置ngx_http_stub_status_module模块输.
在10.0.0.102上访问nginx状态信息

nginx安装部署位nginx-1.16.0的源码安装,详细见《nginx的安装部署》

虚拟主机配置

server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }
        #配置nginx的状态信息页面
        location /status {
            stub_status;
          
        }
        
 

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

重新加载配置文件

[root@node1 ~]# nginx -t
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
[root@node1 ~]# nginx -s reload

在10.0.0.102上测试

[root@node2 ~]# ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.0.102  netmask 255.0.0.0  broadcast 10.255.255.255


[root@node2 ~]# curl 10.0.0.101/status
Active connections: 1 
server accepts handled requests
 13 13 19 
Reading: 0 Writing: 1 Waiting: 0 

测试完成!!!

posted @ 2020-09-11 11:22  yaowx  阅读(935)  评论(0编辑  收藏  举报