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.
diff --git a/doc/configuration.txt b/doc/configuration.txt
index a4bc26e..b183b98 100644
--- a/doc/configuration.txt
+++ b/doc/configuration.txt
@@ -2763,7 +2763,9 @@
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 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-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
diff --git a/src/checks.c b/src/checks.c
index 5e66ec0..172cdd6 100644
--- a/src/checks.c
+++ b/src/checks.c
@@ -3895,7 +3895,15 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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);