MINOR: checks: Add function to get the result code corresponding to a status

The function get_check_status_result() can now be used to get the result
code (CHK_RES_*) corresponding to a check status (HCHK_STATUS_*). It will be
used by the Prometheus exporter when reporting the check status of a server.
This commit is contained in:
Christopher Faulet 2021-02-01 13:11:50 +01:00
parent ff97edac3e
commit 7aa3271439
2 changed files with 10 additions and 0 deletions

View File

@ -29,6 +29,7 @@
extern struct data_cb check_conn_cb;
extern struct proxy checks_fe;
short get_check_status_result(short check_status);
const char *get_check_status_description(short check_status);
const char *get_check_status_info(short check_status);
int httpchk_build_status_header(struct server *s, struct buffer *buf);

View File

@ -152,6 +152,15 @@ static inline int unclean_errno(int err)
return err;
}
/* Converts check_status code to result code */
short get_check_status_result(short check_status)
{
if (check_status < HCHK_STATUS_SIZE)
return check_statuses[check_status].result;
else
return check_statuses[HCHK_STATUS_UNKNOWN].result;
}
/* Converts check_status code to description */
const char *get_check_status_description(short check_status) {