/* flags used by check->state */
#define CHK_ST_INPROGRESS 0x0001 /* a check is currently running */
-#define CHK_ST_DISABLED 0x0002 /* this check is currently administratively disabled */
+#define CHK_ST_CONFIGURED 0x0002 /* this check is configured and may be enabled */
+#define CHK_ST_ENABLED 0x0004 /* this check is currently administratively enabled */
/* check status */
enum {
goto out;
}
+ newsrv->check.state |= CHK_ST_CONFIGURED | CHK_ST_ENABLED;
newsrv->state |= SRV_CHECKED;
}
goto out;
}
+ newsrv->agent.state |= CHK_ST_CONFIGURED | CHK_ST_ENABLED;
newsrv->state |= SRV_AGENT_CHECKED;
}
* parameter of this function is the agent or check field
* of the server.
*/
- disabled = check->server->agent.state & CHK_ST_DISABLED;
+ disabled = !(check->server->agent.state & CHK_ST_ENABLED);
if (strchr(check->bi->data, '%')) {
if (disabled)
if (!(s->state & SRV_CHECKED) ||
s->proxy->state == PR_STSTOPPED ||
(s->state & SRV_MAINTAIN) ||
- (check->state & CHK_ST_DISABLED))
+ !(check->state & CHK_ST_ENABLED))
goto reschedule;
/* we'll initiate a new check */
if (!sv)
return 1;
- sv->agent.state &= ~CHK_ST_DISABLED;
+ if (!(sv->agent.state & CHK_ST_CONFIGURED)) {
+ appctx->ctx.cli.msg = "Agent was not configured on this server, cannot enable.\n";
+ appctx->st0 = STAT_CLI_PRINT;
+ return 1;
+ }
+
+ sv->agent.state |= CHK_ST_ENABLED;
return 1;
}
if (strcmp(args[1], "server") == 0) {
if (!sv)
return 1;
- sv->agent.state |= CHK_ST_DISABLED;
+ sv->agent.state &= ~CHK_ST_ENABLED;
return 1;
}
else if (strcmp(args[1], "server") == 0) {