]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: cli: add support for enabling/disabling health checks.
authorWilly Tarreau <w@1wt.eu>
Fri, 23 May 2014 09:53:10 +0000 (11:53 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 23 May 2014 13:42:49 +0000 (15:42 +0200)
"enable health" and "disable health" are introduced to manipulate the
health check subsystem.

doc/configuration.txt
src/dumpstats.c

index 2308c5cd3e35d47abf811f82efc7319c622f36e7..c565389a99ed3d787bf0b07e891f1dbd2e708b2e 100644 (file)
@@ -13154,6 +13154,15 @@ disable frontend <frontend>
   This command is restricted and can only be issued on sockets configured for
   level "admin".
 
+disable health <backend>/<server>
+  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 <backend>/<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 <frontend>
   This command is restricted and can only be issued on sockets configured for
   level "admin".
 
+enable health <backend>/<server>
+  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 <backend>/<server>
   If the server was previously marked as DOWN for maintenance, this marks the
   server UP and checks are re-enabled.
index 63a615a0c7cbf6b474da6283cca64aa8bc0652f3..7cfe2d07bade1034ce1dd380f507471d859acc4e 100644 (file)
@@ -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;
                }