diff --git a/doc/management.txt b/doc/management.txt index f559ffc86..d4670d58a 100644 --- a/doc/management.txt +++ b/doc/management.txt @@ -1595,6 +1595,9 @@ set server / health [ up | stopping | down ] switch a server's state regardless of some slow health checks for example. Note that the change is propagated to tracking servers if any. +set server / check-port + Change the port used for health checking to + set server / state [ ready | drain | maint ] Force a server's administrative state to a new state. This can be useful to disable load balancing and/or any traffic to a server. Setting the state to diff --git a/src/dumpstats.c b/src/dumpstats.c index b42c07aa9..fa646c091 100644 --- a/src/dumpstats.c +++ b/src/dumpstats.c @@ -1779,6 +1779,26 @@ static int stats_sock_parse_request(struct stream_interface *si, char *line) appctx->st0 = STAT_CLI_PRINT; } } + else if (strcmp(args[3], "check-port") == 0) { + int i = 0; + if (strl2irc(args[4], strlen(args[4]), &i) != 0) { + appctx->ctx.cli.msg = "'set server check-port' expects an integer as argument.\n"; + appctx->st0 = STAT_CLI_PRINT; + } + if ((i < 0) || (i > 65535)) { + appctx->ctx.cli.msg = "provided port is not valid.\n"; + appctx->st0 = STAT_CLI_PRINT; + } + /* prevent the update of port to 0 if MAPPORTS are in use */ + if ((sv->flags & SRV_F_MAPPORTS) && (i == 0)) { + appctx->ctx.cli.msg = "can't unset 'port' since MAPPORTS is in use.\n"; + appctx->st0 = STAT_CLI_PRINT; + return 1; + } + sv->check.port = i; + appctx->ctx.cli.msg = "health check port updated.\n"; + appctx->st0 = STAT_CLI_PRINT; + } else if (strcmp(args[3], "addr") == 0) { warning = server_parse_addr_change_request(sv, args[4], "stats command"); if (warning) { @@ -1787,7 +1807,7 @@ static int stats_sock_parse_request(struct stream_interface *si, char *line) } } else { - appctx->ctx.cli.msg = "'set server ' only supports 'agent', 'health', 'state', 'weight' and 'addr'.\n"; + appctx->ctx.cli.msg = "'set server ' only supports 'agent', 'health', 'state', 'weight', 'addr' and 'check-port'.\n"; appctx->st0 = STAT_CLI_PRINT; } return 1;