From: Willy Tarreau Date: Mon, 11 Jan 2016 14:28:40 +0000 (+0100) Subject: MINOR: stats: add ST_SHOWADMIN to pass the admin info in the regular flags X-Git-Tag: v1.7-dev2~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=508a63fb968be573f5aeda32b31c3122518c919e;p=thirdparty%2Fhaproxy.git MINOR: stats: add ST_SHOWADMIN to pass the admin info in the regular flags It's easier to have a new flag in to indicate whether or not we want to display the admin column in HTML dumps. We already have similar flags to show the version or the legends. --- diff --git a/include/common/uri_auth.h b/include/common/uri_auth.h index 495d240d04..e80722d4eb 100644 --- a/include/common/uri_auth.h +++ b/include/common/uri_auth.h @@ -31,6 +31,7 @@ struct stat_scope { #define ST_SHDESC 0x00000004 /* show description */ #define ST_SHLGNDS 0x00000008 /* show legends */ #define ST_CONVDONE 0x00000010 /* req_acl conversion done */ +#define ST_SHOWADMIN 0x00000020 /* show the admin column */ /* later we may link them to support multiple URI matching */ struct uri_auth { diff --git a/src/dumpstats.c b/src/dumpstats.c index f7e759743f..0bcead6819 100644 --- a/src/dumpstats.c +++ b/src/dumpstats.c @@ -3260,11 +3260,11 @@ static int stats_dump_fields_csv(struct chunk *out, const struct field *stats) return 1; } -/* Dump all fields from into trash using the HTML format. - * A column is reserved for the checkbox is is non-null. The caller's - * flags may be passed in (eg: SHLGNDS to show the legends). +/* Dump all fields from into trash using the HTML format. A column is + * reserved for the checkbox is ST_SHOWADMIN is set in . Some extra info + * are provided if ST_SHLGNDS is present in . */ -static int stats_dump_fields_html(const struct field *stats, int admin, unsigned int flags) +static int stats_dump_fields_html(const struct field *stats, unsigned int flags) { struct chunk src; @@ -3273,7 +3273,7 @@ static int stats_dump_fields_html(const struct field *stats, int admin, unsigned /* name, queue */ ""); - if (admin) { + if (flags & ST_SHOWADMIN) { /* Column sub-heading for Enable or Disable server */ chunk_appendf(&trash, ""); } @@ -3408,7 +3408,7 @@ static int stats_dump_fields_html(const struct field *stats, int admin, unsigned } else if (stats[ST_F_TYPE].u.u32 == STATS_TYPE_SO) { chunk_appendf(&trash, ""); - if (admin) { + if (flags & ST_SHOWADMIN) { /* Column sub-heading for Enable or Disable server */ chunk_appendf(&trash, ""); } @@ -3513,7 +3513,7 @@ static int stats_dump_fields_html(const struct field *stats, int admin, unsigned (stats[ST_F_BCK].u.u32) ? "backup" : "active", style); - if (admin) + if (flags & ST_SHOWADMIN) chunk_appendf(&trash, "", field_str(stats, ST_F_SVNAME)); @@ -3745,7 +3745,7 @@ static int stats_dump_fields_html(const struct field *stats, int admin, unsigned } else if (stats[ST_F_TYPE].u.u32 == STATS_TYPE_BE) { chunk_appendf(&trash, ""); - if (admin) { + if (flags & ST_SHOWADMIN) { /* Column sub-heading for Enable or Disable server */ chunk_appendf(&trash, ""); } @@ -3899,12 +3899,11 @@ static int stats_dump_fields_html(const struct field *stats, int admin, unsigned static int stats_dump_one_line(const struct field *stats, unsigned int flags, struct proxy *px, struct appctx *appctx) { - int admin; - - admin = (px->cap & PR_CAP_BE) && px->srv && (appctx->ctx.stats.flags & STAT_ADMIN); + if ((px->cap & PR_CAP_BE) && px->srv && (appctx->ctx.stats.flags & STAT_ADMIN)) + flags |= ST_SHOWADMIN; if (appctx->ctx.stats.flags & STAT_FMT_HTML) - return stats_dump_fields_html(stats, admin, flags); + return stats_dump_fields_html(stats, flags); else return stats_dump_fields_csv(&trash, stats); }