diff --git a/a.diff b/a.diff deleted file mode 100644 index bd29964..0000000 --- a/a.diff +++ /dev/null @@ -1,1131 +0,0 @@ -diff --git a/README.md b/README.md -index 85081e9..85c1b06 100644 ---- a/README.md -+++ b/README.md -@@ -144,19 +144,14 @@ First of all, the directive `vhost_traffic_status_zone` is required, - and then if the directive `vhost_traffic_status_display` is set, can be access to as follows: - - * /status/format/json -- --* /status/format/html -- --* /status/format/jsonp -- --* /status/control -- - * If you request `/status/format/json`, will respond with a JSON document containing the current activity data for using in live dashboards and third-party monitoring tools. -- -+* /status/format/html - * If you request `/status/format/html`, will respond with the built-in live dashboard in HTML that requests internally to `/status/format/json`. -- -+* /status/format/jsonp - * If you request `/status/format/jsonp`, will respond with a JSONP callback function containing the current activity data for using in live dashboards and third-party monitoring tools. -- -+* /status/format/prometheus -+ * If you request `/status/format/prometheus`, will respond with a [prometheus](https://prometheus.io) document containing the current activity data. -+* /status/control - * If you request `/status/control`, will respond with a JSON document after it reset or delete zones through a query string. See the [Control](#control). - - JSON document contains as follows: -@@ -1210,7 +1205,7 @@ It is backed up immediately regardless of the backup cycle if nginx is exited by - - | - | - | - | --- | --- | --| **Syntax** | **vhost_traffic_status_display_format** \ | -+| **Syntax** | **vhost_traffic_status_display_format** \ | - | **Default** | json | - | **Context** | http, server, location | - -@@ -1218,6 +1213,7 @@ It is backed up immediately regardless of the backup cycle if nginx is exited by - If you set `json`, will respond with a JSON document. - If you set `html`, will respond with the built-in live dashboard in HTML. - If you set `jsonp`, will respond with a JSONP callback function(default: *ngx_http_vhost_traffic_status_jsonp_callback*). -+If you set `prometheus`, will respond with a [prometheus](https://prometheus.io) document. - - ### vhost_traffic_status_display_jsonp - -@@ -1691,7 +1687,7 @@ http { - * [nginx-module-sysguard](https://github.com/vozlt/nginx-module-sysguard) - - ## TODO --* Add support for implementing accumulated request processing time. -+* Add support for implementing LRU(least recently used) for filter. - - ## Donation - [![License](http://img.shields.io/badge/PAYPAL-DONATE-yellow.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=PWWSYKQ9VKH38&lc=KR¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted) -diff --git a/config b/config -index 2ad1ec4..07a616d 100644 ---- a/config -+++ b/config -@@ -2,32 +2,36 @@ ngx_addon_name=ngx_http_vhost_traffic_status_module - have=NGX_STAT_STUB . auto/have - - HTTP_VTS_SRCS=" \ -- $ngx_addon_dir/src/ngx_http_vhost_traffic_status_module.c \ -- $ngx_addon_dir/src/ngx_http_vhost_traffic_status_variables.c \ -- $ngx_addon_dir/src/ngx_http_vhost_traffic_status_string.c \ -- $ngx_addon_dir/src/ngx_http_vhost_traffic_status_shm.c \ -- $ngx_addon_dir/src/ngx_http_vhost_traffic_status_node.c \ -- $ngx_addon_dir/src/ngx_http_vhost_traffic_status_filter.c \ -- $ngx_addon_dir/src/ngx_http_vhost_traffic_status_control.c \ -- $ngx_addon_dir/src/ngx_http_vhost_traffic_status_limit.c \ -- $ngx_addon_dir/src/ngx_http_vhost_traffic_status_display.c \ -- $ngx_addon_dir/src/ngx_http_vhost_traffic_status_set.c \ -- $ngx_addon_dir/src/ngx_http_vhost_traffic_status_dump.c \ -+ $ngx_addon_dir/src/ngx_http_vhost_traffic_status_module.c \ -+ $ngx_addon_dir/src/ngx_http_vhost_traffic_status_variables.c \ -+ $ngx_addon_dir/src/ngx_http_vhost_traffic_status_string.c \ -+ $ngx_addon_dir/src/ngx_http_vhost_traffic_status_shm.c \ -+ $ngx_addon_dir/src/ngx_http_vhost_traffic_status_node.c \ -+ $ngx_addon_dir/src/ngx_http_vhost_traffic_status_filter.c \ -+ $ngx_addon_dir/src/ngx_http_vhost_traffic_status_control.c \ -+ $ngx_addon_dir/src/ngx_http_vhost_traffic_status_limit.c \ -+ $ngx_addon_dir/src/ngx_http_vhost_traffic_status_display.c \ -+ $ngx_addon_dir/src/ngx_http_vhost_traffic_status_display_json.c \ -+ $ngx_addon_dir/src/ngx_http_vhost_traffic_status_display_prometheus.c \ -+ $ngx_addon_dir/src/ngx_http_vhost_traffic_status_set.c \ -+ $ngx_addon_dir/src/ngx_http_vhost_traffic_status_dump.c \ - " - - HTTP_VTS_DEPS=" \ -- $ngx_addon_dir/src/ngx_http_vhost_traffic_status_module.h \ -- $ngx_addon_dir/src/ngx_http_vhost_traffic_status_variables.h \ -- $ngx_addon_dir/src/ngx_http_vhost_traffic_status_string.h \ -- $ngx_addon_dir/src/ngx_http_vhost_traffic_status_shm.h \ -- $ngx_addon_dir/src/ngx_http_vhost_traffic_status_node.h \ -- $ngx_addon_dir/src/ngx_http_vhost_traffic_status_filter.h \ -- $ngx_addon_dir/src/ngx_http_vhost_traffic_status_control.h \ -- $ngx_addon_dir/src/ngx_http_vhost_traffic_status_limit.h \ -- $ngx_addon_dir/src/ngx_http_vhost_traffic_status_display.h \ -- $ngx_addon_dir/src/ngx_http_vhost_traffic_status_set.h \ -- $ngx_addon_dir/src/ngx_http_vhost_traffic_status_dump.h \ -- $ngx_addon_dir/src/ngx_http_vhost_traffic_status_module_html.h \ -+ $ngx_addon_dir/src/ngx_http_vhost_traffic_status_module.h \ -+ $ngx_addon_dir/src/ngx_http_vhost_traffic_status_variables.h \ -+ $ngx_addon_dir/src/ngx_http_vhost_traffic_status_string.h \ -+ $ngx_addon_dir/src/ngx_http_vhost_traffic_status_shm.h \ -+ $ngx_addon_dir/src/ngx_http_vhost_traffic_status_node.h \ -+ $ngx_addon_dir/src/ngx_http_vhost_traffic_status_filter.h \ -+ $ngx_addon_dir/src/ngx_http_vhost_traffic_status_control.h \ -+ $ngx_addon_dir/src/ngx_http_vhost_traffic_status_limit.h \ -+ $ngx_addon_dir/src/ngx_http_vhost_traffic_status_display.h \ -+ $ngx_addon_dir/src/ngx_http_vhost_traffic_status_display_json.h \ -+ $ngx_addon_dir/src/ngx_http_vhost_traffic_status_display_prometheus.h \ -+ $ngx_addon_dir/src/ngx_http_vhost_traffic_status_set.h \ -+ $ngx_addon_dir/src/ngx_http_vhost_traffic_status_dump.h \ -+ $ngx_addon_dir/src/ngx_http_vhost_traffic_status_module_html.h \ - " - if test -n "$ngx_module_link"; then - ngx_module_type=HTTP -diff --git a/src/ngx_http_vhost_traffic_status_control.c b/src/ngx_http_vhost_traffic_status_control.c -index ade1475..a30e7e2 100644 ---- a/src/ngx_http_vhost_traffic_status_control.c -+++ b/src/ngx_http_vhost_traffic_status_control.c -@@ -6,6 +6,7 @@ - - #include "ngx_http_vhost_traffic_status_module.h" - #include "ngx_http_vhost_traffic_status_control.h" -+#include "ngx_http_vhost_traffic_status_display_json.h" - #include "ngx_http_vhost_traffic_status_display.h" - - -diff --git a/src/ngx_http_vhost_traffic_status_display.c b/src/ngx_http_vhost_traffic_status_display.c -index 790a527..8ec6a1c 100644 ---- a/src/ngx_http_vhost_traffic_status_display.c -+++ b/src/ngx_http_vhost_traffic_status_display.c -@@ -7,7 +7,8 @@ - #include "ngx_http_vhost_traffic_status_module_html.h" - #include "ngx_http_vhost_traffic_status_module.h" - #include "ngx_http_vhost_traffic_status_shm.h" --#include "ngx_http_vhost_traffic_status_filter.h" -+#include "ngx_http_vhost_traffic_status_display_prometheus.h" -+#include "ngx_http_vhost_traffic_status_display_json.h" - #include "ngx_http_vhost_traffic_status_display.h" - #include "ngx_http_vhost_traffic_status_control.h" - -@@ -328,6 +329,9 @@ ngx_http_vhost_traffic_status_display_handler_default(ngx_http_request_t *r) - } else if (ngx_strncasecmp(s, (u_char *) "html", sizeof("html") - 1) == 0) { - format = NGX_HTTP_VHOST_TRAFFIC_STATUS_FORMAT_HTML; - -+ } else if (ngx_strncasecmp(s, (u_char *) "prometheus", sizeof("prometheus") - 1) == 0) { -+ format = NGX_HTTP_VHOST_TRAFFIC_STATUS_FORMAT_PROMETHEUS; -+ - } else { - s -= 2; - } -@@ -361,6 +365,9 @@ ngx_http_vhost_traffic_status_display_handler_default(ngx_http_request_t *r) - } else if (format == NGX_HTTP_VHOST_TRAFFIC_STATUS_FORMAT_JSONP) { - ngx_str_set(&type, "application/javascript"); - -+ } else if (format == NGX_HTTP_VHOST_TRAFFIC_STATUS_FORMAT_PROMETHEUS) { -+ ngx_str_set(&type, "text/plain"); -+ - } else { - ngx_str_set(&type, "text/html"); - } -@@ -400,7 +407,7 @@ ngx_http_vhost_traffic_status_display_handler_default(ngx_http_request_t *r) - b->last = ngx_sprintf(b->last, "{}"); - } - -- } else if (format == NGX_HTTP_VHOST_TRAFFIC_STATUS_FORMAT_JSONP) { -+ } else if (format == NGX_HTTP_VHOST_TRAFFIC_STATUS_FORMAT_JSONP) { - shpool = (ngx_slab_pool_t *) vtscf->shm_zone->shm.addr; - ngx_shmtx_lock(&shpool->mutex); - b->last = ngx_sprintf(b->last, "%V", &vtscf->jsonp); -@@ -409,6 +416,16 @@ ngx_http_vhost_traffic_status_display_handler_default(ngx_http_request_t *r) - b->last = ngx_sprintf(b->last, ")"); - ngx_shmtx_unlock(&shpool->mutex); - -+ } else if (format == NGX_HTTP_VHOST_TRAFFIC_STATUS_FORMAT_PROMETHEUS) { -+ shpool = (ngx_slab_pool_t *) vtscf->shm_zone->shm.addr; -+ ngx_shmtx_lock(&shpool->mutex); -+ b->last = ngx_http_vhost_traffic_status_display_prometheus_set(r, b->last); -+ ngx_shmtx_unlock(&shpool->mutex); -+ -+ if (b->last == b->pos) { -+ b->last = ngx_sprintf(b->last, "#"); -+ } -+ - } - else { - b->last = ngx_sprintf(b->last, NGX_HTTP_VHOST_TRAFFIC_STATUS_HTML_DATA, &uri, &uri); -@@ -504,6 +521,7 @@ ngx_http_vhost_traffic_status_display_get_size(ngx_http_request_t *r, - - case NGX_HTTP_VHOST_TRAFFIC_STATUS_FORMAT_JSON: - case NGX_HTTP_VHOST_TRAFFIC_STATUS_FORMAT_JSONP: -+ case NGX_HTTP_VHOST_TRAFFIC_STATUS_FORMAT_PROMETHEUS: - size = sizeof(ngx_http_vhost_traffic_status_node_t) / NGX_PTR_SIZE - * NGX_ATOMIC_T_LEN * un /* values size */ - + (un * 1024) /* names size */ -@@ -531,8 +549,7 @@ u_char * - ngx_http_vhost_traffic_status_display_get_time_queue( - ngx_http_request_t *r, - ngx_http_vhost_traffic_status_node_time_queue_t *q, -- ngx_uint_t offset -- ) -+ ngx_uint_t offset) - { - u_char *p, *s; - ngx_int_t i; -@@ -580,845 +597,6 @@ ngx_http_vhost_traffic_status_display_get_time_queue_msecs( - } - - --u_char * --ngx_http_vhost_traffic_status_display_set_main(ngx_http_request_t *r, -- u_char *buf) --{ -- ngx_atomic_int_t ap, hn, ac, rq, rd, wr, wa; -- ngx_http_vhost_traffic_status_loc_conf_t *vtscf; -- ngx_http_vhost_traffic_status_shm_info_t *shm_info; -- -- vtscf = ngx_http_get_module_loc_conf(r, ngx_http_vhost_traffic_status_module); -- -- ap = *ngx_stat_accepted; -- hn = *ngx_stat_handled; -- ac = *ngx_stat_active; -- rq = *ngx_stat_requests; -- rd = *ngx_stat_reading; -- wr = *ngx_stat_writing; -- wa = *ngx_stat_waiting; -- -- shm_info = ngx_pcalloc(r->pool, sizeof(ngx_http_vhost_traffic_status_shm_info_t)); -- if (shm_info == NULL) { -- return buf; -- } -- -- ngx_http_vhost_traffic_status_shm_info(r, shm_info); -- -- buf = ngx_sprintf(buf, NGX_HTTP_VHOST_TRAFFIC_STATUS_JSON_FMT_MAIN, &ngx_cycle->hostname, -- NGINX_VERSION, vtscf->start_msec, ngx_http_vhost_traffic_status_current_msec(), -- ac, rd, wr, wa, ap, hn, rq, -- shm_info->name, shm_info->max_size, -- shm_info->used_size, shm_info->used_node); -- -- return buf; --} -- -- --u_char * --ngx_http_vhost_traffic_status_display_set_server_node( -- ngx_http_request_t *r, -- u_char *buf, ngx_str_t *key, -- ngx_http_vhost_traffic_status_node_t *vtsn) --{ -- ngx_int_t rc; -- ngx_str_t tmp, dst; -- ngx_http_vhost_traffic_status_loc_conf_t *vtscf; -- -- vtscf = ngx_http_get_module_loc_conf(r, ngx_http_vhost_traffic_status_module); -- -- tmp = *key; -- -- (void) ngx_http_vhost_traffic_status_node_position_key(&tmp, 1); -- -- rc = ngx_http_vhost_traffic_status_escape_json_pool(r->pool, &dst, &tmp); -- if (rc != NGX_OK) { -- ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, -- "display_set_server_node::escape_json_pool() failed"); -- } -- --#if (NGX_HTTP_CACHE) -- buf = ngx_sprintf(buf, NGX_HTTP_VHOST_TRAFFIC_STATUS_JSON_FMT_SERVER, -- &dst, vtsn->stat_request_counter, -- vtsn->stat_in_bytes, -- vtsn->stat_out_bytes, -- vtsn->stat_1xx_counter, -- vtsn->stat_2xx_counter, -- vtsn->stat_3xx_counter, -- vtsn->stat_4xx_counter, -- vtsn->stat_5xx_counter, -- vtsn->stat_cache_miss_counter, -- vtsn->stat_cache_bypass_counter, -- vtsn->stat_cache_expired_counter, -- vtsn->stat_cache_stale_counter, -- vtsn->stat_cache_updating_counter, -- vtsn->stat_cache_revalidated_counter, -- vtsn->stat_cache_hit_counter, -- vtsn->stat_cache_scarce_counter, -- vtsn->stat_request_time_counter, -- ngx_http_vhost_traffic_status_node_time_queue_average( -- &vtsn->stat_request_times, vtscf->average_method, -- vtscf->average_period), -- ngx_http_vhost_traffic_status_display_get_time_queue_times(r, -- &vtsn->stat_request_times), -- ngx_http_vhost_traffic_status_display_get_time_queue_msecs(r, -- &vtsn->stat_request_times), -- ngx_http_vhost_traffic_status_max_integer, -- vtsn->stat_request_counter_oc, -- vtsn->stat_in_bytes_oc, -- vtsn->stat_out_bytes_oc, -- vtsn->stat_1xx_counter_oc, -- vtsn->stat_2xx_counter_oc, -- vtsn->stat_3xx_counter_oc, -- vtsn->stat_4xx_counter_oc, -- vtsn->stat_5xx_counter_oc, -- vtsn->stat_cache_miss_counter_oc, -- vtsn->stat_cache_bypass_counter_oc, -- vtsn->stat_cache_expired_counter_oc, -- vtsn->stat_cache_stale_counter_oc, -- vtsn->stat_cache_updating_counter_oc, -- vtsn->stat_cache_revalidated_counter_oc, -- vtsn->stat_cache_hit_counter_oc, -- vtsn->stat_cache_scarce_counter_oc, -- vtsn->stat_request_time_counter_oc); --#else -- buf = ngx_sprintf(buf, NGX_HTTP_VHOST_TRAFFIC_STATUS_JSON_FMT_SERVER, -- key, vtsn->stat_request_counter, -- vtsn->stat_in_bytes, -- vtsn->stat_out_bytes, -- vtsn->stat_1xx_counter, -- vtsn->stat_2xx_counter, -- vtsn->stat_3xx_counter, -- vtsn->stat_4xx_counter, -- vtsn->stat_5xx_counter, -- vtsn->stat_request_time_counter, -- ngx_http_vhost_traffic_status_node_time_queue_average( -- &vtsn->stat_request_times, vtscf->average_method, -- vtscf->average_period), -- ngx_http_vhost_traffic_status_display_get_time_queue_times(r, -- &vtsn->stat_request_times), -- ngx_http_vhost_traffic_status_display_get_time_queue_msecs(r, -- &vtsn->stat_request_times), -- ngx_http_vhost_traffic_status_max_integer, -- vtsn->stat_request_counter_oc, -- vtsn->stat_in_bytes_oc, -- vtsn->stat_out_bytes_oc, -- vtsn->stat_1xx_counter_oc, -- vtsn->stat_2xx_counter_oc, -- vtsn->stat_3xx_counter_oc, -- vtsn->stat_4xx_counter_oc, -- vtsn->stat_5xx_counter_oc, -- vtsn->stat_request_time_counter_oc); --#endif -- -- return buf; --} -- -- --u_char * --ngx_http_vhost_traffic_status_display_set_server(ngx_http_request_t *r, -- u_char *buf, ngx_rbtree_node_t *node) --{ -- ngx_str_t key; -- ngx_http_vhost_traffic_status_ctx_t *ctx; -- ngx_http_vhost_traffic_status_node_t *vtsn, ovtsn; -- ngx_http_vhost_traffic_status_loc_conf_t *vtscf; -- -- ctx = ngx_http_get_module_main_conf(r, ngx_http_vhost_traffic_status_module); -- -- vtscf = ngx_http_get_module_loc_conf(r, ngx_http_vhost_traffic_status_module); -- -- if (node != ctx->rbtree->sentinel) { -- vtsn = (ngx_http_vhost_traffic_status_node_t *) &node->color; -- -- if (vtsn->stat_upstream.type == NGX_HTTP_VHOST_TRAFFIC_STATUS_UPSTREAM_NO) { -- key.data = vtsn->data; -- key.len = vtsn->len; -- -- ovtsn = vtscf->stats; -- -- buf = ngx_http_vhost_traffic_status_display_set_server_node(r, buf, &key, vtsn); -- -- /* calculates the sum */ -- vtscf->stats.stat_request_counter +=vtsn->stat_request_counter; -- vtscf->stats.stat_in_bytes += vtsn->stat_in_bytes; -- vtscf->stats.stat_out_bytes += vtsn->stat_out_bytes; -- vtscf->stats.stat_1xx_counter += vtsn->stat_1xx_counter; -- vtscf->stats.stat_2xx_counter += vtsn->stat_2xx_counter; -- vtscf->stats.stat_3xx_counter += vtsn->stat_3xx_counter; -- vtscf->stats.stat_4xx_counter += vtsn->stat_4xx_counter; -- vtscf->stats.stat_5xx_counter += vtsn->stat_5xx_counter; -- vtscf->stats.stat_request_time_counter += vtsn->stat_request_time_counter; -- ngx_http_vhost_traffic_status_node_time_queue_merge( -- &vtscf->stats.stat_request_times, -- &vtsn->stat_request_times, vtscf->average_period); -- -- vtscf->stats.stat_request_counter_oc += vtsn->stat_request_counter_oc; -- vtscf->stats.stat_in_bytes_oc += vtsn->stat_in_bytes_oc; -- vtscf->stats.stat_out_bytes_oc += vtsn->stat_out_bytes_oc; -- vtscf->stats.stat_1xx_counter_oc += vtsn->stat_1xx_counter_oc; -- vtscf->stats.stat_2xx_counter_oc += vtsn->stat_2xx_counter_oc; -- vtscf->stats.stat_3xx_counter_oc += vtsn->stat_3xx_counter_oc; -- vtscf->stats.stat_4xx_counter_oc += vtsn->stat_4xx_counter_oc; -- vtscf->stats.stat_5xx_counter_oc += vtsn->stat_5xx_counter_oc; -- vtscf->stats.stat_request_time_counter_oc += vtsn->stat_request_time_counter_oc; -- --#if (NGX_HTTP_CACHE) -- vtscf->stats.stat_cache_miss_counter += -- vtsn->stat_cache_miss_counter; -- vtscf->stats.stat_cache_bypass_counter += -- vtsn->stat_cache_bypass_counter; -- vtscf->stats.stat_cache_expired_counter += -- vtsn->stat_cache_expired_counter; -- vtscf->stats.stat_cache_stale_counter += -- vtsn->stat_cache_stale_counter; -- vtscf->stats.stat_cache_updating_counter += -- vtsn->stat_cache_updating_counter; -- vtscf->stats.stat_cache_revalidated_counter += -- vtsn->stat_cache_revalidated_counter; -- vtscf->stats.stat_cache_hit_counter += -- vtsn->stat_cache_hit_counter; -- vtscf->stats.stat_cache_scarce_counter += -- vtsn->stat_cache_scarce_counter; -- -- vtscf->stats.stat_cache_miss_counter_oc += -- vtsn->stat_cache_miss_counter_oc; -- vtscf->stats.stat_cache_bypass_counter_oc += -- vtsn->stat_cache_bypass_counter_oc; -- vtscf->stats.stat_cache_expired_counter_oc += -- vtsn->stat_cache_expired_counter_oc; -- vtscf->stats.stat_cache_stale_counter_oc += -- vtsn->stat_cache_stale_counter_oc; -- vtscf->stats.stat_cache_updating_counter_oc += -- vtsn->stat_cache_updating_counter_oc; -- vtscf->stats.stat_cache_revalidated_counter_oc += -- vtsn->stat_cache_revalidated_counter_oc; -- vtscf->stats.stat_cache_hit_counter_oc += -- vtsn->stat_cache_hit_counter_oc; -- vtscf->stats.stat_cache_scarce_counter_oc += -- vtsn->stat_cache_scarce_counter_oc; --#endif -- -- ngx_http_vhost_traffic_status_add_oc((&ovtsn), (&vtscf->stats)); -- } -- -- buf = ngx_http_vhost_traffic_status_display_set_server(r, buf, node->left); -- buf = ngx_http_vhost_traffic_status_display_set_server(r, buf, node->right); -- } -- -- return buf; --} -- -- --u_char * --ngx_http_vhost_traffic_status_display_set_filter_node(ngx_http_request_t *r, -- u_char *buf, ngx_http_vhost_traffic_status_node_t *vtsn) --{ -- ngx_str_t key; -- -- key.data = vtsn->data; -- key.len = vtsn->len; -- -- (void) ngx_http_vhost_traffic_status_node_position_key(&key, 2); -- -- return ngx_http_vhost_traffic_status_display_set_server_node(r, buf, &key, vtsn); --} -- -- --u_char * --ngx_http_vhost_traffic_status_display_set_filter(ngx_http_request_t *r, -- u_char *buf, ngx_rbtree_node_t *node) --{ -- ngx_str_t key; -- ngx_uint_t i, j, n, rc; -- ngx_array_t *filter_keys, *filter_nodes; -- ngx_http_vhost_traffic_status_filter_key_t *keys; -- ngx_http_vhost_traffic_status_filter_node_t *nodes; -- -- /* init array */ -- filter_keys = NULL; -- filter_nodes = NULL; -- -- rc = ngx_http_vhost_traffic_status_filter_get_keys(r, &filter_keys, node); -- -- if (filter_keys != NULL && rc == NGX_OK) { -- keys = filter_keys->elts; -- n = filter_keys->nelts; -- -- if (n > 1) { -- ngx_qsort(keys, (size_t) n, -- sizeof(ngx_http_vhost_traffic_status_filter_key_t), -- ngx_http_traffic_status_filter_cmp_keys); -- } -- -- ngx_memzero(&key, sizeof(ngx_str_t)); -- -- for (i = 0; i < n; i++) { -- if (keys[i].key.len == key.len) { -- if (ngx_strncmp(keys[i].key.data, key.data, key.len) == 0) { -- continue; -- } -- } -- key = keys[i].key; -- -- rc = ngx_http_vhost_traffic_status_filter_get_nodes(r, &filter_nodes, &key, node); -- -- if (filter_nodes != NULL && rc == NGX_OK) { -- buf = ngx_sprintf(buf, NGX_HTTP_VHOST_TRAFFIC_STATUS_JSON_FMT_OBJECT_S, -- &keys[i].key); -- -- nodes = filter_nodes->elts; -- for (j = 0; j < filter_nodes->nelts; j++) { -- buf = ngx_http_vhost_traffic_status_display_set_filter_node(r, buf, -- nodes[j].node); -- } -- -- buf--; -- buf = ngx_sprintf(buf, NGX_HTTP_VHOST_TRAFFIC_STATUS_JSON_FMT_OBJECT_E); -- buf = ngx_sprintf(buf, NGX_HTTP_VHOST_TRAFFIC_STATUS_JSON_FMT_NEXT); -- -- /* destory array to prevent duplication */ -- if (filter_nodes != NULL) { -- filter_nodes = NULL; -- } -- } -- -- } -- -- /* destory array */ -- for (i = 0; i < n; i++) { -- if (keys[i].key.data != NULL) { -- ngx_pfree(r->pool, keys[i].key.data); -- } -- } -- if (filter_keys != NULL) { -- filter_keys = NULL; -- } -- } -- -- return buf; --} -- -- --u_char * --ngx_http_vhost_traffic_status_display_set_upstream_node(ngx_http_request_t *r, -- u_char *buf, ngx_http_upstream_server_t *us, --#if nginx_version > 1007001 -- ngx_http_vhost_traffic_status_node_t *vtsn --#else -- ngx_http_vhost_traffic_status_node_t *vtsn, ngx_str_t *name --#endif -- ) --{ -- ngx_int_t rc; -- ngx_str_t key; -- ngx_http_vhost_traffic_status_loc_conf_t *vtscf; -- -- vtscf = ngx_http_get_module_loc_conf(r, ngx_http_vhost_traffic_status_module); -- --#if nginx_version > 1007001 -- rc = ngx_http_vhost_traffic_status_escape_json_pool(r->pool, &key, &us->name); --#else -- rc = ngx_http_vhost_traffic_status_escape_json_pool(r->pool, &key, name); --#endif -- -- if (rc != NGX_OK) { -- ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, -- "display_set_upstream_node::escape_json_pool() failed"); -- } -- -- if (vtsn != NULL) { -- buf = ngx_sprintf(buf, NGX_HTTP_VHOST_TRAFFIC_STATUS_JSON_FMT_UPSTREAM, -- &key, vtsn->stat_request_counter, -- vtsn->stat_in_bytes, vtsn->stat_out_bytes, -- vtsn->stat_1xx_counter, vtsn->stat_2xx_counter, -- vtsn->stat_3xx_counter, vtsn->stat_4xx_counter, -- vtsn->stat_5xx_counter, -- vtsn->stat_request_time_counter, -- ngx_http_vhost_traffic_status_node_time_queue_average( -- &vtsn->stat_request_times, vtscf->average_method, -- vtscf->average_period), -- ngx_http_vhost_traffic_status_display_get_time_queue_times(r, -- &vtsn->stat_request_times), -- ngx_http_vhost_traffic_status_display_get_time_queue_msecs(r, -- &vtsn->stat_request_times), -- vtsn->stat_upstream.response_time_counter, -- ngx_http_vhost_traffic_status_node_time_queue_average( -- &vtsn->stat_upstream.response_times, vtscf->average_method, -- vtscf->average_period), -- ngx_http_vhost_traffic_status_display_get_time_queue_times(r, -- &vtsn->stat_upstream.response_times), -- ngx_http_vhost_traffic_status_display_get_time_queue_msecs(r, -- &vtsn->stat_upstream.response_times), -- us->weight, us->max_fails, -- us->fail_timeout, -- ngx_http_vhost_traffic_status_boolean_to_string(us->backup), -- ngx_http_vhost_traffic_status_boolean_to_string(us->down), -- ngx_http_vhost_traffic_status_max_integer, -- vtsn->stat_request_counter_oc, vtsn->stat_in_bytes_oc, -- vtsn->stat_out_bytes_oc, vtsn->stat_1xx_counter_oc, -- vtsn->stat_2xx_counter_oc, vtsn->stat_3xx_counter_oc, -- vtsn->stat_4xx_counter_oc, vtsn->stat_5xx_counter_oc, -- vtsn->stat_request_time_counter_oc, vtsn->stat_response_time_counter_oc); -- -- } else { -- buf = ngx_sprintf(buf, NGX_HTTP_VHOST_TRAFFIC_STATUS_JSON_FMT_UPSTREAM, -- &key, (ngx_atomic_uint_t) 0, -- (ngx_atomic_uint_t) 0, (ngx_atomic_uint_t) 0, -- (ngx_atomic_uint_t) 0, (ngx_atomic_uint_t) 0, -- (ngx_atomic_uint_t) 0, (ngx_atomic_uint_t) 0, -- (ngx_atomic_uint_t) 0, -- (ngx_atomic_uint_t) 0, -- (ngx_msec_t) 0, -- (u_char *) "", (u_char *) "", -- (ngx_atomic_uint_t) 0, -- (ngx_msec_t) 0, -- (u_char *) "", (u_char *) "", -- us->weight, us->max_fails, -- us->fail_timeout, -- ngx_http_vhost_traffic_status_boolean_to_string(us->backup), -- ngx_http_vhost_traffic_status_boolean_to_string(us->down), -- ngx_http_vhost_traffic_status_max_integer, -- (ngx_atomic_uint_t) 0, (ngx_atomic_uint_t) 0, -- (ngx_atomic_uint_t) 0, (ngx_atomic_uint_t) 0, -- (ngx_atomic_uint_t) 0, (ngx_atomic_uint_t) 0, -- (ngx_atomic_uint_t) 0, (ngx_atomic_uint_t) 0, -- (ngx_atomic_uint_t) 0, (ngx_atomic_uint_t) 0); -- } -- -- return buf; --} -- -- --u_char * --ngx_http_vhost_traffic_status_display_set_upstream_alone(ngx_http_request_t *r, -- u_char *buf, ngx_rbtree_node_t *node) --{ -- unsigned type; -- ngx_str_t key; -- ngx_http_upstream_server_t us; -- ngx_http_vhost_traffic_status_ctx_t *ctx; -- ngx_http_vhost_traffic_status_node_t *vtsn; -- -- ctx = ngx_http_get_module_main_conf(r, ngx_http_vhost_traffic_status_module); -- -- type = NGX_HTTP_VHOST_TRAFFIC_STATUS_UPSTREAM_UA; -- -- if (node != ctx->rbtree->sentinel) { -- vtsn = (ngx_http_vhost_traffic_status_node_t *) &node->color; -- -- if (vtsn->stat_upstream.type == type) { -- key.len = vtsn->len; -- key.data = vtsn->data; -- -- (void) ngx_http_vhost_traffic_status_node_position_key(&key, 1); -- --#if nginx_version > 1007001 -- us.name = key; --#endif -- us.weight = 0; -- us.max_fails = 0; -- us.fail_timeout = 0; -- us.down = 0; -- us.backup = 0; -- --#if nginx_version > 1007001 -- buf = ngx_http_vhost_traffic_status_display_set_upstream_node(r, buf, &us, vtsn); --#else -- buf = ngx_http_vhost_traffic_status_display_set_upstream_node(r, buf, &us, vtsn, &key); --#endif -- } -- -- buf = ngx_http_vhost_traffic_status_display_set_upstream_alone(r, buf, node->left); -- buf = ngx_http_vhost_traffic_status_display_set_upstream_alone(r, buf, node->right); -- } -- -- return buf; --} -- -- --u_char * --ngx_http_vhost_traffic_status_display_set_upstream_group(ngx_http_request_t *r, -- u_char *buf) --{ -- size_t len; -- u_char *p, *o, *s; -- uint32_t hash; -- unsigned type, zone; -- ngx_int_t rc; -- ngx_str_t key, dst; -- ngx_uint_t i, j; -- ngx_rbtree_node_t *node; -- ngx_http_upstream_server_t *us, usn; --#if (NGX_HTTP_UPSTREAM_ZONE) -- ngx_http_upstream_rr_peer_t *peer; -- ngx_http_upstream_rr_peers_t *peers; --#endif -- ngx_http_upstream_srv_conf_t *uscf, **uscfp; -- ngx_http_upstream_main_conf_t *umcf; -- ngx_http_vhost_traffic_status_ctx_t *ctx; -- ngx_http_vhost_traffic_status_node_t *vtsn; -- -- ctx = ngx_http_get_module_main_conf(r, ngx_http_vhost_traffic_status_module); -- umcf = ngx_http_get_module_main_conf(r, ngx_http_upstream_module); -- uscfp = umcf->upstreams.elts; -- -- len = 0; -- for (i = 0; i < umcf->upstreams.nelts; i++) { -- uscf = uscfp[i]; -- len = ngx_max(uscf->host.len, len); -- } -- -- dst.len = len + sizeof("@[ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255]:65535") - 1; -- dst.data = ngx_pnalloc(r->pool, dst.len); -- if (dst.data == NULL) { -- return buf; -- } -- -- p = dst.data; -- -- for (i = 0; i < umcf->upstreams.nelts; i++) { -- -- uscf = uscfp[i]; -- -- /* groups */ -- if (uscf->servers && !uscf->port) { -- us = uscf->servers->elts; -- -- type = NGX_HTTP_VHOST_TRAFFIC_STATUS_UPSTREAM_UG; -- -- o = buf; -- -- buf = ngx_sprintf(buf, NGX_HTTP_VHOST_TRAFFIC_STATUS_JSON_FMT_ARRAY_S, -- &uscf->host); -- s = buf; -- -- zone = 0; -- --#if (NGX_HTTP_UPSTREAM_ZONE) -- if (uscf->shm_zone == NULL) { -- goto not_supported; -- } -- -- zone = 1; -- -- peers = uscf->peer.data; -- -- ngx_http_upstream_rr_peers_rlock(peers); -- -- for (peer = peers->peer; peer; peer = peer->next) { -- p = ngx_cpymem(p, uscf->host.data, uscf->host.len); -- *p++ = NGX_HTTP_VHOST_TRAFFIC_STATUS_KEY_SEPARATOR; -- p = ngx_cpymem(p, peer->name.data, peer->name.len); -- -- dst.len = uscf->host.len + sizeof("@") - 1 + peer->name.len; -- -- rc = ngx_http_vhost_traffic_status_node_generate_key(r->pool, &key, &dst, type); -- if (rc != NGX_OK) { -- ngx_http_upstream_rr_peers_unlock(peers); -- return buf; -- } -- -- hash = ngx_crc32_short(key.data, key.len); -- node = ngx_http_vhost_traffic_status_node_lookup(ctx->rbtree, &key, hash); -- -- usn.weight = peer->weight; -- usn.max_fails = peer->max_fails; -- usn.fail_timeout = peer->fail_timeout; -- usn.backup = 0; -- usn.down = (peer->fails >= peer->max_fails || peer->down); -- --#if nginx_version > 1007001 -- usn.name = peer->name; --#endif -- -- if (node != NULL) { -- vtsn = (ngx_http_vhost_traffic_status_node_t *) &node->color; --#if nginx_version > 1007001 -- buf = ngx_http_vhost_traffic_status_display_set_upstream_node(r, buf, &usn, vtsn); --#else -- buf = ngx_http_vhost_traffic_status_display_set_upstream_node(r, buf, &usn, vtsn, &peer->name); --#endif -- -- } else { --#if nginx_version > 1007001 -- buf = ngx_http_vhost_traffic_status_display_set_upstream_node(r, buf, &usn, NULL); --#else -- buf = ngx_http_vhost_traffic_status_display_set_upstream_node(r, buf, &usn, NULL, &peer->name); --#endif -- } -- -- p = dst.data; -- } -- -- ngx_http_upstream_rr_peers_unlock(peers); -- --not_supported: -- --#endif -- -- for (j = 0; j < uscf->servers->nelts; j++) { -- usn = us[j]; -- -- if (zone && usn.backup != 1) { -- continue; -- } -- -- if (us[j].addrs == NULL) { -- continue; -- } -- -- p = ngx_cpymem(p, uscf->host.data, uscf->host.len); -- *p++ = NGX_HTTP_VHOST_TRAFFIC_STATUS_KEY_SEPARATOR; -- p = ngx_cpymem(p, us[j].addrs->name.data, us[j].addrs->name.len); -- -- dst.len = uscf->host.len + sizeof("@") - 1 + us[j].addrs->name.len; -- -- rc = ngx_http_vhost_traffic_status_node_generate_key(r->pool, &key, &dst, type); -- if (rc != NGX_OK) { -- return buf; -- } -- -- hash = ngx_crc32_short(key.data, key.len); -- node = ngx_http_vhost_traffic_status_node_lookup(ctx->rbtree, &key, hash); -- --#if nginx_version > 1007001 -- usn.name = us[j].addrs->name; --#endif -- -- if (node != NULL) { -- vtsn = (ngx_http_vhost_traffic_status_node_t *) &node->color; --#if nginx_version > 1007001 -- buf = ngx_http_vhost_traffic_status_display_set_upstream_node(r, buf, &usn, vtsn); --#else -- buf = ngx_http_vhost_traffic_status_display_set_upstream_node(r, buf, &usn, vtsn, &us[j].addrs->name); --#endif -- -- } else { --#if nginx_version > 1007001 -- buf = ngx_http_vhost_traffic_status_display_set_upstream_node(r, buf, &usn, NULL); --#else -- buf = ngx_http_vhost_traffic_status_display_set_upstream_node(r, buf, &usn, NULL, &us[j].addrs->name); --#endif -- } -- -- p = dst.data; -- } -- -- if (s == buf) { -- buf = o; -- -- } else { -- buf--; -- buf = ngx_sprintf(buf, NGX_HTTP_VHOST_TRAFFIC_STATUS_JSON_FMT_ARRAY_E); -- buf = ngx_sprintf(buf, NGX_HTTP_VHOST_TRAFFIC_STATUS_JSON_FMT_NEXT); -- } -- } -- } -- -- /* alones */ -- o = buf; -- -- ngx_str_set(&key, "::nogroups"); -- -- buf = ngx_sprintf(buf, NGX_HTTP_VHOST_TRAFFIC_STATUS_JSON_FMT_ARRAY_S, &key); -- -- s = buf; -- -- buf = ngx_http_vhost_traffic_status_display_set_upstream_alone(r, buf, ctx->rbtree->root); -- -- if (s == buf) { -- buf = o; -- -- } else { -- buf--; -- buf = ngx_sprintf(buf, NGX_HTTP_VHOST_TRAFFIC_STATUS_JSON_FMT_ARRAY_E); -- buf = ngx_sprintf(buf, NGX_HTTP_VHOST_TRAFFIC_STATUS_JSON_FMT_NEXT); -- } -- -- return buf; --} -- -- --#if (NGX_HTTP_CACHE) -- --u_char --*ngx_http_vhost_traffic_status_display_set_cache_node(ngx_http_request_t *r, -- u_char *buf, ngx_http_vhost_traffic_status_node_t *vtsn) --{ -- ngx_int_t rc; -- ngx_str_t key, dst; -- -- dst.data = vtsn->data; -- dst.len = vtsn->len; -- -- (void) ngx_http_vhost_traffic_status_node_position_key(&dst, 1); -- -- rc = ngx_http_vhost_traffic_status_escape_json_pool(r->pool, &key, &dst); -- if (rc != NGX_OK) { -- ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, -- "display_set_cache_node::escape_json_pool() failed"); -- } -- -- buf = ngx_sprintf(buf, NGX_HTTP_VHOST_TRAFFIC_STATUS_JSON_FMT_CACHE, -- &key, vtsn->stat_cache_max_size, -- vtsn->stat_cache_used_size, -- vtsn->stat_in_bytes, -- vtsn->stat_out_bytes, -- vtsn->stat_cache_miss_counter, -- vtsn->stat_cache_bypass_counter, -- vtsn->stat_cache_expired_counter, -- vtsn->stat_cache_stale_counter, -- vtsn->stat_cache_updating_counter, -- vtsn->stat_cache_revalidated_counter, -- vtsn->stat_cache_hit_counter, -- vtsn->stat_cache_scarce_counter, -- ngx_http_vhost_traffic_status_max_integer, -- vtsn->stat_request_counter_oc, -- vtsn->stat_in_bytes_oc, -- vtsn->stat_out_bytes_oc, -- vtsn->stat_1xx_counter_oc, -- vtsn->stat_2xx_counter_oc, -- vtsn->stat_3xx_counter_oc, -- vtsn->stat_4xx_counter_oc, -- vtsn->stat_5xx_counter_oc, -- vtsn->stat_cache_miss_counter_oc, -- vtsn->stat_cache_bypass_counter_oc, -- vtsn->stat_cache_expired_counter_oc, -- vtsn->stat_cache_stale_counter_oc, -- vtsn->stat_cache_updating_counter_oc, -- vtsn->stat_cache_revalidated_counter_oc, -- vtsn->stat_cache_hit_counter_oc, -- vtsn->stat_cache_scarce_counter_oc); -- -- return buf; --} -- -- --u_char * --ngx_http_vhost_traffic_status_display_set_cache(ngx_http_request_t *r, -- u_char *buf, ngx_rbtree_node_t *node) --{ -- ngx_http_vhost_traffic_status_ctx_t *ctx; -- ngx_http_vhost_traffic_status_node_t *vtsn; -- -- ctx = ngx_http_get_module_main_conf(r, ngx_http_vhost_traffic_status_module); -- -- if (node != ctx->rbtree->sentinel) { -- vtsn = (ngx_http_vhost_traffic_status_node_t *) &node->color; -- -- if (vtsn->stat_upstream.type == NGX_HTTP_VHOST_TRAFFIC_STATUS_UPSTREAM_CC) { -- buf = ngx_http_vhost_traffic_status_display_set_cache_node(r, buf, vtsn); -- } -- -- buf = ngx_http_vhost_traffic_status_display_set_cache(r, buf, node->left); -- buf = ngx_http_vhost_traffic_status_display_set_cache(r, buf, node->right); -- } -- -- return buf; --} -- --#endif -- -- --u_char * --ngx_http_vhost_traffic_status_display_set(ngx_http_request_t *r, -- u_char *buf) --{ -- u_char *o, *s; -- ngx_rbtree_node_t *node; -- ngx_http_vhost_traffic_status_ctx_t *ctx; -- ngx_http_vhost_traffic_status_loc_conf_t *vtscf; -- -- ctx = ngx_http_get_module_main_conf(r, ngx_http_vhost_traffic_status_module); -- -- vtscf = ngx_http_get_module_loc_conf(r, ngx_http_vhost_traffic_status_module); -- -- node = ctx->rbtree->root; -- -- /* init stats */ -- ngx_memzero(&vtscf->stats, sizeof(vtscf->stats)); -- ngx_http_vhost_traffic_status_node_time_queue_init(&vtscf->stats.stat_request_times); -- -- /* main & connections */ -- buf = ngx_sprintf(buf, NGX_HTTP_VHOST_TRAFFIC_STATUS_JSON_FMT_S); -- -- buf = ngx_http_vhost_traffic_status_display_set_main(r, buf); -- -- /* serverZones */ -- buf = ngx_sprintf(buf, NGX_HTTP_VHOST_TRAFFIC_STATUS_JSON_FMT_SERVER_S); -- -- buf = ngx_http_vhost_traffic_status_display_set_server(r, buf, node); -- -- buf = ngx_http_vhost_traffic_status_display_set_server_node(r, buf, &vtscf->sum_key, -- &vtscf->stats); -- -- buf--; -- buf = ngx_sprintf(buf, NGX_HTTP_VHOST_TRAFFIC_STATUS_JSON_FMT_E); -- buf = ngx_sprintf(buf, NGX_HTTP_VHOST_TRAFFIC_STATUS_JSON_FMT_NEXT); -- -- /* filterZones */ -- o = buf; -- -- buf = ngx_sprintf(buf, NGX_HTTP_VHOST_TRAFFIC_STATUS_JSON_FMT_FILTER_S); -- -- s = buf; -- -- buf = ngx_http_vhost_traffic_status_display_set_filter(r, buf, node); -- -- if (s == buf) { -- buf = o; -- -- } else { -- buf--; -- buf = ngx_sprintf(buf, NGX_HTTP_VHOST_TRAFFIC_STATUS_JSON_FMT_E); -- buf = ngx_sprintf(buf, NGX_HTTP_VHOST_TRAFFIC_STATUS_JSON_FMT_NEXT); -- } -- -- /* upstreamZones */ -- o = buf; -- -- buf = ngx_sprintf(buf, NGX_HTTP_VHOST_TRAFFIC_STATUS_JSON_FMT_UPSTREAM_S); -- -- s = buf; -- -- buf = ngx_http_vhost_traffic_status_display_set_upstream_group(r, buf); -- -- if (s == buf) { -- buf = o; -- buf--; -- -- } else { -- buf--; -- buf = ngx_sprintf(buf, NGX_HTTP_VHOST_TRAFFIC_STATUS_JSON_FMT_E); -- } -- --#if (NGX_HTTP_CACHE) -- /* cacheZones */ -- o = buf; -- -- buf = ngx_sprintf(buf, NGX_HTTP_VHOST_TRAFFIC_STATUS_JSON_FMT_NEXT); -- buf = ngx_sprintf(buf, NGX_HTTP_VHOST_TRAFFIC_STATUS_JSON_FMT_CACHE_S); -- -- s = buf; -- -- buf = ngx_http_vhost_traffic_status_display_set_cache(r, buf, node); -- -- if (s == buf) { -- buf = o; -- -- } else { -- buf--; -- buf = ngx_sprintf(buf, NGX_HTTP_VHOST_TRAFFIC_STATUS_JSON_FMT_E); -- } --#endif -- -- buf = ngx_sprintf(buf, NGX_HTTP_VHOST_TRAFFIC_STATUS_JSON_FMT_E); -- -- return buf; --} -- -- - char * - ngx_http_vhost_traffic_status_display(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) - { -diff --git a/src/ngx_http_vhost_traffic_status_display.h b/src/ngx_http_vhost_traffic_status_display.h -index 2e9dfbe..5693839 100644 ---- a/src/ngx_http_vhost_traffic_status_display.h -+++ b/src/ngx_http_vhost_traffic_status_display.h -@@ -24,47 +24,6 @@ u_char *ngx_http_vhost_traffic_status_display_get_time_queue_msecs( - ngx_http_request_t *r, - ngx_http_vhost_traffic_status_node_time_queue_t *q); - --u_char *ngx_http_vhost_traffic_status_display_set_main( -- ngx_http_request_t *r, u_char *buf); --u_char *ngx_http_vhost_traffic_status_display_set_server_node( -- ngx_http_request_t *r, -- u_char *buf, ngx_str_t *key, -- ngx_http_vhost_traffic_status_node_t *vtsn); --u_char *ngx_http_vhost_traffic_status_display_set_server( -- ngx_http_request_t *r, u_char *buf, -- ngx_rbtree_node_t *node); --u_char *ngx_http_vhost_traffic_status_display_set_filter_node( -- ngx_http_request_t *r, u_char *buf, -- ngx_http_vhost_traffic_status_node_t *vtsn); --u_char *ngx_http_vhost_traffic_status_display_set_filter( -- ngx_http_request_t *r, u_char *buf, -- ngx_rbtree_node_t *node); --u_char *ngx_http_vhost_traffic_status_display_set_upstream_node( -- ngx_http_request_t *r, u_char *buf, -- ngx_http_upstream_server_t *us, --#if nginx_version > 1007001 -- ngx_http_vhost_traffic_status_node_t *vtsn --#else -- ngx_http_vhost_traffic_status_node_t *vtsn, ngx_str_t *name --#endif -- ); --u_char *ngx_http_vhost_traffic_status_display_set_upstream_alone( -- ngx_http_request_t *r, u_char *buf, ngx_rbtree_node_t *node); --u_char *ngx_http_vhost_traffic_status_display_set_upstream_group( -- ngx_http_request_t *r, u_char *buf); -- --#if (NGX_HTTP_CACHE) --u_char *ngx_http_vhost_traffic_status_display_set_cache_node( -- ngx_http_request_t *r, u_char *buf, -- ngx_http_vhost_traffic_status_node_t *vtsn); --u_char *ngx_http_vhost_traffic_status_display_set_cache( -- ngx_http_request_t *r, u_char *buf, -- ngx_rbtree_node_t *node); --#endif -- --u_char *ngx_http_vhost_traffic_status_display_set(ngx_http_request_t *r, -- u_char *buf); -- - char *ngx_http_vhost_traffic_status_display(ngx_conf_t *cf, - ngx_command_t *cmd, void *conf); - -diff --git a/src/ngx_http_vhost_traffic_status_module.c b/src/ngx_http_vhost_traffic_status_module.c -index e817893..9d0fdb9 100644 ---- a/src/ngx_http_vhost_traffic_status_module.c -+++ b/src/ngx_http_vhost_traffic_status_module.c -@@ -44,6 +44,7 @@ static ngx_conf_enum_t ngx_http_vhost_traffic_status_display_format[] = { - { ngx_string("json"), NGX_HTTP_VHOST_TRAFFIC_STATUS_FORMAT_JSON }, - { ngx_string("html"), NGX_HTTP_VHOST_TRAFFIC_STATUS_FORMAT_HTML }, - { ngx_string("jsonp"), NGX_HTTP_VHOST_TRAFFIC_STATUS_FORMAT_JSONP }, -+ { ngx_string("prometheus"), NGX_HTTP_VHOST_TRAFFIC_STATUS_FORMAT_PROMETHEUS }, - { ngx_null_string, 0 } - }; - -diff --git a/src/ngx_http_vhost_traffic_status_module.h b/src/ngx_http_vhost_traffic_status_module.h -index 8f0a1e5..7a76a23 100644 ---- a/src/ngx_http_vhost_traffic_status_module.h -+++ b/src/ngx_http_vhost_traffic_status_module.h -@@ -33,6 +33,7 @@ - #define NGX_HTTP_VHOST_TRAFFIC_STATUS_FORMAT_JSON 1 - #define NGX_HTTP_VHOST_TRAFFIC_STATUS_FORMAT_HTML 2 - #define NGX_HTTP_VHOST_TRAFFIC_STATUS_FORMAT_JSONP 3 -+#define NGX_HTTP_VHOST_TRAFFIC_STATUS_FORMAT_PROMETHEUS 4 - - #define NGX_HTTP_VHOST_TRAFFIC_STATUS_AVERAGE_METHOD_AMM 0 - #define NGX_HTTP_VHOST_TRAFFIC_STATUS_AVERAGE_METHOD_WMA 1