Skip to content

Commit 5288d0f

Browse files
Olivier Houchardwtarreau
authored andcommitted
MINOR: cli: Add a "help" keyword to show sess
Add a help keyword to show sess, that will provide a longer explanation of all the available options than what is provided by the command "help".
1 parent 2fffd85 commit 5288d0f

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/stream.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3722,6 +3722,19 @@ static int cli_parse_show_sess(char **args, char *payload, struct appctx *appctx
37223722
ctx->target = (void *)-1;
37233723
cur_arg++;
37243724
}
3725+
else if (*args[cur_arg] && strcmp(args[cur_arg], "help") == 0) {
3726+
chunk_printf(&trash,
3727+
"Usage: show sess [<id> | older <age> | susp | all] [<options>*]\n"
3728+
"Dumps active streams (formerly called 'sessions'). Available selectors:\n"
3729+
" <id> dump only this stream identifier (0x...)\n"
3730+
" all dump all stream in large format\n"
3731+
" older <age> only display stream older than <age>\n"
3732+
" susp report streams considered suspicious\n"
3733+
"Available options: \n"
3734+
" show-uri also display the transaction URI, if available\n"
3735+
"Without any argument, all streams are dumped in a shorter format.");
3736+
return cli_err(appctx, trash.area);
3737+
}
37253738
else if (*args[cur_arg]) {
37263739
ctx->target = (void *)strtoul(args[cur_arg], NULL, 0);
37273740
if (ctx->target)
@@ -3734,7 +3747,7 @@ static int cli_parse_show_sess(char **args, char *payload, struct appctx *appctx
37343747
ctx->flags |= CLI_SHOWSESS_F_DUMP_URI;
37353748
}
37363749
else {
3737-
chunk_printf(&trash, "Unsupported option '%s'.\n", args[cur_arg]);
3750+
chunk_printf(&trash, "Unsupported option '%s', try 'help' for more info.\n", args[cur_arg]);
37383751
return cli_err(appctx, trash.area);
37393752
}
37403753
cur_arg++;
@@ -4050,7 +4063,7 @@ static int cli_parse_shutdown_sessions_server(char **args, char *payload, struct
40504063

40514064
/* register cli keywords */
40524065
static struct cli_kw_list cli_kws = {{ },{
4053-
{ { "show", "sess", NULL }, "show sess [<id>|all|susp|older <age>] : report the list of current sessions or dump this exact session", cli_parse_show_sess, cli_io_handler_dump_sess, cli_release_show_sess },
4066+
{ { "show", "sess", NULL }, "show sess [help|<id>|all|susp|older...] : report the list of current streams or dump this exact stream", cli_parse_show_sess, cli_io_handler_dump_sess, cli_release_show_sess },
40544067
{ { "shutdown", "session", NULL }, "shutdown session [id] : kill a specific session", cli_parse_shutdown_session, NULL, NULL },
40554068
{ { "shutdown", "sessions", "server" }, "shutdown sessions server <bk>/<srv> : kill sessions on a server", cli_parse_shutdown_sessions_server, NULL, NULL },
40564069
{{},}

0 commit comments

Comments
 (0)