From: Willy Tarreau Date: Fri, 23 May 2014 09:53:10 +0000 (+0200) Subject: MEDIUM: cli: add support for enabling/disabling health checks. X-Git-Tag: v1.5-dev26~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9b5aecd5be0cfc039bca68465a3649d6346c089f;p=thirdparty%2Fhaproxy.git MEDIUM: cli: add support for enabling/disabling health checks. "enable health" and "disable health" are introduced to manipulate the health check subsystem. --- diff --git a/doc/configuration.txt b/doc/configuration.txt index 2308c5cd3e..c565389a99 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -13154,6 +13154,15 @@ disable frontend This command is restricted and can only be issued on sockets configured for level "admin". +disable health / + Mark the primary health check as temporarily stopped. This will disable + sending of health checks, and the last health check result will be ignored. + The server will be in unchecked state and considered UP unless an auxiliary + agent check forces it down. + + This command is restricted and can only be issued on sockets configured for + level "admin". + disable server / Mark the server DOWN for maintenance. In this mode, no more checks will be performed on the server until it leaves maintenance. @@ -13191,6 +13200,13 @@ enable frontend This command is restricted and can only be issued on sockets configured for level "admin". +enable health / + Resume a primary health check that was temporarily stopped. This will enable + sending of health checks again. Please see "disable health" for details. + + This command is restricted and can only be issued on sockets configured for + level "admin". + enable server / If the server was previously marked as DOWN for maintenance, this marks the server UP and checks are re-enabled. diff --git a/src/dumpstats.c b/src/dumpstats.c index 63a615a0c7..7cfe2d07ba 100644 --- a/src/dumpstats.c +++ b/src/dumpstats.c @@ -1791,7 +1791,23 @@ static int stats_sock_parse_request(struct stream_interface *si, char *line) sv->agent.state |= CHK_ST_ENABLED; return 1; } - if (strcmp(args[1], "server") == 0) { + else if (strcmp(args[1], "health") == 0) { + struct server *sv; + + sv = expect_server_admin(s, si, args[2]); + if (!sv) + return 1; + + if (!(sv->check.state & CHK_ST_CONFIGURED)) { + appctx->ctx.cli.msg = "Health checks are not configured on this server, cannot enable.\n"; + appctx->st0 = STAT_CLI_PRINT; + return 1; + } + + sv->check.state |= CHK_ST_ENABLED; + return 1; + } + else if (strcmp(args[1], "server") == 0) { struct server *sv; sv = expect_server_admin(s, si, args[2]); @@ -1828,7 +1844,7 @@ static int stats_sock_parse_request(struct stream_interface *si, char *line) return 1; } else { /* unknown "enable" parameter */ - appctx->ctx.cli.msg = "'enable' only supports 'agent', 'frontend' and 'server'.\n"; + appctx->ctx.cli.msg = "'enable' only supports 'agent', 'frontend', 'health', and 'server'.\n"; appctx->st0 = STAT_CLI_PRINT; return 1; } @@ -1844,6 +1860,16 @@ static int stats_sock_parse_request(struct stream_interface *si, char *line) sv->agent.state &= ~CHK_ST_ENABLED; return 1; } + else if (strcmp(args[1], "health") == 0) { + struct server *sv; + + sv = expect_server_admin(s, si, args[2]); + if (!sv) + return 1; + + sv->check.state &= ~CHK_ST_ENABLED; + return 1; + } else if (strcmp(args[1], "server") == 0) { struct server *sv; @@ -1881,7 +1907,7 @@ static int stats_sock_parse_request(struct stream_interface *si, char *line) return 1; } else { /* unknown "disable" parameter */ - appctx->ctx.cli.msg = "'disable' only supports 'agent', 'frontend' and 'server'.\n"; + appctx->ctx.cli.msg = "'disable' only supports 'agent', 'frontend', 'health', and 'server'.\n"; appctx->st0 = STAT_CLI_PRINT; return 1; }