From 09f72be1c1442627e1a37412858612d812147088 Mon Sep 17 00:00:00 2001
From: Misiek <creating.www@gmail.com>
Date: Mon, 9 Jan 2017 09:40:42 +0100
Subject: [PATCH 2/4] [PATCH] MINOR: cli: Add possiblity to change agent config
 via CLI/socket

This change adds possibility to change agent-addr and agent-send directives
by CLI/socket. Now you can replace server's and their configuration without
reloading/restarting whole haproxy, so it's a step in no-reload/no-restart
direction.

Depends on #e9602af - agent-addr is implemented there.

Can be backported to 1.7.
---
 src/server.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/src/server.c b/src/server.c
index 9741917..259c3de 100644
--- a/src/server.c
+++ b/src/server.c
@@ -3467,6 +3467,33 @@ static int cli_parse_set_server(char **args, struct appctx *appctx, void *privat
 			appctx->st0 = CLI_ST_PRINT;
 		}
 	}
+	else if (strcmp(args[3], "agent-addr") == 0) {
+		if(!(sv->agent.state & CHK_ST_ENABLED)) {
+			appctx->ctx.cli.msg = "agent checks are not enabled on this server.\n";
+			appctx->st0 = CLI_ST_PRINT;
+		} else {
+			if(str2ip(args[4], &sv->agent.addr) == NULL) {
+				appctx->ctx.cli.msg = "incorrect addr address given for agent.\n";
+				appctx->st0 = CLI_ST_PRINT;
+			}
+		}
+	}
+	else if(strcmp(args[3], "agent-send") == 0) {
+		if(!(sv->agent.state & CHK_ST_ENABLED)) {
+			appctx->ctx.cli.msg = "agent checks are not enabled on this server.\n";
+			appctx->st0 = CLI_ST_PRINT;
+		} else {
+			char *nss = strdup(args[4]);
+			if(!nss) {
+				appctx->ctx.cli.msg = "cannot allocate memory for new string.\n";
+				appctx->st0 = CLI_ST_PRINT;
+			} else {
+				free(sv->agent.send_string);
+				sv->agent.send_string = nss;
+				sv->agent.send_string_len = strlen(args[4]);
+			}
+		}
+	}
 	else if (strcmp(args[3], "check-port") == 0) {
 		int i = 0;
 		if (strl2irc(args[4], strlen(args[4]), &i) != 0) {
-- 
2.10.1 (Apple Git-78)

