[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 <value>" to do that.
This commit is contained in:
Willy Tarreau 2010-01-26 10:59:06 +01:00
parent 2eba6aaa1b
commit 7aabd11cec
2 changed files with 34 additions and 1 deletions

View File

@ -7553,6 +7553,11 @@ get weight <backend>/<server>
may be specified either by their name or by their numeric ID, prefixed with a
dash ('#').
set timeout cli <delay>
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 <backend>/<server> <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

View File

@ -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;
}
}