diff --git a/include/types/session.h b/include/types/session.h
index 819acfd74..a76861912 100644
--- a/include/types/session.h
+++ b/include/types/session.h
@@ -74,6 +74,9 @@
#define SN_FINST_SHIFT 12 /* bit shift */
/* unused: 0x00008000 */
+#define SN_STAT_HIDEDWN 0x00010000 /* hide 'down' servers in the stats page */
+#define SN_STAT_NORFRSH 0x00020000 /* do not automatically refresh the stats page */
+
/* WARNING: if new fields are added, they must be initialized in event_accept()
* and freed in session_free() !
diff --git a/src/proto_http.c b/src/proto_http.c
index 8ebdc6116..7a86d1159 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -3453,7 +3453,7 @@ int produce_content_stats(struct session *s)
"Connection: close\r\n"
"Content-Type: text/html\r\n");
- if (s->be->uri_auth->refresh > 0)
+ if (s->be->uri_auth->refresh > 0 && !(s->flags & SN_STAT_NORFRSH))
chunk_printf(&msg, sizeof(trash), "Refresh: %d\r\n",
s->be->uri_auth->refresh);
@@ -3569,7 +3569,7 @@ int produce_content_stats(struct session *s)
"
Statistics Report for pid %d
\n"
"
\n"
"> General process information
\n"
- "\n"
+ "\n"
" pid = %d (nbproc = %d) \n"
"uptime = %dd %dh%02dm%02ds \n"
"system limits : memmax = %s%s ; ulimit-n = %d \n"
@@ -3590,14 +3590,8 @@ int produce_content_stats(struct session *s)
" | | not checked | "
" \n"
" | "
- ""
- "External ressources:"
- " | "
- "
\n"
+ ""
+ "Display option:"
"",
pid, pid, global.nbproc,
up / 86400, (up % 86400) / 3600,
@@ -3610,6 +3604,53 @@ int produce_content_stats(struct session *s)
actconn
);
+ if (s->flags & SN_STAT_HIDEDWN)
+ chunk_printf(&msg, sizeof(trash),
+ "- Show all servers
\n",
+ s->be->uri_auth->uri_prefix,
+ "",
+ (s->flags & SN_STAT_NORFRSH) ? ";norefresh" : "");
+ else
+ chunk_printf(&msg, sizeof(trash),
+ " - Hide 'DOWN' servers
\n",
+ s->be->uri_auth->uri_prefix,
+ ";up",
+ (s->flags & SN_STAT_NORFRSH) ? ";norefresh" : "");
+
+ if (s->be->uri_auth->refresh > 0) {
+ if (s->flags & SN_STAT_NORFRSH)
+ chunk_printf(&msg, sizeof(trash),
+ " - Enable refresh
\n",
+ s->be->uri_auth->uri_prefix,
+ (s->flags & SN_STAT_HIDEDWN) ? ";up" : "",
+ "");
+ else
+ chunk_printf(&msg, sizeof(trash),
+ " - Disable refresh
\n",
+ s->be->uri_auth->uri_prefix,
+ (s->flags & SN_STAT_HIDEDWN) ? ";up" : "",
+ ";norefresh");
+ }
+
+ chunk_printf(&msg, sizeof(trash),
+ " - Refresh now
\n",
+ s->be->uri_auth->uri_prefix,
+ (s->flags & SN_STAT_HIDEDWN) ? ";up" : "",
+ (s->flags & SN_STAT_NORFRSH) ? ";norefresh" : "");
+
+ chunk_printf(&msg, sizeof(trash),
+ " | "
+ ""
+ "External ressources:"
+ " | "
+ "\n"
+ ""
+ );
+
if (buffer_write_chunk(rep, &msg) != 0)
return 0;
@@ -3793,6 +3834,12 @@ int produce_content_stats_proxy(struct session *s, struct proxy *px)
else
sv_state = 0; /* DOWN */
+ if ((sv_state == 0) && (s->flags & SN_STAT_HIDEDWN)) {
+ /* do not report servers which are DOWN */
+ s->data_ctx.stats.sv = sv->next;
+ continue;
+ }
+
chunk_printf(&msg, sizeof(trash),
/* name */
"%s | "
@@ -5189,6 +5236,26 @@ int stats_check_uri_auth(struct session *t, struct proxy *backend)
if (memcmp(h, uri_auth->uri_prefix, uri_auth->uri_len) != 0)
return 0;
+ h += uri_auth->uri_len;
+ while (h <= t->req->data + txn->req.sl.rq.u + txn->req.sl.rq.u_l - 3) {
+ if (memcmp(h, ";up", 3) == 0) {
+ t->flags |= SN_STAT_HIDEDWN;
+ break;
+ }
+ h++;
+ }
+
+ if (uri_auth->refresh) {
+ h = t->req->data + txn->req.sl.rq.u + uri_auth->uri_len;
+ while (h <= t->req->data + txn->req.sl.rq.u + txn->req.sl.rq.u_l - 10) {
+ if (memcmp(h, ";norefresh", 10) == 0) {
+ t->flags |= SN_STAT_NORFRSH;
+ break;
+ }
+ h++;
+ }
+ }
+
/* we are in front of a interceptable URI. Let's check
* if there's an authentication and if it's valid.
*/