stub_status监控Nginx使用情况!

stub_status监控Nginx使用情况!

查看nginx安装的模块!

# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.8.1
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC) 
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module

有安装这个模块哦!
配置,

server{
        listen 80;
        index index.html index.htm index.php;
		server_name xxx.com;
        root  /home/wwwroot/default/sheep/Public;
	
        location /nginx_status {
                stub_status on;
        		access_log off;
                allow all;
        }

        include enable-php-pathinfo.conf;

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /\.
        {
            deny all;
        }

        access_log  /home/wwwlogs/sheep/access.log  main;
}

查看结果,在浏览器中查看!

http://www.xxx.com/nginx_status
Active connections: 132 
server accepts handled requests
 1576 1576 2334 
Reading: 0 Writing: 3 Waiting: 129 

第一行
    当前的活跃连接数:132 #等于 Reading + Writing + Waiting
第二行
    服务器已接受的连接数:1576(accepted connection #),已接收来自客户端的连接数,也是被Worker进程接收的连接数。
    服务器已处理的连接数:1576(handled connection #),已被处理的连接总数,其值一般与accepts相等,除非受到了某些资源的限制,如:设置了worker_connections的数量限制。
    服务器已处理的请求:2334(可以算出,平均每个连接有 1.48 个请求)(handled connection #)
第三行
    Reading – Nginx 正在读取请求头的连接数为 0;
    Writing – Nginx 正在读取请求体、处理请求并发送响应给客户端的连接数为 3;
    Waiting – 当前活动的长连接数:129。 #只是keep-alive,没有活动的连接。

posted @ 2019-05-09 15:20  TBHacker  阅读(485)  评论(0编辑  收藏  举报