-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1127 from hongxiaolong/mod_debug_conn
add ngx_debug_conn to show connection usage.
- Loading branch information
Showing
5 changed files
with
595 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
ngx_debug_conn | ||
============== | ||
|
||
该模块可以提供NGINX/Tengine连接的状态信息。 | ||
|
||
示例 | ||
======= | ||
|
||
获取NGINX/Tengine连接的状态信息 | ||
--------------------------------- | ||
|
||
``` | ||
http { | ||
server { | ||
listen 80; | ||
|
||
location = /debug_conn { | ||
debug_conn; | ||
} | ||
} | ||
} | ||
``` | ||
|
||
请求URI /debug_conn,可以获取到该NGINX/Tengine连接的使用情况统计。 | ||
页面输出如下: | ||
|
||
``` | ||
$ curl 'localhost:80/debug_conn' | ||
pid:70568 | ||
connections:3 | ||
--------- [1] -------- | ||
conns[i]: 0 | ||
fd: 6 | ||
addr: 0.0.0.0:80 | ||
sent: 0 | ||
action: (null: listening) | ||
handler: r:000000010DAEBEC0 w:0000000000000000 | ||
requests: 0 | ||
poolsize: 0 | ||
--------- [2] -------- | ||
conns[i]: 1 | ||
fd: 7 | ||
addr: (null) | ||
sent: 0 | ||
action: (null: channel) | ||
handler: r:000000010DAFB770 w:0000000000000000 | ||
requests: 0 | ||
poolsize: 0 | ||
--------- [3] -------- | ||
conns[i]: 2 | ||
fd: 3 | ||
addr: 127.0.0.1 | ||
sent: 0 | ||
action: (null) | ||
handler: r:000000010DB28CA0 w:000000010DB28CA0 | ||
requests: 1 | ||
poolsize: 0 | ||
********* request ****** | ||
uri: http://localhost/debug_conn | ||
handler: r:000000010DB26820 w:000000010DB29770 | ||
startsec: 1542356262 | ||
poolsize: 0 | ||
``` | ||
|
||
连接的使用情况统计 | ||
----------------------------------- | ||
|
||
数据说明 | ||
==== | ||
|
||
每个数据段落如"[1]"包含当前标号对应连接的状态信息,数据项意义如下: | ||
|
||
* __conns__: 当前连接标号,用于信息统计 | ||
* __fd__: 当前连接的句柄号 | ||
* __addr__: 当前连接的监听地址 | ||
* __sent__: 当前连接的已发送数据量 | ||
* __action__: 当前连接的log action | ||
* __handler__: 当前连接的读写事件挂载handler地址,配合addr2line来查询对应函数 | ||
* __requests__: 当前连接上的请求量 | ||
* __poolsize__: 当前连接的内存池大小 | ||
* __request__: 当前连接上的请求 | ||
* __uri__: 当前连接上的请求的请求地址 | ||
* __handler__: 当前连接上的请求的读写事件挂载handler地址,配合addr2line来查询对应函数 | ||
* __startsec__: 当前连接上的请求的起始时间戳 | ||
* __poolsize__: 当前连接上的请求的内存池大小 | ||
|
||
NGINX兼容性 | ||
=================== | ||
|
||
* 1.13.4 (stable version of 1.13.x) 及其更高版本 | ||
|
||
Tengine兼容性 | ||
===================== | ||
|
||
* 2.1.1 (stable version of 2.1.x) 及其更高版本 | ||
|
||
安装说明 | ||
======= | ||
|
||
源码安装,执行如下命令: | ||
|
||
``` | ||
$ wget http://nginx.org/download/nginx-1.13.4.tar.gz | ||
$ tar -xzvf nginx-1.13.4.tar.gz | ||
$ cd nginx-1.13.4/ | ||
$ ./configure --add-module=/path/to/ngx_debug_conn | ||
$ make -j4 && make install | ||
``` | ||
|
||
|
||
配置指令 | ||
========= | ||
|
||
语法: **debug_conn** | ||
|
||
默认: `none` | ||
|
||
位置: `server, location` | ||
|
||
NGINX/Tenigne的连接状态信息可以通过该location访问得到。 | ||
|
||
注意信息 | ||
========= | ||
|
||
``` | ||
********* request ****** | ||
``` | ||
|
||
request数据段落仅在当前连接上有请求存在时展示 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
ngx_debug_conn | ||
============== | ||
|
||
This module provides access to information of connection usage for nginx/tengine. | ||
|
||
Example | ||
======= | ||
|
||
Get information of connection usage. | ||
--------------------------------- | ||
|
||
``` | ||
http { | ||
server { | ||
listen 80; | ||
location = /debug_conn { | ||
debug_conn; | ||
} | ||
} | ||
} | ||
``` | ||
|
||
Requesting URI /debug_conn, you will get information of connection usage for nginx/tengine. | ||
The output page may look like as follows: | ||
|
||
``` | ||
$ curl 'localhost:80/debug_conn' | ||
pid:70568 | ||
connections:3 | ||
--------- [1] -------- | ||
conns[i]: 0 | ||
fd: 6 | ||
addr: 0.0.0.0:80 | ||
sent: 0 | ||
action: (null: listening) | ||
handler: r:000000010DAEBEC0 w:0000000000000000 | ||
requests: 0 | ||
poolsize: 0 | ||
--------- [2] -------- | ||
conns[i]: 1 | ||
fd: 7 | ||
addr: (null) | ||
sent: 0 | ||
action: (null: channel) | ||
handler: r:000000010DAFB770 w:0000000000000000 | ||
requests: 0 | ||
poolsize: 0 | ||
--------- [3] -------- | ||
conns[i]: 2 | ||
fd: 3 | ||
addr: 127.0.0.1 | ||
sent: 0 | ||
action: (null) | ||
handler: r:000000010DB28CA0 w:000000010DB28CA0 | ||
requests: 1 | ||
poolsize: 0 | ||
********* request ****** | ||
uri: http://localhost/debug_conn | ||
handler: r:000000010DB26820 w:000000010DB29770 | ||
startsec: 1542356262 | ||
poolsize: 0 | ||
``` | ||
|
||
Get information of connection usage | ||
----------------------------------- | ||
|
||
Data | ||
==== | ||
|
||
Every block like "[1]" except the related connection usage as follows: | ||
|
||
* __conns__: sequence of current connection | ||
* __fd__: file description of current connection | ||
* __addr__: listening address of current connection | ||
* __sent__: data sent size of current connection | ||
* __action__: log action of current connection | ||
* __handler__: read/write event handler of current connection, use addr2line to find the real function | ||
* __requests__: request numbers of current connection | ||
* __poolsize__: memory pool size of current connection | ||
* __request__: request of current connection | ||
* __uri__: request uri of current connection | ||
* __handler__: read/write event handler of the request, use addr2line to find the real function | ||
* __startsec__: start timestamp of the request | ||
* __poolsize__: memory pool size of the request | ||
|
||
Nginx Compatibility | ||
=================== | ||
|
||
The latest module is compatible with the following versions of nginx: | ||
|
||
* 1.13.4 (stable version of 1.13.x) and later | ||
|
||
Tengine Compatibility | ||
===================== | ||
|
||
* 2.1.1 (stable version of 2.1.x) and later | ||
|
||
Install | ||
======= | ||
|
||
Install this module from source: | ||
|
||
``` | ||
$ wget http://nginx.org/download/nginx-1.13.4.tar.gz | ||
$ tar -xzvf nginx-1.13.4.tar.gz | ||
$ cd nginx-1.13.4/ | ||
$ ./configure --add-module=/path/to/ngx_debug_conn | ||
$ make -j4 && make install | ||
``` | ||
|
||
Directive | ||
========= | ||
|
||
Syntax: **debug_conn** | ||
|
||
Default: `none` | ||
|
||
Context: `server, location` | ||
|
||
The information of nginx connection usage will be accessible from the surrounding location. | ||
|
||
Exception | ||
========= | ||
|
||
``` | ||
********* request ****** | ||
``` | ||
|
||
The request block will only show when request exists in connection. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ngx_addon_name=ngx_http_debug_conn_module | ||
HTTP_MODULES="$HTTP_MODULES ngx_http_debug_conn_module" | ||
NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_debug_conn_module.c" |
Oops, something went wrong.