zoukankan      html  css  js  c++  java
  • 解读

    Nginx-解读内置非默认模块 ngx_http_stub_status_module

    1.Background

      ngx_http_stub_status_module 是一个 Nginx 的内置 HTTP 模块,该模块可以提供 Nginx 的状态信息。默认情况下这个模块是不被编译进来的,所以在编译 Nginx 时要指定加载该模块:

    --with-http_stub_status_module

      当然了,如果你是重新编译,仅仅-s reload是不够的,可能需要用到平滑升级:《高性能Web服务器Nginx的配置与部署研究(14)平滑升级你的Nginx》。

      为什么拿它做例子?因为它也是个足够短小精悍的模块,是一个典型 handler 模块。那么以后我们讲解模块的过程,都是:

      1).简要的介绍
      2).使用的实例
      3).指令介绍
      4).源码分析

    2.Simple example

    复制代码
    location /nginx_status {
        #copied from http://blog.kovyrin.net/2006/04/29/monitoring-nginx-with-rrdtool/
        stub_status on;
        access_log off;
        allow SOME.IP.ADD.RESS;
        deny all;
    }
    复制代码

      我们假设你是在本机上实验,并且开启的是 80 端口,那么在浏览器中输入:http://localhost/nginx_status 会看到这样的信息:

    Active connections: 291
    server accepts handled requests
    16630948 16630948 31070465
    Reading: 6 Writing: 179 Waiting: 106

      其含义很容易理解:

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


      Nginx 官方的解释如下:

        active connections – number of all open connections
        server accepts handled requests – nginx accepted 16630948 connections, handled 16630948 connections (no one was closed just it was accepted), and handles 31070465 requests (1.8 requests per connection)
        reading – nginx reads request header
        writing – nginx reads request body, processes request, or writes response to a client
        waiting – keep-alive connections, actually it is active - (reading + writing)

    3 Directives

      这个模块中的唯一一个指令,是:

    stub_status

      语法:stub_status on
      作用域:location
      功能:统计这个 location 的信息。

  • 相关阅读:
    [导入]【翻译】WF从入门到精通(第十三章):打造自定义活动
    [导入]关于网页标准与JAVAScript执行的问题
    html包含html文件的方法
    [导入]C#加密方法汇总
    8、步步为营VS 2008 + .NET 3.5(8) DLINQ(LINQ to SQL)之面向对象的添加、查询、更新和删除
    [导入]【翻译】WF从入门到精通(第十五章):工作流和事务
    [导入]存储过程得到某个表的所有字段信息
    1、步步为营VS 2008 + .NET 3.5(1) VS 2008新特性之Multi Targeting(多定向)、Web Designer and CSS(集成了CSS的web设计器)和Nested Master Page(嵌套母版页)
    [导入]vbs修改注册表
    正则表达式30分钟入门教程
  • 原文地址:https://www.cnblogs.com/justart/p/7767689.html
Copyright © 2011-2022 走看看