]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stats: report BE unpublished status
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 13 Jan 2026 15:24:52 +0000 (16:24 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 15 Jan 2026 08:08:18 +0000 (09:08 +0100)
A previous patch defines a new proxy status : unpublished backends. This
patch extends this by changing proxy status reported in stats. If
unpublished is set, an extra "(UNPUB)" is added to the field.

Also, HTML stats is also slightly updated. If a backend is up but
unpublished, its status will be reported in orange color.

src/stats-html.c
src/stats-proxy.c

index b18d64195b8da7adc84257c29376233324d58dd9..79ffc9731d12c907b02f38826651d89d6f36d3cd 100644 (file)
@@ -1133,6 +1133,23 @@ int stats_dump_fields_html(struct buffer *out,
                chunk_appendf(out, "</tr>\n");
        }
        else if (stats[ST_I_PX_TYPE].u.u32 == STATS_TYPE_BE) {
+               struct ist ist_status = ist(field_str(stats, ST_I_PX_STATUS));
+               struct buffer buf_status;
+               char status[64];
+
+               buf_status = b_make(status, sizeof(status), 0, 0);
+               if (istmatch(ist_status, ist("DOWN"))) {
+                       chunk_appendf(&buf_status, "<font color=\"%s\"><b>%s</b></font>",
+                                     "red", field_str(stats, ST_I_PX_STATUS));
+               }
+               else if (istist(ist_status, ist("UNPUB")).len != 0) {
+                       chunk_appendf(&buf_status, "<font color=\"%s\"><b>%s</b></font>",
+                                     "orange", field_str(stats, ST_I_PX_STATUS));
+               }
+               else {
+                       chunk_appendf(&buf_status, "%s", field_str(stats, ST_I_PX_STATUS));
+               }
+
                chunk_appendf(out, "<tr class=\"backend\">");
                if (flags & STAT_F_ADMIN) {
                        /* Column sub-heading for Enable or Disable server */
@@ -1298,7 +1315,7 @@ int stats_dump_fields_html(struct buffer *out,
                              (long long)stats[ST_I_PX_SRV_ABRT].u.u64,
                              (long long)stats[ST_I_PX_WRETR].u.u64, (long long)stats[ST_I_PX_WREDIS].u.u64,
                              human_time(stats[ST_I_PX_LASTCHG].u.u32, 1),
-                             strcmp(field_str(stats, ST_I_PX_STATUS), "DOWN") ? field_str(stats, ST_I_PX_STATUS) : "<font color=\"red\"><b>DOWN</b></font>",
+                             status,
                              stats[ST_I_PX_WEIGHT].u.u32, stats[ST_I_PX_UWEIGHT].u.u32,
                              stats[ST_I_PX_ACT].u.u32, stats[ST_I_PX_BCK].u.u32);
 
index 03b1999c0dca92c0b8cc803905d2a36f518ea971..8d15d7bdf47be2f7d2188384831aa0823543e4ea 100644 (file)
@@ -1262,6 +1262,8 @@ int stats_fill_be_line(struct proxy *px, int flags, struct field *line, int len,
                        case ST_I_PX_STATUS:
                                fld = chunk_newstr(out);
                                chunk_appendf(out, "%s", (px->lbprm.tot_weight > 0 || !px->srv) ? "UP" : "DOWN");
+                               if (px->flags & PR_FL_BE_UNPUBLISHED)
+                                       chunk_appendf(out, " (UNPUB)");
                                if (flags & (STAT_F_HIDE_MAINT|STAT_F_HIDE_DOWN))
                                        chunk_appendf(out, " (%d/%d)", nbup, nbsrv);
                                field = mkf_str(FO_STATUS, fld);