Hello, I am trying to set up a health check service similar to the inetd solutions suggested in the documentation. Unfortunately, my backends run on different ports because they are being created dynamically and as far as I can tell I cannot include the server port in my healthcheck either as part of the server declaration, a header, or as part of the healthcheck uri itself.
I have been trying to come up with potential solutions that are not overly invasive, and I think that the simplest solution is to include the server host and port in the existing send-state header. I have included a patch that I believe does this at the end of this email. Before I go off maintaining a local fork, I wanted to ask if the haproxy devs would be sympathetic to me trying to upstream this patch? As for prior art, I found a few posts on this mailing list about the ability to add headers to http checks. I believe that something like http://marc.info/?l=haproxy&m=139181606417120&w=2 would be more then what we need to solve this problem, but that thread seems to have died. I do believe that a general ability to add headers to healthchecks would be superior to my patch, but the general solution is significantly harder to pull off. If you guys agree that this patch is ok, please let me know what I need to do next. I don't see any tests for the send-state option but I presume that I would need to update the documentation. Thank you, Joseph Lynch === Patch === diff --git a/src/checks.c b/src/checks.c index 15a3c40..d620b5b 100644 --- a/src/checks.c +++ b/src/checks.c @@ -477,6 +477,8 @@ static int httpchk_build_status_header(struct server *s, char *buffer, int size) int sv_state; int ratio; int hlen = 0; + char host[46]; + char port[6]; const char *srv_hlt_st[7] = { "DOWN", "DOWN %d/%d", "UP %d/%d", "UP", "NOLB %d/%d", "NOLB", @@ -507,8 +509,11 @@ static int httpchk_build_status_header(struct server *s, char *buffer, int size) (s->state != SRV_ST_STOPPED) ? (s->check.health - s->check.rise + 1) : (s->check.health), (s->state != SRV_ST_STOPPED) ? (s->check.fall) : (s->check.rise)); - hlen += snprintf(buffer + hlen, size - hlen, "; name=%s/%s; node=%s; weight=%d/%d; scur=%d/%d; qcur=%d", - s->proxy->id, s->id, + addr_to_str(&s->addr, host, sizeof(host)); + port_to_str(&s->addr, port, sizeof(port)); + + hlen += snprintf(buffer + hlen, size - hlen, "; host=%s; port=%s; name=%s/%s; node=%s; weight=%d/%d; scur=%d/%d; qcur=%d", + host, port, s->proxy->id, s->id, global.node, (s->eweight * s->proxy->lbprm.wmult + s->proxy->lbprm.wdiv - 1) / s->proxy->lbprm.wdiv, (s->proxy->lbprm.tot_weight * s->proxy->lbprm.wmult + s->proxy->lbprm.wdiv - 1) / s->proxy->lbprm.wdiv,

