From: Willy Tarreau Date: Tue, 26 Jan 2010 09:59:06 +0000 (+0100) Subject: [STATS] make it possible to change a CLI connection timeout X-Git-Tag: v1.4-rc1~45 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7aabd11cecea3f0ed0fcb1c69a85f9a54dd171ec;p=thirdparty%2Fhaproxy.git [STATS] make it possible to change a CLI connection timeout Sometimes it helps to be able to change an interactive CLI connection timeout. Now we just have to enter "set timeout cli " to do that. --- diff --git a/doc/configuration.txt b/doc/configuration.txt index a1383ad77d..b10714d5b2 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -7553,6 +7553,11 @@ get weight / may be specified either by their name or by their numeric ID, prefixed with a dash ('#'). +set timeout cli + Change the CLI interface timeout for current connection. This can be useful + during long debugging sessions where the user needs to constantly inspect + some indicators without being disconnected. The delay is passed in seconds. + set weight / [%] Change a server's weight to the value passed in argument. If the value ends with the '%' sign, then the new weight will be relative to the initially diff --git a/src/dumpstats.c b/src/dumpstats.c index 495e28007d..24b0706e2f 100644 --- a/src/dumpstats.c +++ b/src/dumpstats.c @@ -64,6 +64,7 @@ const char stats_sock_usage_msg[] = " show sess : report the list of current sessions\n" " get weight : report a server's current weight\n" " set weight : change a server's weight\n" + " set timeout : change a timeout setting\n" ""; const char stats_permission_denied_msg[] = @@ -497,7 +498,34 @@ int stats_sock_parse_request(struct stream_interface *si, char *line) return 1; } - else { /* not "set weight" */ + else if (strcmp(args[1], "timeout") == 0) { + if (strcmp(args[2], "cli") == 0) { + unsigned timeout; + const char *res; + + if (!*args[3]) { + s->data_ctx.cli.msg = "Expects an integer value.\n"; + si->st0 = STAT_CLI_PRINT; + return 1; + } + + res = parse_time_err(args[3], &timeout, TIME_UNIT_S); + if (res || timeout < 1) { + s->data_ctx.cli.msg = "Invalid timeout value.\n"; + si->st0 = STAT_CLI_PRINT; + return 1; + } + + s->req->rto = s->rep->wto = 1 + MS_TO_TICKS(timeout*1000); + return 1; + } + else { + s->data_ctx.cli.msg = "'set timeout' only supports 'cli'.\n"; + si->st0 = STAT_CLI_PRINT; + return 1; + } + } + else { /* unknown "set" parameter */ return 0; } }