]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stats: get rid of the STAT_SHOWADMIN flag
authorWilly Tarreau <w@1wt.eu>
Wed, 9 Oct 2019 09:11:46 +0000 (11:11 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 10 Oct 2019 09:30:07 +0000 (11:30 +0200)
This flag is used to decide to show the check box in front of a proxy
on the HTML stat page. It is always equal to STAT_ADMIN except when the
proxy has no backend capability (i.e. a pure frontend) or has no server,
in which case it's only used to avoid leaving an empty column at the
beginning of the table. Not only this is pretty useless, but it also
causes the columns not to align well when mixing multiple proxies with
or without servers.

Let's simply always use STAT_ADMIN and get rid of this flag.

include/types/stats.h
src/stats.c

index ee16ac7509727ec581a1feb86aa6ac70ac165aaf..d078b676d89e731918222fad2a3c9e9c7679389c 100644 (file)
@@ -34,7 +34,6 @@
 #define STAT_SHNODE     0x00000200      /* conf: show node name */
 #define STAT_SHDESC     0x00000400      /* conf: show description */
 #define STAT_SHLGNDS    0x00000800      /* conf: show legends */
-#define STAT_SHOWADMIN  0x00001000      /* conf: show the admin column */
 
 #define STAT_BOUND      0x00800000     /* bound statistics to selected proxies/types/services */
 #define STAT_STARTED    0x01000000     /* some output has occurred */
index afa2e305f899ad8d65659560d4c8aa86924c6c44..d464bd582203f326a996a257598fcb4ed5bcb525 100644 (file)
@@ -670,7 +670,7 @@ err:
 }
 
 /* Dump all fields from <stats> into <out> using the HTML format. A column is
- * reserved for the checkbox is STAT_SHOWADMIN is set in <flags>. Some extra info
+ * reserved for the checkbox is STAT_ADMIN is set in <flags>. Some extra info
  * are provided if STAT_SHLGNDS is present in <flags>.
  */
 static int stats_dump_fields_html(struct buffer *out,
@@ -684,7 +684,7 @@ static int stats_dump_fields_html(struct buffer *out,
                              /* name, queue */
                              "<tr class=\"frontend\">");
 
-               if (flags & STAT_SHOWADMIN) {
+               if (flags & STAT_ADMIN) {
                        /* Column sub-heading for Enable or Disable server */
                        chunk_appendf(out, "<td></td>");
                }
@@ -827,7 +827,7 @@ static int stats_dump_fields_html(struct buffer *out,
        }
        else if (stats[ST_F_TYPE].u.u32 == STATS_TYPE_SO) {
                chunk_appendf(out, "<tr class=socket>");
-               if (flags & STAT_SHOWADMIN) {
+               if (flags & STAT_ADMIN) {
                        /* Column sub-heading for Enable or Disable server */
                        chunk_appendf(out, "<td></td>");
                }
@@ -932,7 +932,7 @@ static int stats_dump_fields_html(struct buffer *out,
                                      (stats[ST_F_BCK].u.u32) ? "backup" : "active", style);
 
 
-               if (flags & STAT_SHOWADMIN)
+               if (flags & STAT_ADMIN)
                        chunk_appendf(out,
                                      "<td><input class='%s-checkbox' type=\"checkbox\" name=\"s\" value=\"%s\"></td>",
                                      field_str(stats, ST_F_PXNAME),
@@ -1188,7 +1188,7 @@ static int stats_dump_fields_html(struct buffer *out,
        }
        else if (stats[ST_F_TYPE].u.u32 == STATS_TYPE_BE) {
                chunk_appendf(out, "<tr class=\"backend\">");
-               if (flags & STAT_SHOWADMIN) {
+               if (flags & STAT_ADMIN) {
                        /* Column sub-heading for Enable or Disable server */
                        chunk_appendf(out, "<td></td>");
                }
@@ -1356,9 +1356,7 @@ int stats_dump_one_line(const struct field *stats, unsigned int flags, struct pr
 {
        int ret;
 
-       if ((px->cap & PR_CAP_BE) && px->srv && (appctx->ctx.stats.flags & STAT_ADMIN))
-               flags |= STAT_SHOWADMIN;
-
+       flags |= appctx->ctx.stats.flags & STAT_ADMIN;
        if (appctx->ctx.stats.flags & STAT_FMT_HTML)
                ret = stats_dump_fields_html(&trash, stats, flags);
        else if (appctx->ctx.stats.flags & STAT_FMT_TYPED)