]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stats: add ST_SHOWADMIN to pass the admin info in the regular flags
authorWilly Tarreau <w@1wt.eu>
Mon, 11 Jan 2016 14:28:40 +0000 (15:28 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 11 Mar 2016 16:08:05 +0000 (17:08 +0100)
It's easier to have a new flag in <flags> 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.

include/common/uri_auth.h
src/dumpstats.c

index 495d240d04fe8a8e73ac8d5f1305c5c49b4fd0b4..e80722d4ebb20c7c1e57611767cafdbb8eda1da8 100644 (file)
@@ -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 {
index f7e759743f9f586a9d1db10a62fd102864a97117..0bcead681996bdd2ce6ff0bdc3ad1721d23c814b 100644 (file)
@@ -3260,11 +3260,11 @@ static int stats_dump_fields_csv(struct chunk *out, const struct field *stats)
        return 1;
 }
 
-/* Dump all fields from <stats> into trash using the HTML format.
- * A column is reserved for the checkbox is <admin> is non-null. The caller's
- * flags may be passed in <flags> (eg: SHLGNDS to show the legends).
+/* Dump all fields from <stats> into trash using the HTML format. A column is
+ * reserved for the checkbox is ST_SHOWADMIN is set in <flags>. Some extra info
+ * are provided if ST_SHLGNDS is present in <flags>.
  */
-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 */
                              "<tr class=\"frontend\">");
 
-               if (admin) {
+               if (flags & ST_SHOWADMIN) {
                        /* Column sub-heading for Enable or Disable server */
                        chunk_appendf(&trash, "<td></td>");
                }
@@ -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, "<tr class=socket>");
-               if (admin) {
+               if (flags & ST_SHOWADMIN) {
                        /* Column sub-heading for Enable or Disable server */
                        chunk_appendf(&trash, "<td></td>");
                }
@@ -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,
                                      "<td><input type=\"checkbox\" name=\"s\" value=\"%s\"></td>",
                                      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, "<tr class=\"backend\">");
-               if (admin) {
+               if (flags & ST_SHOWADMIN) {
                        /* Column sub-heading for Enable or Disable server */
                        chunk_appendf(&trash, "<td></td>");
                }
@@ -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);
 }