MINOR: check: add agent-send server parameter
Causes HAProxy to emit a static string to the agent on every check,
so that you can independently control multiple services running
behind a single agent port.
diff --git a/src/checks.c b/src/checks.c
index 997cf81..e77926a 100644
--- a/src/checks.c
+++ b/src/checks.c
@@ -1459,6 +1459,10 @@
}
}
+ if ((check->type & PR_O2_LB_AGENT_CHK) && check->send_string_len) {
+ bo_putblk(check->bo, check->send_string, check->send_string_len);
+ }
+
/* prepare a new connection */
conn_init(conn);
diff --git a/src/haproxy.c b/src/haproxy.c
index 93423a9..973af29 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -1412,6 +1412,7 @@
free(s->check.bo);
free(s->agent.bi);
free(s->agent.bo);
+ free(s->agent.send_string);
free((char*)s->conf.file);
#ifdef USE_OPENSSL
if (s->use_ssl || s->check.use_ssl)
diff --git a/src/server.c b/src/server.c
index c92623d..224d536 100644
--- a/src/server.c
+++ b/src/server.c
@@ -984,6 +984,9 @@
newsrv->check.downinter = curproxy->defsrv.check.downinter;
newsrv->agent.use_ssl = curproxy->defsrv.agent.use_ssl;
newsrv->agent.port = curproxy->defsrv.agent.port;
+ if (curproxy->defsrv.agent.send_string != NULL)
+ newsrv->agent.send_string = strdup(curproxy->defsrv.agent.send_string);
+ newsrv->agent.send_string_len = curproxy->defsrv.agent.send_string_len;
newsrv->agent.inter = curproxy->defsrv.agent.inter;
newsrv->agent.fastinter = curproxy->defsrv.agent.fastinter;
newsrv->agent.downinter = curproxy->defsrv.agent.downinter;
@@ -1052,6 +1055,14 @@
newsrv->agent.port = atol(args[cur_arg + 1]);
cur_arg += 2;
}
+ else if (!strcmp(args[cur_arg], "agent-send")) {
+ global.maxsock++;
+ free(newsrv->agent.send_string);
+ newsrv->agent.send_string_len = strlen(args[cur_arg + 1]);
+ newsrv->agent.send_string = calloc(1, newsrv->agent.send_string_len + 1);
+ memcpy(newsrv->agent.send_string, args[cur_arg + 1], newsrv->agent.send_string_len);
+ cur_arg += 2;
+ }
else if (!defsrv && !strcmp(args[cur_arg], "cookie")) {
newsrv->cookie = strdup(args[cur_arg + 1]);
newsrv->cklen = strlen(args[cur_arg + 1]);