NGINX虛擬主機流量狀態模塊
有關最新標記的版本,請參見GitHub版本。
安裝此模塊後,運行sudo prove -rt 。需要sudo ,因為測試要求NGINX在端口80上聆聽。
未測試早期版本。
shell> git clone git://github.com/vozlt/nginx-module-vts.git
通過添加--add-module=/path/to/nginx-module-vts將模塊添加到構建配置中
構建Nginx二進制。
安裝NGINX二進制。
http {
vhost_traffic_status_zone;
...
server {
...
location /status {
vhost_traffic_status_display;
vhost_traffic_status_display_format html;
}
}
}這是一個NGINX模塊,可訪問虛擬主機狀態信息。它包含當前狀態,例如服務器,上游,緩存。這類似於Nginx Plus的現場活動監控。內置的HTML也從舊版本的演示頁面中獲取。
首先,需要指令vhost_traffic_status_zone ,然後如果設置了指令vhost_traffic_status_display ,則可以訪問如下:
/status/format/json ,將使用一個JSON文檔進行響應,其中包含當前活動數據,用於實時儀表板和第三方監視工具。/status/format/json /status/format/html json 。/status/format/jsonp ,將使用一個JSONP回調函數響應,該函數包含當前活動數據,用於在實時儀表板和第三方監視工具中使用。/status/format/prometheus ,將使用包含當前活動數據的Prometheus文件進行響應。/status/control ,將通過查詢字符串重置或刪除區域後使用JSON文檔進行響應。看到控件。JSON文檔包含如下:
{
"hostName" : ...,
"moduleVersion" : ...,
"nginxVersion" : ...,
"loadMsec" : ...,
"nowMsec" : ...,
"connections" : {
"active" : ...,
"reading" : ...,
"writing" : ...,
"waiting" : ...,
"accepted" : ...,
"handled" : ...,
"requests" : ...
},
"sharedZones" : {
"name" : ...,
"maxSize" : ...,
"usedSize" : ...,
"usedNode" : ...
},
"serverZones" : {
"..." :{
"requestCounter" : ...,
"inBytes" : ...,
"outBytes" : ...,
"responses" :{
"1xx" : ...,
"2xx" : ...,
"3xx" : ...,
"4xx" : ...,
"5xx" : ...,
"miss" : ...,
"bypass" : ...,
"expired" : ...,
"stale" : ...,
"updating" : ...,
"revalidated" : ...,
"hit" : ...,
"scarce" : ...
},
"requestMsecCounter" : ...,
"requestMsec" : ...,
"requestMsecs" :{
"times" :[ ... ],
"msecs" :[ ... ]
},
"requestBuckets" :{
"msecs" :[ ... ],
"counters" :[ ... ]
},
}
...
},
"filterZones" : {
"..." :{
"..." :{
"requestCounter" : ...,
"inBytes" : ...,
"outBytes" : ...,
"responses" :{
"1xx" : ...,
"2xx" : ...,
"3xx" : ...,
"4xx" : ...,
"5xx" : ...,
"miss" : ...,
"bypass" : ...,
"expired" : ...,
"stale" : ...,
"updating" : ...,
"revalidated" : ...,
"hit" : ...,
"scarce" : ...
},
"requestMsecCounter" : ...,
"requestMsec" : ...,
"requestMsecs" :{
"times" :[ ... ],
"msecs" :[ ... ]
},
"requestBuckets" :{
"msecs" :[ ... ],
"counters" :[ ... ]
},
},
...
},
...
},
"upstreamZones" : {
"..." :[
{
"server" : ...,
"requestCounter" : ...,
"inBytes" : ...,
"outBytes" : ...,
"responses" :{
"1xx" : ...,
"2xx" : ...,
"3xx" : ...,
"4xx" : ...,
"5xx" : ...
},
"requestMsecCounter" : ...,
"requestMsec" : ...,
"requestMsecs" :{
"times" :[ ... ],
"msecs" :[ ... ]
},
"requestBuckets" :{
"msecs" :[ ... ],
"counters" :[ ... ]
},
"responseMsecCounter" : ...,
"responseMsec" : ...,
"responseMsecs" :{
"times" :[ ... ],
"msecs" :[ ... ]
},
"responseBuckets" :{
"msecs" :[ ... ],
"counters" :[ ... ]
},
"weight" : ...,
"maxFails" : ...,
"failTimeout" : ...,
"backup" : ...,
"down" : ...
}
...
],
...
}
"cacheZones" : {
"..." :{
"maxSize" : ...,
"usedSize" : ...,
"inBytes" : ...,
"outBytes" : ...,
"responses" :{
"miss" : ...,
"bypass" : ...,
"expired" : ...,
"stale" : ...,
"updating" : ...,
"revalidated" : ...,
"hit" : ...,
"scarce" : ...
}
},
...
}
}* )和HIT比率vhost_traffic_status_filter_by_set_key指令過濾的每個服務器區域的流量(進出)以及請求和響應計數和緩存命中率* ),並通過vhost_traffic_status_filter_by_set_key指令過濾HIT比率 JSON文檔中的overCounts對象主要用於32位系統,如果其值溢出,則將增加1個。指令vhost_traffic_status_display_format設置了JSON,JSONP,HTML,PROMETHEUS之一的默認OUPUT格式。 (默認:JSON)
流量計算如下:
所有計算都在NGINX的對數處理階段工作。內部重定向(X-Accel-redirect或error_page)在上游區域中未計算。
Caveats:此模塊依賴於NGINX記錄系統(NGX_HTTP_LOG_PHASE:NGINX HTTP的最後階段),因此流量可能在某些CirumStances中與實際帶寬流量不同。 Websocket,已取消的下載可能導致不准確的原因。該模塊的工作根本無關緊要,無論access_log指令“ on”或“ off”。同樣,此模塊在“ access_log Off”上效果很好。當使用多個域時,它將設置為Server_name指令的第一個域(左)。如果您不想要它,請參見vhost_traffic_status_filter_by_host,vhost_traffic_status_filter_filter_by_set_keyney指令。
有關stream流量統計信息,請參見以下模塊:
當前所有平均值均在最後64個值中計算為AMM(算術平均值)。
它能夠通過查詢字符串重置或刪除交通區域。請求用JSON文檔做出響應。
{status_uri} / control?cmd = {command} &group = {group} &Zone = {name} http {
geoip_country /usr/share/GeoIP/GeoIP.dat;
vhost_traffic_status_zone;
vhost_traffic_status_filter_by_set_key $geoip_country_code country::*;
...
server {
server_name example.org;
...
vhost_traffic_status_filter_by_set_key $geoip_country_code country:: $server_name ;
location /status {
vhost_traffic_status_display;
vhost_traffic_status_display_format html;
}
}
}如果設置為上述,則控制URI就像example.org/status/control 。
可用的請求參數如下:
status | reset | delete >status/format/json 。server | filter upstream@alone | upstream@group | cache | * >這類似於status/format/json除非它可以獲取每個區域。
status/format/json完全相同。 MANXONES值是默認狀態值,包括hostName , moduleVersion , nginxVersion , loadMsec , nowMsec , connections 。
namefilter_group @ nameupstream_group @ namenamename它將指定區域的值重置為0。
namefilter_group @ nameupstream_group @ namenamename它在共享內存中刪除指定的區域。
namefilter_group @ nameupstream_group @ namenamename 它可以使用vhost_traffic_status_set_by_filter指令分別獲得NGINX配置中的狀態值。它幾乎可以獲取所有狀態值,並且獲得的值存儲在用戶定義變量中,這是第一個參數。
http {
geoip_country /usr/share/GeoIP/GeoIP.dat;
vhost_traffic_status_zone;
vhost_traffic_status_filter_by_set_key $geoip_country_code country::*;
...
upstream backend {
10.10.10.11:80;
10.10.10.12:80;
}
server {
server_name example.org;
...
vhost_traffic_status_filter_by_set_key $geoip_country_code country:: $server_name ;
vhost_traffic_status_set_by_filter $requestCounter server/example.org/requestCounter;
vhost_traffic_status_set_by_filter $requestCounterKR filter/country::example.org@KR/requestCounter;
location /backend {
vhost_traffic_status_set_by_filter $requestCounterB1 upstream@group/[email protected]:80/requestCounter;
proxy_pass http://backend;
}
}
}上述設置如下:
請參閱vhost_traffic_status_set_by_filter指令詳細使用。
以JSON格式提供以下狀態信息:
/ {status_uri} /格式 /json
/ {status_uri} / control?cmd =狀態&...
{version}(|.dev.{commit})格式中的模塊的版本。vhost_traffic_status )vhost_traffic_status_histogram_buckets指令設置的直方圖的存儲桶值。serverZones ,除了包含組名稱外。vhost_traffic_status_histogram_buckets指令設置的直方圖的存儲桶值。vhost_traffic_status_histogram_buckets指令設置的直方圖的存儲桶值。weight設置。max_fails設置。fail_timeout設置。backup設置。down設置。基本上,這只是一個標記NGX_HTTP_UPSTREAM_MODULE的服務器(例如server backend3.example.com down ),而不是實際的上游服務器狀態。如果您啟用了上游區域指令,它將更改為實際狀態。proxy_cache_path指令中的max_size ,則默認情況下將分配系統依賴值NGX_MAX_OFF_T_VALUE 。換句話說,此值來自NGINX,而不是我指定的值。maxSize值。 / {status_uri} / control?cmd = reset&...
/ {status_uri} / control?cmd = delete&...
提供了以下嵌入式變量:
它能夠使用指令vhost_traffic_status_limit_traffic限制每個主機的總流量。它還可以使用指令vhost_traffic_status_limit_traffic_by_set_key來限制所有流量。當超過限制時,服務器將返回503(暫時不可用的服務)錯誤,以回復請求。返回代碼可以更改。
http {
vhost_traffic_status_zone;
...
server {
server_name *.example.org;
vhost_traffic_status_limit_traffic in:64G;
vhost_traffic_status_limit_traffic out:1024G;
...
}
}*.example.org上的總流量分別限制為64G和1024G。如果啟用了vhost_traffic_status_filter_by_host指令,則每個域單獨工作。 http {
geoip_country /usr/share/GeoIP/GeoIP.dat;
vhost_traffic_status_zone;
...
server {
server_name example.org;
vhost_traffic_status_filter_by_set_key $geoip_country_code country:: $server_name ;
vhost_traffic_status_limit_traffic_by_set_key FG@country:: $server_name @US out:1024G;
vhost_traffic_status_limit_traffic_by_set_key FG@country:: $server_name @CN out:2048G;
...
}
}
example.org和CN的總流量分別限制為1024G和2048G。 http {
vhost_traffic_status_zone;
...
upstream backend {
server 10.10.10.17:80;
server 10.10.10.18:80;
}
server {
server_name example.org;
location /backend {
vhost_traffic_status_limit_traffic_by_set_key UG@[email protected]:80 in:512G;
vhost_traffic_status_limit_traffic_by_set_key UG@[email protected]:80 in:1024G;
proxy_pass http://backend;
}
...
}
}
example.org上游後端進入上游後端的總流量限制為每個對等點512G和1024G。 Caveats:流量是累積轉移或計數器,而不是帶寬。
它能夠使用指令vhost_traffic_status_filter_by_set_key來計算用戶定義的單個統計數據。
http {
geoip_country /usr/share/GeoIP/GeoIP.dat;
vhost_traffic_status_zone;
vhost_traffic_status_filter_by_set_key $geoip_country_code country::*;
...
server {
...
vhost_traffic_status_filter_by_set_key $geoip_country_code country:: $server_name ;
location /status {
vhost_traffic_status_display;
vhost_traffic_status_display_format html;
}
}
}基本上,鄉村標誌圖像是在HTML內置的。如果包含在組名稱中的country字符串,則啟用國家標誌圖像,這是vhost_traffic_status_filter_by_set_key指令的第二個參數。
http {
vhost_traffic_status_zone;
...
server {
...
location ~ ^/storage/(.+)/.*$ {
set $volume $1 ;
vhost_traffic_status_filter_by_set_key $volume storage:: $server_name ;
}
location /status {
vhost_traffic_status_display;
vhost_traffic_status_display_format html;
}
}
} http {
vhost_traffic_status_zone;
map $http_user_agent $filter_user_agent {
default 'unknown' ;
~ iPhone ios;
~ Android android;
~ (MSIE|Mozilla) windows;
}
vhost_traffic_status_filter_by_set_key $filter_user_agent agent::*;
...
server {
...
vhost_traffic_status_filter_by_set_key $filter_user_agent agent:: $server_name ;
location /status {
vhost_traffic_status_display;
vhost_traffic_status_display_format html;
}
}
}http_user_agent的流量 http {
vhost_traffic_status_zone;
server {
...
vhost_traffic_status_filter_by_set_key $status $server_name ;
location /status {
vhost_traffic_status_display;
vhost_traffic_status_display_format html;
}
}
}http status code的流量Caveats: $狀態變量可在nginx-(1.3.2,1.2.2)中找到。
如果域具有多個DNS記錄,則可以使用過濾器功能或Proxy_pass中的變量來計算單個IP的流量。
http {
vhost_traffic_status_zone;
upstream backend {
elb.example.org:80;
}
...
server {
...
location /backend {
vhost_traffic_status_filter_by_set_key $upstream_addr upstream::backend;
proxy_pass backend;
}
}
}elb.example.org的單個IP的流量。如果elb.example.org具有多個DNS A記錄,則將顯示所有filterZones中的所有IPS。在上面的設置中,隨著NGINX啟動或重新加載IT配置,它會查詢DNS服務器以解決域和DNS記錄在內存中的緩存。因此,即使DNS a記錄被DNS管理員call縮,除非nginx重新啟動或重新加載,否則DNS的記錄也不會更改。 http {
vhost_traffic_status_zone;
resolver 10.10.10.53 valid=10s
...
server {
...
location /backend {
set $backend_server elb.example.org;
proxy_pass http:// $backend_server ;
}
}
}elb.example.org的單個IP的流量。如果elb.example.org的DNS更改了記錄,則將同時顯示舊的IP和新IP ::nogroups中的新IP。與第一個上游組設置不同,即使DNS A記錄被DNS管理員claging,第二個設置也可以很好地工作。 Caveats:請有關NGINX DNS的更多詳細信息,請參見DNS-Service-Discovery-nginx-Plus。
http {
vhost_traffic_status_zone;
...
server {
...
location /status {
vhost_traffic_status_bypass_limit on;
vhost_traffic_status_bypass_stats on;
vhost_traffic_status_display;
vhost_traffic_status_display_format html;
}
}
}/status URI被排除在狀態流量計算和限制功能之外。請參閱以下指令: http {
vhost_traffic_status_zone;
vhost_traffic_status_dump /var/log/nginx/vts.db;
...
server {
...
}
}vhost_traffic_status_dump指令將永久維護統計數據數據。請參閱vhost_traffic_status_dump指令以獲取詳細用法。 {{uri}}字符串更改為狀態uri。 shell> vi share/status.template.html
var vtsStatusURI = "yourStatusUri/format/json", vtsUpdateInterval = 1000;
shell> cp share/status.template.html /usr/share/nginx/html/status.html
nginx.conf server {
server_name example.org;
root /usr/share/nginx/html;
# Redirect requests for / to /status.html
location = / {
return 301 /status.html;
}
location = /status.html {}
# Everything beginning /status (except for /status.html) is
# processed by the status handler
location /status {
vhost_traffic_status_display;
vhost_traffic_status_display_format json;
}
}
http://example.org/status.html
修改share/status.template.html (請勿更改{{uri}}字符串)
重新創建ngx_http_vhost_traffic_status_module_html.h ,如下:
shell> cd util
shell> ./tplToDefine.sh ../share/status.template.html > ../src/ngx_http_vhost_traffic_status_module_html.h
通過添加--add-module=/path/to/nginx-module-vts將模塊添加到構建配置中
構建Nginx二進制。
安裝NGINX二進制。

| - | - |
|---|---|
| 句法 | vhost_traffic_status <on | off> |
| 預設 | 離開 |
| 情境 | HTTP,服務器,位置 |
Description:啟用或禁用模塊工作。如果設置vhost_traffic_status_zone指令,將自動啟用。
| - | - |
|---|---|
| 句法 | vhost_traffic_status_zone [共享:名稱:大小] |
| 預設 | 共享:vhost_traffic_status:1m |
| 情境 | http |
Description:設置共享內存區域的參數,該參數將保留各種鍵的狀態。緩存在所有工作過程之間共享。在大多數情況下,NGINX-MODULE-VTS使用的共享存儲器大小不會增加太多。當使用vhost_traffic_status_filter_by_set_key指令時,共享存儲器大小會增加,但是如果固定過濾器的鍵是固定的(例如。國家代碼的總數約為240 ),則不會持續增加。
如果您使用vhost_traffic_status_filter_by_set_key指令,則將其設置如下:
vhost_traffic_status_zone shared:vhost_traffic_status:32m )"ngx_slab_alloc() failed: no memory in vhost_traffic_status_zone" )在error_log中打印出來,則增加到超過(二手size * 2)。| - | - |
|---|---|
| 句法 | VHOST_TRAFFIC_STATUS_DUMP PATH [週期] |
| 預設 | - |
| 情境 | http |
Description:啟用統計數據轉儲並還原。該路徑是轉儲統計數據的位置。(例如/var/log/nginx/vts.db )該週期是備份週期時間。(默認值:60s),如果NGINX由信號(Signal)(Sigkill)( SIGKILL ),則它會立即備份。
| - | - |
|---|---|
| 句法 | vhost_traffic_status_display |
| 預設 | - |
| 情境 | HTTP,服務器,位置 |
Description:啟用或禁用模塊顯示處理程序。
| - | - |
|---|---|
| 句法 | vhost_traffic_status_display_format <json | html | jsonp | Prometheus> |
| 預設 | JSON |
| 情境 | HTTP,服務器,位置 |
Description:設置顯示處理程序的輸出格式。如果您設置json ,將使用JSON文檔進行響應。如果設置了html ,將使用HTML的內置Live儀表板進行響應。如果設置jsonp ,將使用JSONP回調函數響應(默認: ngx_http_vhost_traffic_status_jsonp_callback )。如果您設定prometheus ,將使用Prometheus文件做出回應。
| - | - |
|---|---|
| 句法 | vhost_traffic_status_display_jsonp回調 |
| 預設 | ngx_http_vhost_traffic_status_jsonp_callback |
| 情境 | HTTP,服務器,位置 |
Description:設置JSONP的回調名稱。
| - | - |
|---|---|
| 句法 | vhost_traffic_status_display_sum_key名稱 |
| 預設 | * |
| 情境 | HTTP,服務器,位置 |
Description:在服務器字段的JSON中設置SUM鍵字符串。默認的總和鍵字符串是“*”。
| - | - |
|---|---|
| 句法 | vhost_traffic_status_filter <on | off> |
| 預設 | 在 |
| 情境 | HTTP,服務器,位置 |
Description:啟用或禁用過濾器功能。
| - | - |
|---|---|
| 句法 | vhost_traffic_status_filter_by_host <on | off> |
| 預設 | 離開 |
| 情境 | HTTP,服務器,位置 |
Description:通過主機標頭字段啟用或禁用鍵。如果on並設置Nginx的Server_name指令將幾個或通配符名稱設置為星號,例如“ *.example.org”,並請求使用hostName,例如(a | b | c).example.org或 *.example.org.example.org,則json serverzones thts json serverzones均以下面的打印:如下所示:如下所示:如下:
server {
server_name *.example.org;
vhost_traffic_status_filter_by_host on;
...
} ...
"serverZones" : {
"a.example.org" : {
...
},
"b.example.org" : {
...
},
"c.example.org" : {
...
}
...
},
...它提供了設置vhost_traffic_status_filter_by_set_key $host相同功能。
| - | - |
|---|---|
| 句法 | VHOST_TRAFFIC_STATUS_FILTER_BY_SET_KEY KEY [名稱] |
| 預設 | - |
| 情境 | HTTP,服務器,位置 |
Description:通過用戶定義的變量啟用鍵。密鑰是計算流量的鍵字符串。該名稱是計算流量的組字符串。鍵和名稱可以包含$ host,$ server_name之類的變量。如果指定了名稱的s組,則屬於filterZones 。如果未指定第二個參數名稱,則鍵的組屬於serverZones 。 GEOIP模塊的示例如下:
server {
server_name example.org;
vhost_traffic_status_filter_by_set_key $geoip_country_code country:: $server_name ;
...
} ...
"serverZones" : {
...
},
"filterZones" : {
"country::example.org" : {
"KR" : {
"requestCounter" : ...,
"inBytes" : ...,
"outBytes" : ...,
"responses" :{
"1xx" : ...,
"2xx" : ...,
"3xx" : ...,
"4xx" : ...,
"5xx" : ...,
"miss" : ...,
"bypass" : ...,
"expired" : ...,
"stale" : ...,
"updating" : ...,
"revalidated" : ...,
"hit" : ...,
"scarce" : ...
},
"requestMsecCounter" : ...,
"requestMsec" : ...,
"requestMsecs" :{
"times" :[ ... ],
"msecs" :[ ... ]
},
},
"US" : {
...
},
...
},
...
},
...
| - | - |
|---|---|
| 句法 | vhost_traffic_status_filter_check_duplate <on | off> |
| 預設 | 在 |
| 情境 | HTTP,服務器,位置 |
Description:啟用或禁用VHOST_TRAFFIC_STATUS_FILTER_BY_SET_KEY的重複數據刪除。如果啟用了此選項,則僅處理每個指令(HTTP,Server,Location)中的重複值( key + name )之一。
| - | - |
|---|---|
| 句法 | vhost_traffic_status_filter_max_node編號[ String ...] |
| 預設 | 0 |
| 情境 | http |
Description:使用指定的數字和字符串值啟用過濾器大小的限制。如果超過數字,則現有節點將被LRU算法刪除。數字參數是節點的大小將受到限制。默認值0不限製過濾器。一個節點是JSON文檔中filterZones中的對象。字符串參數是由vhost_traffic_status_filter_by_set_key指令設置的組字符串值的匹配字符串值。即使只有第一部分匹配,匹配也像正則表達式/^string.*/一樣成功。默認情況下,如果未設置字符串參數,則將其應用於所有過濾器。
例如:
$ vi nginx.conf
http {
geoip_country /usr/share/GeoIP/GeoIP.dat;
vhost_traffic_status_zone;
# The all filters are limited to a total of 16 nodes.
# vhost_traffic_status_filter_max_node 16
# The `/^uris.*/` and `/^client::ports.*/` group string patterns are limited to a total of 64 nodes.
vhost_traffic_status_filter_max_node 16 uris client::ports;
...
server {
server_name example.org;
...
vhost_traffic_status_filter_by_set_key $uri uris:: $server_name ;
vhost_traffic_status_filter_by_set_key $remote_port client::ports:: $server_name ;
vhost_traffic_status_filter_by_set_key $geoip_country_code country:: $server_name ;
}
} $ for i in {0..1000}; do curl -H 'Host: example.org' -i "http://localhost:80/test$i"; done

在上面的示例中, /^uris.*/和/^client::ports.*/組字符串模式僅限於16個節點。諸如country::.*不受限制。
| - | - |
|---|---|
| 句法 | vhost_traffic_status_limit <on | off> |
| 預設 | 在 |
| 情境 | HTTP,服務器,位置 |
Description:啟用或禁用限制功能。
| - | - |
|---|---|
| 句法 | VHOST_TRAFFIC_STATUS_LIMIT_TRAFFIC成員:大小[代碼] |
| 預設 | - |
| 情境 | HTTP,服務器,位置 |
Description:啟用指定成員的流量限制。該成員是限制流量的成員字符串。大小是限制流量的大小(k/m/g)。該代碼是響應被拒絕請求的返回的代碼。(默認:503)
可用member字符串如下:
| - | - |
|---|---|
| 句法 | vhost_traffic_status_limit_traffic_by_set_key鍵: size [代碼] |
| 預設 | - |
| 情境 | HTTP,服務器,位置 |
Description:啟用指定密鑰和成員的流量限制。關鍵是一個限制流量的鍵字符串。該成員是限制流量的成員字符串。大小是限制流量的大小(k/m/g)。該代碼是響應被拒絕請求的返回的代碼。(默認:503)
key語法如下:
group @[ subgroup @] name可用的group字符串如下:
subgroup )subgroup )可用member字符串如下:
成員與vhost_traffic_status_limit_traffic指令相同。
| - | - |
|---|---|
| 句法 | vhost_traffic_status_limit_check_duplate <on | off> |
| 預設 | 在 |
| 情境 | HTTP,服務器,位置 |
Description:啟用或禁用vhost_traffic_status_limit_by_set_key的重複數據刪除。如果啟用了此選項,則僅處理每個指令(http,server,location)中的重複值( member | key + member )之一。
| - | - |
|---|---|
| 句法 | VHOST_TRAFFIC_STATUS_SET_BY_FILTER $變量組/區域/名稱 |
| 預設 | - |
| 情境 | http,服務器,位置,如果 |
Description:獲取存儲在共享內存中的指定狀態值。它幾乎可以獲取所有狀態值,並且獲得的值存儲在$變量中,這是第一個參數。
Caveats:名稱是案例敏感的。所有返回值均採用整數類型。
例如:
$requestCounter server/example.org/requestCounter$requestCounter filter/country::example.org@KR/requestCounter$requestCounter upstream@group/[email protected]:80/requestCounter$requestCounter upstream@alone/10.10.10.11:80/requestCounter$cacheHit cache/my_cache_name/cacheHit| - | - |
|---|---|
| 句法 | vhost_traffic_status_average_method <AMM|WMA> [ period ] |
| 預設 | AMM 60s |
| 情境 | http, server, location |
Description: Sets the method which is a formula that calculate the average of response processing times. The period is an effective time of the values used for the average calculation.(Default: 60s) If period set to 0, effective time is ignored. In this case, the last average value is displayed even if there is no requests and after the elapse of time. The corresponding values are requestMsec and responseMsec in JSON.
| - | - |
|---|---|
| 句法 | vhost_traffic_status_histogram_buckets second ... |
| 預設 | - |
| 情境 | http, server, location |
Description: Sets the observe buckets to be used in the histograms. By default, if you do not set this directive, it will not work. The second can be expressed in decimal places with a minimum value of 0.001(1ms). The maximum size of the buckets is 32. If this value is insufficient for you, change the NGX_HTTP_VHOST_TRAFFIC_STATUS_DEFAULT_BUCKET_LEN in the src/ngx_http_vhost_traffic_status_node.h
For examples:
0.005 0.01 0.05 0.1 0.5 1 5 100.005 0.01 0.05 0.1 Caveats: By default, if you do not set this directive, the histogram statistics does not work. The restored histograms by vhost_traffic_status_dump directive have no affected by changes to the buckets by vhost_traffic_status_histogram_buckets directive. So you must first delete the zone or the dump file before changing the buckets by vhost_traffic_status_histogram_buckets directive. Similar to the above, delete the dump file when using the histogram for the first time.
| - | - |
|---|---|
| 句法 | vhost_traffic_status_bypass_limit <on|off> |
| 預設 | 離開 |
| 情境 | http, server, location |
Description: Enables or disables to bypass vhost_traffic_status_limit directives. The limit features is bypassed if this option is enabled. This is mostly useful if you want to connect the status web page like /status regardless of vhost_traffic_status_limit directives as follows:
http {
vhost_traffic_status_zone;
...
server {
...
location /status {
vhost_traffic_status_bypass_limit on;
vhost_traffic_status_display;
vhost_traffic_status_display_format html;
}
}
}| - | - |
|---|---|
| 句法 | vhost_traffic_status_bypass_stats <on|off> |
| 預設 | 離開 |
| 情境 | http, server, location |
Description: Enables or disables to bypass vhost_traffic_status . The traffic status stats features is bypassed if this option is enabled. In other words, it is excluded from the traffic status stats. This is mostly useful if you want to ignore your request in status web page like /status as follows:
http {
vhost_traffic_status_zone;
...
server {
...
location /status {
vhost_traffic_status_bypass_stats on;
vhost_traffic_status_display;
vhost_traffic_status_display_format html;
}
}
}To cut a release, create a changelog entry PR with git-chglog
version="v0.2.0"
git checkout -b "cut-${version}"
git-chglog -o CHANGELOG.md --next-tag "${version}"
git add CHANGELOG.md
sed -i "s/NGX_HTTP_VTS_MODULE_VERSION ".*/NGX_HTTP_VTS_MODULE_VERSION "${version}"/" src/ngx_http_vhost_traffic_status_module.h
git add src/ngx_http_vhost_traffic_status_module.h
git-chglog -t .chglog/RELNOTES.tmpl --next-tag "${version}" "${version}" | git commit -F-
After the PR is merged, create the new tag and release on the GitHub Releases.
Stream traffic status
普羅米修斯
System protection
YoungJoo.Kim(김영주) [[email protected]]