]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stats-html: Display reuse ratio for spop connections
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 9 Jul 2024 05:49:49 +0000 (07:49 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 12 Jul 2024 13:27:05 +0000 (15:27 +0200)
Now SPOP connections can be reused, it could be pretty useful to know the
reuse rate. The corresponding backend and server counters are already
incremented, but not displayed on the stats HTML page. Thanks to this patch,
it is now possible to get it, just like for HTTP proxies.

The related issue is #2502.

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

index 41eaa9e896272c9e329b5687e37f2acfec276823..e27ff8e40dfa60615806ef1824e6c42b70adbe72 100644 (file)
@@ -944,6 +944,16 @@ int stats_dump_fields_html(struct buffer *out,
                                      U2H(stats[ST_I_PX_WREW].u.u64),
                                      U2H(stats[ST_I_PX_EINT].u.u64));
                }
+               else if (strcmp(field_str(stats, ST_I_PX_MODE), "spop") == 0) {
+                       chunk_appendf(out,
+                                     "<tr><th>New connections:</th><td>%s</td></tr>"
+                                     "<tr><th>Reused connections:</th><td>%s</td><td>(%d%%)</td></tr>"
+                                     "",
+                                     U2H(stats[ST_I_PX_CONNECT].u.u64),
+                                     U2H(stats[ST_I_PX_REUSE].u.u64),
+                                     (stats[ST_I_PX_CONNECT].u.u64 + stats[ST_I_PX_REUSE].u.u64) ?
+                                     (int)(100 * stats[ST_I_PX_REUSE].u.u64 / (stats[ST_I_PX_CONNECT].u.u64 + stats[ST_I_PX_REUSE].u.u64)) : 0);
+               }
 
                chunk_appendf(out, "<tr><th colspan=3>Max / Avg over last 1024 success. conn.</th></tr>");
                chunk_appendf(out, "<tr><th>- Queue time:</th><td>%s / %s</td><td>ms</td></tr>",
@@ -1211,6 +1221,16 @@ int stats_dump_fields_html(struct buffer *out,
                                      U2H(stats[ST_I_PX_WREW].u.u64),
                                      U2H(stats[ST_I_PX_EINT].u.u64));
                }
+               else if (strcmp(field_str(stats, ST_I_PX_MODE), "spop") == 0) {
+                       chunk_appendf(out,
+                                     "<tr><th>New connections:</th><td>%s</td></tr>"
+                                     "<tr><th>Reused connections:</th><td>%s</td><td>(%d%%)</td></tr>"
+                                     "",
+                                     U2H(stats[ST_I_PX_CONNECT].u.u64),
+                                     U2H(stats[ST_I_PX_REUSE].u.u64),
+                                     (stats[ST_I_PX_CONNECT].u.u64 + stats[ST_I_PX_REUSE].u.u64) ?
+                                     (int)(100 * stats[ST_I_PX_REUSE].u.u64 / (stats[ST_I_PX_CONNECT].u.u64 + stats[ST_I_PX_REUSE].u.u64)) : 0);
+               }
 
                chunk_appendf(out, "<tr><th colspan=3>Max / Avg over last 1024 success. conn.</th></tr>");
                chunk_appendf(out, "<tr><th>- Queue time:</th><td>%s / %s</td><td>ms</td></tr>",
index a158d87cf24d8a92b6e2b298a4c2ba1b610f73e0..bfc07295366fd666eddfec2b06409af24959fae0 100644 (file)
@@ -118,7 +118,7 @@ const struct stat_col stat_cols_px[ST_I_PX_MAX] = {
        [ST_I_PX_AGENT_HEALTH]                  = { .name = "agent_health",                .desc = "Current server agent check level (0..fall-1=DOWN, fall..rise-1=UP)" },
        [ST_I_PX_ADDR]                          = { .name = "addr",                        .desc = "Server's address:port, shown only if show-legends is set, or at levels oper/admin for the CLI" },
        [ST_I_PX_COOKIE]                        = { .name = "cookie",                      .desc = "Backend's cookie name or Server's cookie value, shown only if show-legends is set, or at levels oper/admin for the CLI" },
-       [ST_I_PX_MODE]                          = { .name = "mode",                        .desc = "'mode' setting (tcp/http/health/cli)" },
+       [ST_I_PX_MODE]                          = { .name = "mode",                        .desc = "'mode' setting (tcp/http/health/cli/spop)" },
        [ST_I_PX_ALGO]                          = { .name = "algo",                        .desc = "Backend's load balancing algorithm, shown only if show-legends is set, or at levels oper/admin for the CLI" },
        [ST_I_PX_CONN_RATE]     = ME_NEW_FE("conn_rate",     FN_RATE,    FF_U32, conn_per_sec,           STATS_PX_CAP__F__, "Number of new connections accepted over the last second on the frontend for this worker process"),
        [ST_I_PX_CONN_RATE_MAX]                 = { .name = "conn_rate_max",               .desc = "Highest value of connections per second observed since the worker process started" },