diff --git a/doc/management.txt b/doc/management.txt index 63ba742c1..c5e5579d3 100644 --- a/doc/management.txt +++ b/doc/management.txt @@ -3997,6 +3997,15 @@ update ssl ocsp-response local tree, its contents will be displayed on the standard output. The format is the same as the one described in "show ssl ocsp-response". +wait + This simply waits for the requested delay before continuing. This can be used + to collect metrics around a specific interval. The default unit for the delay + is milliseconds, though other units are accepted if suffixed with the usual + timer units (s, m, h, d). When used with the 'socat' utility, do not forget + to extend socat's close timeout to cover the wait time. + Example: + $ socat -t20 /path/to/socket <<< "show activity; wait 10s; show activity" + 9.4. Master CLI --------------- diff --git a/include/haproxy/cli-t.h b/include/haproxy/cli-t.h index c155df338..9334fcd9f 100644 --- a/include/haproxy/cli-t.h +++ b/include/haproxy/cli-t.h @@ -81,6 +81,27 @@ struct cli_print_ctx { int severity; /* severity of the message to be returned according to (syslog) rfc5424 */ }; +/* context for the "wait" command that's used to wait for some time on a + * condition. We store the start date and the expiration date. The error + * value is set by the I/O handler to be printed by the release handler at + * the end. + */ +enum cli_wait_err { + CLI_WAIT_ERR_DONE, // condition satisfied + CLI_WAIT_ERR_INTR, // interrupted + CLI_WAIT_ERR_EXP, // finished on wait expiration +}; + +enum cli_wait_cond { + CLI_WAIT_COND_NONE, // no condition to wait on +}; + +struct cli_wait_ctx { + uint start, deadline; // both are in ticks. + enum cli_wait_cond cond; // CLI_WAIT_COND_* + enum cli_wait_err error; // CLI_WAIT_ERR_* +}; + struct cli_kw { const char *str_kw[CLI_PREFIX_KW_NB]; /* keywords ended by NULL, limited to CLI_PREFIX_KW_NB separated keywords combination */ diff --git a/src/cli.c b/src/cli.c index 1546c0d7c..acd5b8729 100644 --- a/src/cli.c +++ b/src/cli.c @@ -2010,6 +2010,105 @@ static int cli_parse_set_ratelimit(char **args, char *payload, struct appctx *ap return 1; } +/* Parse a "wait