BUG/MINOR: promex: fix backend_agg_check_status

When a server is in maintenance, the check.status is no longer updated.
Therefore, we shouldn't consider check.status if the checks are not active. This
check was properly implemented in the haproxy_server_check_status metric, but
wasn't carried over to backend_agg_check_status, which introduced
inconsistencies between the two metrics.

[cf: This patch must be backported as far as 2.4]

(cherry picked from commit 3790eb4f855e8897277193e83e4a80ba3ee09b4d)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 0a2b4042590ab95185b14a312d72cfd71efafd85)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit d0ee5d296ada8debbba6e2c2c4d7b2a8b5364549)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit c3ea4ef07d1d2731c710c48e3e2aee12c8dabfb0)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
diff --git a/addons/promex/service-prometheus.c b/addons/promex/service-prometheus.c
index d31b666..fec61d1 100644
--- a/addons/promex/service-prometheus.c
+++ b/addons/promex/service-prometheus.c
@@ -844,8 +844,10 @@
 						goto next_px;
 					sv = px->srv;
 					while (sv) {
-						srv_check_status = sv->check.status;
-						srv_check_count[srv_check_status] += 1;
+						if ((sv->check.state & (CHK_ST_ENABLED|CHK_ST_PAUSED)) == CHK_ST_ENABLED) {
+							srv_check_status = sv->check.status;
+							srv_check_count[srv_check_status] += 1;
+						}
 						sv = sv->next;
 					}
 					for (; appctx->ctx.stats.st_code < HCHK_STATUS_SIZE; appctx->ctx.stats.st_code++) {