From: Aurelien DARRAGON Date: Thu, 17 Nov 2022 15:34:07 +0000 (+0100) Subject: MINOR: stats: add server revision id support X-Git-Tag: v2.8-dev1~177 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=745ce8e8ad8150569f368ab4663adda77a43c857;p=thirdparty%2Fhaproxy.git MINOR: stats: add server revision id support Make use of the new srv->rid value in stats. Stat is referred as ST_F_SRID, it is now used in stats_fill_sv_stats function in order to be included in csv and json stats dumps. Moreover, "rid: $value" will be displayed next to server puid in html stats page if "stats show-legend" is specified in the stats frontend. (mouse hovering tooltip) Depends on the following commit: "MINOR: server: add srv->rid (revision id) value" --- diff --git a/include/haproxy/stats-t.h b/include/haproxy/stats-t.h index efa0ac3839..1a7d3d157d 100644 --- a/include/haproxy/stats-t.h +++ b/include/haproxy/stats-t.h @@ -456,6 +456,7 @@ enum stat_field { ST_F_NEED_CONN_EST, ST_F_UWEIGHT, ST_F_AGG_SRV_CHECK_STATUS, + ST_F_SRID, /* must always be the last one */ ST_F_TOTAL_FIELDS diff --git a/src/stats.c b/src/stats.c index 8ed5a71338..5fd4d3f969 100644 --- a/src/stats.c +++ b/src/stats.c @@ -260,6 +260,7 @@ const struct name_desc stat_fields[ST_F_TOTAL_FIELDS] = { [ST_F_NEED_CONN_EST] = { .name = "need_conn_est", .desc = "Estimated needed number of connections"}, [ST_F_UWEIGHT] = { .name = "uweight", .desc = "Server's user weight, or sum of active servers' user weights for a backend" }, [ST_F_AGG_SRV_CHECK_STATUS] = { .name = "agg_server_check_status", .desc = "Backend's aggregated gauge of servers' state check status" }, + [ST_F_SRID] = { .name = "srid", .desc = "Server id revision, to prevent server id reuse mixups" }, }; /* one line of info */ @@ -1153,7 +1154,7 @@ static int stats_dump_fields_html(struct buffer *out, chunk_appendf(out, "%s, ", field_str(stats, ST_F_ADDR)); /* id */ - chunk_appendf(out, "id: %d", stats[ST_F_SID].u.u32); + chunk_appendf(out, "id: %d, rid: %d", stats[ST_F_SID].u.u32, stats[ST_F_SRID].u.u32); /* cookie */ if (stats[ST_F_COOKIE].type) { @@ -2283,6 +2284,9 @@ int stats_fill_sv_stats(struct proxy *px, struct server *sv, int flags, case ST_F_SID: metric = mkf_u32(FO_KEY|FS_SERVICE, sv->puid); break; + case ST_F_SRID: + metric = mkf_u32(FN_COUNTER, sv->rid); + break; case ST_F_THROTTLE: if (sv->cur_state == SRV_ST_STARTING && !server_is_draining(sv)) metric = mkf_u32(FN_AVG, server_throttle_rate(sv));