From: Aurelien DARRAGON Date: Wed, 7 Dec 2022 13:52:10 +0000 (+0100) Subject: MINOR: stats: properly handle ST_F_CHECK_DURATION metric X-Git-Tag: v2.8-dev1~166 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b118f2f407a824b44e787aae360fabd0172dbf0e;p=thirdparty%2Fhaproxy.git MINOR: stats: properly handle ST_F_CHECK_DURATION metric ST_F_CHECK_DURATION metric is typed as unsigned int variable, and it is derived from check->duration that is signed. While most of the time check->duration > 0, it is not always true: with HCHK_STATUS_HANA checks, check->duration is set to -1 to prevent server logs from including irrelevant duration info (HCHK_STATUS_HANA checks are not time related). Because of this, stats could report UINT64_MAX value for ST_F_CHECK_DURATION metric. This was quite confusing. To prevent this, we make sure not to assign negative value to ST_F_CHECK_DURATION. This is only a minor printing issue, not backport needed. --- diff --git a/src/stats.c b/src/stats.c index 5fd4d3f969..6ce41171a4 100644 --- a/src/stats.c +++ b/src/stats.c @@ -2330,7 +2330,7 @@ int stats_fill_sv_stats(struct proxy *px, struct server *sv, int flags, case ST_F_CHECK_DURATION: if ((sv->check.state & (CHK_ST_ENABLED|CHK_ST_PAUSED)) == CHK_ST_ENABLED && sv->check.status >= HCHK_STATUS_CHECKED) - metric = mkf_u64(FN_DURATION, sv->check.duration); + metric = mkf_u64(FN_DURATION, MAX(sv->check.duration, 0)); break; case ST_F_CHECK_DESC: if ((sv->check.state & (CHK_ST_ENABLED|CHK_ST_PAUSED)) == CHK_ST_ENABLED)