MINOR: stats: report the load balancing algorithm in CSV output

It was already present in the HTML output, let's add it to CSV now,
but only when SHLGNDS is set.
This commit is contained in:
Willy Tarreau 2016-01-11 14:48:36 +01:00
parent f8211dff89
commit f1516d9840
2 changed files with 6 additions and 1 deletions

View File

@ -1025,6 +1025,7 @@ S (Servers).
73. addr [L..S]: address:port or "unix". IPv6 has brackets around the address. 73. addr [L..S]: address:port or "unix". IPv6 has brackets around the address.
74: cookie [..BS]: server's cookie value or backend's cookie name 74: cookie [..BS]: server's cookie value or backend's cookie name
75: mode [LFBS]: proxy mode (tcp, http, health, unknown) 75: mode [LFBS]: proxy mode (tcp, http, health, unknown)
76: algo [..B.]: load balancing algorithm
9.2. Unix Socket commands 9.2. Unix Socket commands

View File

@ -336,6 +336,7 @@ enum stat_field {
ST_F_ADDR, ST_F_ADDR,
ST_F_COOKIE, ST_F_COOKIE,
ST_F_MODE, ST_F_MODE,
ST_F_ALGO,
/* must always be the last one */ /* must always be the last one */
ST_F_TOTAL_FIELDS ST_F_TOTAL_FIELDS
@ -422,6 +423,7 @@ const char *stat_field_names[ST_F_TOTAL_FIELDS] = {
[ST_F_ADDR] = "addr", [ST_F_ADDR] = "addr",
[ST_F_COOKIE] = "cookie", [ST_F_COOKIE] = "cookie",
[ST_F_MODE] = "mode", [ST_F_MODE] = "mode",
[ST_F_ALGO] = "algo",
}; };
/* one line of stats */ /* one line of stats */
@ -3751,7 +3753,7 @@ static int stats_dump_fields_html(const struct field *stats, int admin, unsigned
if (flags & ST_SHLGNDS) { if (flags & ST_SHLGNDS) {
/* balancing */ /* balancing */
chunk_appendf(&trash, "<div class=tips>balancing: %s", chunk_appendf(&trash, "<div class=tips>balancing: %s",
backend_lb_algo_str(px->lbprm.algo & BE_LB_ALGO)); field_str(stats, ST_F_ALGO));
/* cookie */ /* cookie */
if (stats[ST_F_COOKIE].type) { if (stats[ST_F_COOKIE].type) {
@ -4346,9 +4348,11 @@ static int stats_dump_be_stats(struct stream_interface *si, struct proxy *px, in
stats[ST_F_TYPE] = mkf_u32(FO_CONFIG|FS_SERVICE, STATS_TYPE_BE); stats[ST_F_TYPE] = mkf_u32(FO_CONFIG|FS_SERVICE, STATS_TYPE_BE);
stats[ST_F_RATE] = mkf_u32(0, read_freq_ctr(&px->be_sess_per_sec)); stats[ST_F_RATE] = mkf_u32(0, read_freq_ctr(&px->be_sess_per_sec));
stats[ST_F_RATE_MAX] = mkf_u32(0, px->be_counters.sps_max); stats[ST_F_RATE_MAX] = mkf_u32(0, px->be_counters.sps_max);
if (flags & ST_SHLGNDS) { if (flags & ST_SHLGNDS) {
if (px->cookie_name) if (px->cookie_name)
stats[ST_F_COOKIE] = mkf_str(FO_CONFIG|FN_NAME|FS_SERVICE, px->cookie_name); stats[ST_F_COOKIE] = mkf_str(FO_CONFIG|FN_NAME|FS_SERVICE, px->cookie_name);
stats[ST_F_ALGO] = mkf_str(FO_CONFIG|FS_SERVICE, backend_lb_algo_str(px->lbprm.algo & BE_LB_ALGO));
} }
/* http response: 1xx, 2xx, 3xx, 4xx, 5xx, other */ /* http response: 1xx, 2xx, 3xx, 4xx, 5xx, other */