From: Amaury Denoyelle Date: Mon, 5 Oct 2020 09:49:45 +0000 (+0200) Subject: MINOR: stats: add config "stats show modules" X-Git-Tag: v2.3-dev6~96 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0b70a8a314e9e376c153ad8512f4a70efaca241e;p=thirdparty%2Fhaproxy.git MINOR: stats: add config "stats show modules" By default, hide the extra statistics on the html page. Define a new flag STAT_SHMODULES which is activated if the config "stats show modules" is set. --- diff --git a/doc/configuration.txt b/doc/configuration.txt index b01129f8f2..f6eacfbfae 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -10036,6 +10036,22 @@ stats show-legends See also: "stats enable", "stats uri". +stats show-modules + Enable display of extra statistics module on the statistics page + May be used in sections : defaults | frontend | listen | backend + yes | yes | yes | yes + Arguments : none + + New columns are added at the end of the line containing the extra statistics + values as a tooltip. + + Though this statement alone is enough to enable statistics reporting, it is + recommended to set all other settings in order to avoid relying on default + unobvious parameters. Default behavior is not to show this information. + + See also: "stats enable", "stats uri". + + stats show-node [ ] Enable reporting of a host name on the statistics page. May be used in sections : defaults | frontend | listen | backend diff --git a/include/haproxy/stats-t.h b/include/haproxy/stats-t.h index 96dcf18d89..d148651247 100644 --- a/include/haproxy/stats-t.h +++ b/include/haproxy/stats-t.h @@ -39,6 +39,7 @@ #define STAT_SHDESC 0x00000400 /* conf: show description */ #define STAT_SHLGNDS 0x00000800 /* conf: show legends */ #define STAT_SHOW_FDESC 0x00001000 /* show the field descriptions when possible */ +#define STAT_SHMODULES 0x00002000 /* conf: show modules */ #define STAT_BOUND 0x00800000 /* bound statistics to selected proxies/types/services */ #define STAT_STARTED 0x01000000 /* some output has occurred */ diff --git a/src/cfgparse-listen.c b/src/cfgparse-listen.c index b8f3795247..c2db644c8e 100644 --- a/src/cfgparse-listen.c +++ b/src/cfgparse-listen.c @@ -1923,6 +1923,12 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm) err_code |= ERR_ALERT | ERR_ABORT; goto out; } + } else if (!strcmp(args[1], "show-modules")) { + if (!stats_set_flag(&curproxy->uri_auth, STAT_SHMODULES)) { + ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum); + err_code |= ERR_ALERT | ERR_ABORT; + goto out; + } } else if (!strcmp(args[1], "show-node")) { if (*args[2]) { diff --git a/src/stats.c b/src/stats.c index ae2f58d2b7..f84488a177 100644 --- a/src/stats.c +++ b/src/stats.c @@ -764,7 +764,9 @@ err: /* Dump all fields from into using the HTML format. A column is * reserved for the checkbox is STAT_ADMIN is set in . Some extra info - * are provided if STAT_SHLGNDS is present in . + * are provided if STAT_SHLGNDS is present in . The statistics from + * extra modules are displayed at the end of the lines if STAT_SHMODULES is + * present in . */ static int stats_dump_fields_html(struct buffer *out, const struct field *stats, @@ -922,23 +924,25 @@ static int stats_dump_fields_html(struct buffer *out, U2H(stats[ST_F_EREQ].u.u64), field_str(stats, ST_F_STATUS)); - list_for_each_entry(mod, &stats_module_list[STATS_DOMAIN_PROXY], list) { - chunk_appendf(out, - "%s
", - mod->name); - if (stats_px_get_cap(mod->domain_flags) & STATS_PX_CAP_FE) { - for (j = 0; j < mod->stats_count; ++j) { - chunk_appendf(out, - "", - mod->stats[j].desc, field_to_html_str(&stats[ST_F_TOTAL_FIELDS + i])); - ++i; + if (flags & STAT_SHMODULES) { + list_for_each_entry(mod, &stats_module_list[STATS_DOMAIN_PROXY], list) { + chunk_appendf(out, + ""); + chunk_appendf(out, + "
%s%s
%s
", + mod->name); + if (stats_px_get_cap(mod->domain_flags) & STATS_PX_CAP_FE) { + for (j = 0; j < mod->stats_count; ++j) { + chunk_appendf(out, + "", + mod->stats[j].desc, field_to_html_str(&stats[ST_F_TOTAL_FIELDS + i])); + ++i; + } + } else { + i += mod->stats_count; } - } else { - i += mod->stats_count; - } - chunk_appendf(out, - "
%s%s
"); + } } chunk_appendf(out, ""); @@ -1004,23 +1008,25 @@ static int stats_dump_fields_html(struct buffer *out, U2H(stats[ST_F_EREQ].u.u64), field_str(stats, ST_F_STATUS)); - list_for_each_entry(mod, &stats_module_list[STATS_DOMAIN_PROXY], list) { - chunk_appendf(out, - "%s
", - mod->name); - if (stats_px_get_cap(mod->domain_flags) & STATS_PX_CAP_LI) { - for (j = 0; j < mod->stats_count; ++j) { - chunk_appendf(out, - "", - mod->stats[j].desc, field_to_html_str(&stats[ST_F_TOTAL_FIELDS + i])); - ++i; + if (flags & STAT_SHMODULES) { + list_for_each_entry(mod, &stats_module_list[STATS_DOMAIN_PROXY], list) { + chunk_appendf(out, + ""); + chunk_appendf(out, + "
%s%s
%s
", + mod->name); + if (stats_px_get_cap(mod->domain_flags) & STATS_PX_CAP_LI) { + for (j = 0; j < mod->stats_count; ++j) { + chunk_appendf(out, + "", + mod->stats[j].desc, field_to_html_str(&stats[ST_F_TOTAL_FIELDS + i])); + ++i; + } + } else { + i += mod->stats_count; } - } else { - i += mod->stats_count; - } - chunk_appendf(out, - "
%s%s
"); + } } chunk_appendf(out, ""); @@ -1340,23 +1346,25 @@ static int stats_dump_fields_html(struct buffer *out, else chunk_appendf(out, "-"); - list_for_each_entry(mod, &stats_module_list[STATS_DOMAIN_PROXY], list) { - chunk_appendf(out, - "%s
", - mod->name); - if (stats_px_get_cap(mod->domain_flags) & STATS_PX_CAP_SRV) { - for (j = 0; j < mod->stats_count; ++j) { - chunk_appendf(out, - "", - mod->stats[j].desc, field_to_html_str(&stats[ST_F_TOTAL_FIELDS + i])); - ++i; + if (flags & STAT_SHMODULES) { + list_for_each_entry(mod, &stats_module_list[STATS_DOMAIN_PROXY], list) { + chunk_appendf(out, + ""); + chunk_appendf(out, + "
%s%s
%s
", + mod->name); + if (stats_px_get_cap(mod->domain_flags) & STATS_PX_CAP_SRV) { + for (j = 0; j < mod->stats_count; ++j) { + chunk_appendf(out, + "", + mod->stats[j].desc, field_to_html_str(&stats[ST_F_TOTAL_FIELDS + i])); + ++i; + } + } else { + i += mod->stats_count; } - } else { - i += mod->stats_count; - } - chunk_appendf(out, - "
%s%s
"); + } } chunk_appendf(out, "\n"); @@ -1529,23 +1537,26 @@ static int stats_dump_fields_html(struct buffer *out, stats[ST_F_CHKDOWN].u.u32, stats[ST_F_DOWNTIME].type ? human_time(stats[ST_F_DOWNTIME].u.u32, 1) : " "); - list_for_each_entry(mod, &stats_module_list[STATS_DOMAIN_PROXY], list) { - chunk_appendf(out, - "%s
", - mod->name); - if (stats_px_get_cap(mod->domain_flags) & STATS_PX_CAP_BE) { - for (j = 0; j < mod->stats_count; ++j) { - chunk_appendf(out, - "", - mod->stats[j].desc, field_to_html_str(&stats[ST_F_TOTAL_FIELDS + i])); - ++i; + if (flags & STAT_SHMODULES) { + list_for_each_entry(mod, &stats_module_list[STATS_DOMAIN_PROXY], list) { + chunk_appendf(out, + ""); } - chunk_appendf(out, - "
%s%s
%s
", + mod->name); + if (stats_px_get_cap(mod->domain_flags) & STATS_PX_CAP_BE) { + for (j = 0; j < mod->stats_count; ++j) { + chunk_appendf(out, + "", + mod->stats[j].desc, field_to_html_str(&stats[ST_F_TOTAL_FIELDS + i])); + ++i; + } + } else { + i += mod->stats_count; } - } else { - i += mod->stats_count; + chunk_appendf(out, + "
%s%s
"); } + chunk_appendf(out, ""); } @@ -2316,19 +2327,24 @@ static void stats_dump_html_px_hdr(struct stream_interface *si, struct proxy *px chunk_appendf(&trash, ""); } - // calculate the count of module for colspan attribute - list_for_each_entry(mod, &stats_module_list[STATS_DOMAIN_PROXY], list) { - ++stats_module_len; - } - chunk_appendf(&trash, "" "Queue" "Session rateSessions" "BytesDenied" "ErrorsWarnings" - "Server" - "Extra modules" + "Server"); + + if (appctx->ctx.stats.flags & STAT_SHMODULES) { + // calculate the count of module for colspan attribute + list_for_each_entry(mod, &stats_module_list[STATS_DOMAIN_PROXY], list) { + ++stats_module_len; + } + chunk_appendf(&trash, "Extra modules", + stats_module_len); + } + + chunk_appendf(&trash, "\n" "" "CurMaxLimit" @@ -2338,10 +2354,12 @@ static void stats_dump_html_px_hdr(struct stream_interface *si, struct proxy *px "RespRetrRedis" "StatusLastChkWghtAct" "BckChkDwnDwntme" - "Thrtle\n", stats_module_len); + "Thrtle\n"); - list_for_each_entry(mod, &stats_module_list[STATS_DOMAIN_PROXY], list) { - chunk_appendf(&trash, "%s", mod->name); + if (appctx->ctx.stats.flags & STAT_SHMODULES) { + list_for_each_entry(mod, &stats_module_list[STATS_DOMAIN_PROXY], list) { + chunk_appendf(&trash, "%s", mod->name); + } } chunk_appendf(&trash, "");