mirror of
https://github.com/haproxy/haproxy.git
synced 2026-02-20 00:10:41 -05:00
BUG/MINOR: stats: Add missing agent stats on servers
Agent stats were lost during the stats refactoring performed in the 2.4 to simplify the Prometheus exporter. stats_fill_sv_stats() function must fill ST_F_AGENT_* and ST_F_LAST_AGT stats. This patch should fix the issue #1331. It must be backported to 2.4.
This commit is contained in:
parent
5fcd428c35
commit
59bab61649
1 changed files with 41 additions and 0 deletions
41
src/stats.c
41
src/stats.c
|
|
@ -2332,6 +2332,47 @@ int stats_fill_sv_stats(struct proxy *px, struct server *sv, int flags,
|
|||
if ((sv->check.state & (CHK_ST_ENABLED|CHK_ST_PAUSED)) == CHK_ST_ENABLED)
|
||||
metric = mkf_u32(FO_CONFIG|FS_SERVICE, ref->check.health);
|
||||
break;
|
||||
case ST_F_AGENT_STATUS:
|
||||
if ((sv->agent.state & (CHK_ST_ENABLED|CHK_ST_PAUSED)) == CHK_ST_ENABLED) {
|
||||
const char *fld_chksts;
|
||||
|
||||
fld_chksts = chunk_newstr(out);
|
||||
chunk_strcat(out, "* "); // for check in progress
|
||||
chunk_strcat(out, get_check_status_info(sv->agent.status));
|
||||
if (!(sv->agent.state & CHK_ST_INPROGRESS))
|
||||
fld_chksts += 2; // skip "* "
|
||||
metric = mkf_str(FN_OUTPUT, fld_chksts);
|
||||
}
|
||||
break;
|
||||
case ST_F_AGENT_CODE:
|
||||
if ((sv->agent.state & (CHK_ST_ENABLED|CHK_ST_PAUSED)) == CHK_ST_ENABLED &&
|
||||
(sv->agent.status >= HCHK_STATUS_L57DATA))
|
||||
metric = mkf_u32(FN_OUTPUT, sv->agent.code);
|
||||
break;
|
||||
case ST_F_AGENT_DURATION:
|
||||
if ((sv->agent.state & (CHK_ST_ENABLED|CHK_ST_PAUSED)) == CHK_ST_ENABLED)
|
||||
metric = mkf_u64(FN_DURATION, sv->agent.duration);
|
||||
break;
|
||||
case ST_F_AGENT_DESC:
|
||||
if ((sv->agent.state & (CHK_ST_ENABLED|CHK_ST_PAUSED)) == CHK_ST_ENABLED)
|
||||
metric = mkf_str(FN_OUTPUT, get_check_status_description(sv->agent.status));
|
||||
break;
|
||||
case ST_F_LAST_AGT:
|
||||
if ((sv->agent.state & (CHK_ST_ENABLED|CHK_ST_PAUSED)) == CHK_ST_ENABLED)
|
||||
metric = mkf_str(FN_OUTPUT, sv->agent.desc);
|
||||
break;
|
||||
case ST_F_AGENT_RISE:
|
||||
if ((sv->agent.state & (CHK_ST_ENABLED|CHK_ST_PAUSED)) == CHK_ST_ENABLED)
|
||||
metric = mkf_u32(FO_CONFIG|FS_SERVICE, sv->agent.rise);
|
||||
break;
|
||||
case ST_F_AGENT_FALL:
|
||||
if ((sv->agent.state & (CHK_ST_ENABLED|CHK_ST_PAUSED)) == CHK_ST_ENABLED)
|
||||
metric = mkf_u32(FO_CONFIG|FS_SERVICE, sv->agent.fall);
|
||||
break;
|
||||
case ST_F_AGENT_HEALTH:
|
||||
if ((sv->agent.state & (CHK_ST_ENABLED|CHK_ST_PAUSED)) == CHK_ST_ENABLED)
|
||||
metric = mkf_u32(FO_CONFIG|FS_SERVICE, sv->agent.health);
|
||||
break;
|
||||
case ST_F_REQ_TOT:
|
||||
if (px->mode == PR_MODE_HTTP)
|
||||
metric = mkf_u64(FN_COUNTER, sv->counters.p.http.cum_req);
|
||||
|
|
|
|||
Loading…
Reference in a new issue