mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-28 00:33:19 +00:00
MINOR: checks: Use dedicated actions to send log-format strings in send rules
Following actions have been added to send log-format strings from a tcp-check ruleset instead the log-format parameter: * tcp-check send-lf <fmt> * tcp-check send-binary-lf <fmt> It is easier for tools generating configurations. Each action may only be interpreted in one way.
This commit is contained in:
parent
67a234583e
commit
b50b3e6d0a
@ -2763,7 +2763,9 @@ tcp-check comment X - X X
|
||||
tcp-check connect X - X X
|
||||
tcp-check expect X - X X
|
||||
tcp-check send X - X X
|
||||
tcp-check send-lf X - X X
|
||||
tcp-check send-binary X - X X
|
||||
tcp-check send-binary-lf X - X X
|
||||
tcp-check set-var X - X X
|
||||
tcp-check unset-var X - X X
|
||||
tcp-request connection - X X -
|
||||
@ -10318,18 +10320,21 @@ tcp-check expect [min-recv <int>] [comment <msg>]
|
||||
"tcp-check send-binary", "http-check expect", tune.chksize
|
||||
|
||||
|
||||
tcp-check send <data> [comment <msg>] [log-format]
|
||||
Specify a string to be sent as a question during a generic health check
|
||||
tcp-check send <data> [comment <msg>]
|
||||
tcp-check send-lf <fmt> [comment <msg>]
|
||||
Specify a string or a log-format string to be sent as a question during a
|
||||
generic health check
|
||||
May be used in sections: defaults | frontend | listen | backend
|
||||
yes | no | yes | yes
|
||||
|
||||
Arguments :
|
||||
comment <msg> defines a message to report if the rule evaluation fails.
|
||||
|
||||
log-format specifies <data> must be evaluated a log-format string.
|
||||
<data> is the string that will be sent during a generic health
|
||||
check session.
|
||||
|
||||
<data> the data to be sent as a question during a generic health check
|
||||
session. For now, <data> must be a string.
|
||||
<fmt> is the log-format string that will be sent, once evaluated,
|
||||
during a generic health check session.
|
||||
|
||||
Examples :
|
||||
# look for the redis master server
|
||||
@ -10341,22 +10346,22 @@ tcp-check send <data> [comment <msg>] [log-format]
|
||||
"tcp-check send-binary", tune.chksize
|
||||
|
||||
|
||||
tcp-check send-binary <hexstring> [comment <msg>] [log-format]
|
||||
Specify a hex digits string to be sent as a binary question during a raw
|
||||
tcp health check
|
||||
tcp-check send-binary <hexstring> [comment <msg>]
|
||||
tcp-check send-binary-lf <hexfmt> [comment <msg>]
|
||||
Specify an hex digits string or an hex digits log-format string to be sent as
|
||||
a binary question during a raw tcp health check
|
||||
May be used in sections: defaults | frontend | listen | backend
|
||||
yes | no | yes | yes
|
||||
|
||||
Arguments :
|
||||
comment <msg> defines a message to report if the rule evaluation fails.
|
||||
|
||||
log-format specifies <hexstring> must be evaluated a log-format string.
|
||||
<hexstring> is the hexadecimal string that will be send, once converted
|
||||
to binary, during a generic health check session.
|
||||
|
||||
<hexstring> test the exact string in its hexadecimal form matches in the
|
||||
response buffer. A health check response will be considered
|
||||
valid if the response's buffer contains this exact hexadecimal
|
||||
string. Purpose is to send binary data to ask on binary
|
||||
protocols.
|
||||
<hexfmt> is the hexadecimal log-format string that will be send, once
|
||||
evaluated and converted to binary, during a generic health
|
||||
check session.
|
||||
|
||||
Examples :
|
||||
# redis check in binary
|
||||
|
31
src/checks.c
31
src/checks.c
@ -3895,7 +3895,15 @@ static struct tcpcheck_rule *parse_tcpcheck_send(char **args, int cur_arg, struc
|
||||
char *comment = NULL, *data = NULL;
|
||||
enum tcpcheck_send_type type = TCPCHK_SEND_UNDEF;
|
||||
|
||||
type = ((strcmp(args[cur_arg], "send-binary") == 0) ? TCPCHK_SEND_BINARY : TCPCHK_SEND_STRING);
|
||||
if (strcmp(args[cur_arg], "send-binary-lf") == 0)
|
||||
type = TCPCHK_SEND_BINARY_LF;
|
||||
else if (strcmp(args[cur_arg], "send-binary") == 0)
|
||||
type = TCPCHK_SEND_BINARY;
|
||||
else if (strcmp(args[cur_arg], "send-lf") == 0)
|
||||
type = TCPCHK_SEND_STRING_LF;
|
||||
else if (strcmp(args[cur_arg], "send") == 0)
|
||||
type = TCPCHK_SEND_STRING;
|
||||
|
||||
if (!*(args[cur_arg+1])) {
|
||||
memprintf(errmsg, "'%s' expects a %s as argument",
|
||||
(type == TCPCHK_SEND_BINARY ? "binary string": "string"), args[cur_arg]);
|
||||
@ -3919,14 +3927,8 @@ static struct tcpcheck_rule *parse_tcpcheck_send(char **args, int cur_arg, struc
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
else if (strcmp(args[cur_arg], "log-format") == 0) {
|
||||
if (type == TCPCHK_SEND_BINARY)
|
||||
type = TCPCHK_SEND_BINARY_LF;
|
||||
else if (type == TCPCHK_SEND_STRING)
|
||||
type = TCPCHK_SEND_STRING_LF;
|
||||
}
|
||||
else {
|
||||
memprintf(errmsg, "expects 'comment', 'log-format' but got '%s' as argument.",
|
||||
memprintf(errmsg, "expects 'comment' but got '%s' as argument.",
|
||||
args[cur_arg]);
|
||||
goto error;
|
||||
}
|
||||
@ -5960,7 +5962,8 @@ static int proxy_parse_tcpcheck(char **args, int section, struct proxy *curpx,
|
||||
cur_arg = 1;
|
||||
if (strcmp(args[cur_arg], "connect") == 0)
|
||||
chk = parse_tcpcheck_connect(args, cur_arg, curpx, &rs->rules, file, line, errmsg);
|
||||
else if (strcmp(args[cur_arg], "send") == 0 || strcmp(args[cur_arg], "send-binary") == 0)
|
||||
else if (strcmp(args[cur_arg], "send") == 0 || strcmp(args[cur_arg], "send-binary") == 0 ||
|
||||
strcmp(args[cur_arg], "send-lf") == 0 || strcmp(args[cur_arg], "send-binary-lf") == 0)
|
||||
chk = parse_tcpcheck_send(args, cur_arg, curpx, &rs->rules, file, line, errmsg);
|
||||
else if (strcmp(args[cur_arg], "expect") == 0)
|
||||
chk = parse_tcpcheck_expect(args, cur_arg, curpx, &rs->rules, 0, file, line, errmsg);
|
||||
@ -6359,7 +6362,7 @@ int proxy_parse_ssl_hello_chk_opt(char **args, int cur_arg, struct proxy *curpx,
|
||||
goto error;
|
||||
}
|
||||
|
||||
chk = parse_tcpcheck_send((char *[]){"tcp-check", "send-binary", sslv3_client_hello, "log-format", ""},
|
||||
chk = parse_tcpcheck_send((char *[]){"tcp-check", "send-binary-lf", sslv3_client_hello, ""},
|
||||
1, curpx, &rs->rules, file, line, &errmsg);
|
||||
if (!chk) {
|
||||
ha_alert("parsing [%s:%d] : %s\n", file, line, errmsg);
|
||||
@ -6494,7 +6497,7 @@ int proxy_parse_smtpchk_opt(char **args, int cur_arg, struct proxy *curpx, struc
|
||||
chk->index = 2;
|
||||
LIST_ADDQ(&rs->rules, &chk->list);
|
||||
|
||||
chk = parse_tcpcheck_send((char *[]){"tcp-check", "send", smtp_req, "log-format", ""},
|
||||
chk = parse_tcpcheck_send((char *[]){"tcp-check", "send-lf", smtp_req, ""},
|
||||
1, curpx, &rs->rules, file, line, &errmsg);
|
||||
if (!chk) {
|
||||
ha_alert("parsing [%s:%d] : %s\n", file, line, errmsg);
|
||||
@ -6629,7 +6632,7 @@ int proxy_parse_pgsql_check_opt(char **args, int cur_arg, struct proxy *curpx, s
|
||||
chk->index = 0;
|
||||
LIST_ADDQ(&rs->rules, &chk->list);
|
||||
|
||||
chk = parse_tcpcheck_send((char *[]){"tcp-check", "send-binary", pgsql_req, "log-format", ""},
|
||||
chk = parse_tcpcheck_send((char *[]){"tcp-check", "send-binary-lf", pgsql_req, ""},
|
||||
1, curpx, &rs->rules, file, line, &errmsg);
|
||||
if (!chk) {
|
||||
ha_alert("parsing [%s:%d] : %s\n", file, line, errmsg);
|
||||
@ -6858,7 +6861,7 @@ int proxy_parse_mysql_check_opt(char **args, int cur_arg, struct proxy *curpx, s
|
||||
LIST_ADDQ(&rs->rules, &chk->list);
|
||||
|
||||
if (mysql_req) {
|
||||
chk = parse_tcpcheck_send((char *[]){"tcp-check", "send-binary", mysql_req, "log-format", ""},
|
||||
chk = parse_tcpcheck_send((char *[]){"tcp-check", "send-binary-lf", mysql_req, ""},
|
||||
1, curpx, &rs->rules, file, line, &errmsg);
|
||||
if (!chk) {
|
||||
ha_alert("parsing [%s:%d] : %s\n", file, line, errmsg);
|
||||
@ -7381,7 +7384,7 @@ static int srv_parse_agent_check(char **args, int *cur_arg, struct proxy *curpx,
|
||||
goto error;
|
||||
}
|
||||
|
||||
chk = parse_tcpcheck_send((char *[]){"tcp-check", "send", "%[var(check.agent_string)]", "log-format", ""},
|
||||
chk = parse_tcpcheck_send((char *[]){"tcp-check", "send-lf", "%[var(check.agent_string)]", ""},
|
||||
1, curpx, &rs->rules, srv->conf.file, srv->conf.line, errmsg);
|
||||
if (!chk) {
|
||||
memprintf(errmsg, "'%s': %s", args[*cur_arg], *errmsg);
|
||||
|
Loading…
Reference in New Issue
Block a user