]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stats: report the number of idle connections for each server
authorWilly Tarreau <w@1wt.eu>
Sun, 8 Sep 2019 07:24:56 +0000 (09:24 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 8 Sep 2019 07:30:50 +0000 (09:30 +0200)
This adds two extra fields to the stats, one for the current number of idle
connections and one for the configured limit. A tooltip link now appears on
the HTML page to show these values in front of the active connection values.

This should be backported to 2.0 and 1.9 as it's the only way to monitor
the idle connections behaviour.

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

index 5a7aa981347e9df62dbbeacc86743ac5c7fcacfb..2a71ff64ef54b6ef3d88da4e4c1f68e96ebdcf1e 100644 (file)
@@ -415,6 +415,8 @@ enum stat_field {
        ST_F_REUSE,
        ST_F_CACHE_LOOKUPS,
        ST_F_CACHE_HITS,
+       ST_F_SRV_ICUR,
+       ST_F_SRV_ILIM,
 
        /* must always be the last one */
        ST_F_TOTAL_FIELDS
index 01fcb4586b53c4347abcf59543cc94cbc0bab0ba..34efbfbbb0e9411ef418a182330fa24610f4532a 100644 (file)
@@ -974,11 +974,23 @@ static int stats_dump_fields_html(struct buffer *out,
 
                chunk_appendf(out,
                              /* sessions: current, max, limit, total */
-                             "<td>%s</td><td>%s</td><td>%s</td>"
+                             "<td><u>%s<div class=tips>"
+                               "<table class=det>"
+                               "<tr><th>Current active connections:</th><td>%s</td></tr>"
+                               "<tr><th>Current idle connections:</th><td>%s</td></tr>"
+                               "<tr><th>Active connections limit:</th><td>%s</td></tr>"
+                               "<tr><th>Idle connections limit:</th><td>%s</td></tr>"
+                               "</table></div></u>"
+                             "</td><td>%s</td><td>%s</td>"
                              "<td><u>%s<div class=tips><table class=det>"
                              "<tr><th>Cum. sessions:</th><td>%s</td></tr>"
                              "",
-                             U2H(stats[ST_F_SCUR].u.u32), U2H(stats[ST_F_SMAX].u.u32), LIM2A(stats[ST_F_SLIM].u.u32, "-"),
+                             U2H(stats[ST_F_SCUR].u.u32),
+                               U2H(stats[ST_F_SCUR].u.u32),
+                               U2H(stats[ST_F_SRV_ICUR].u.u32),
+                               LIM2A(stats[ST_F_SLIM].u.u32, "-"),
+                               stats[ST_F_SRV_ILIM].type ? U2H(stats[ST_F_SRV_ILIM].u.u32) : "-",
+                             U2H(stats[ST_F_SMAX].u.u32), LIM2A(stats[ST_F_SLIM].u.u32, "-"),
                              U2H(stats[ST_F_STOT].u.u64),
                              U2H(stats[ST_F_STOT].u.u64));
 
@@ -1641,6 +1653,10 @@ int stats_fill_sv_stats(struct proxy *px, struct server *sv, int flags,
        if (sv->maxconn)
                stats[ST_F_SLIM] = mkf_u32(FO_CONFIG|FN_LIMIT, sv->maxconn);
 
+       stats[ST_F_SRV_ICUR] = mkf_u32(0, sv->curr_idle_conns);
+       if (sv->max_idle_conns != -1)
+               stats[ST_F_SRV_ILIM] = mkf_u32(FO_CONFIG|FN_LIMIT, sv->max_idle_conns);
+
        stats[ST_F_STOT]     = mkf_u64(FN_COUNTER, sv->counters.cum_sess);
        stats[ST_F_BIN]      = mkf_u64(FN_COUNTER, sv->counters.bytes_in);
        stats[ST_F_BOUT]     = mkf_u64(FN_COUNTER, sv->counters.bytes_out);