MINOR: stats-html: Display reuse ratio for spop connections

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.
This commit is contained in:
Christopher Faulet 2024-07-09 07:49:49 +02:00
parent e68274c90a
commit 6b9daec93d
2 changed files with 21 additions and 1 deletions

View 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>",

View 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" },