MINOR: stream/cli: add another filter "susp" to "show sess"
This one reports streams considered as "suspicious", i.e. those with no expiration dates or dates in the past, or those without a front endpoint. More criteria could be added in the future.
This commit is contained in:
parent
3ffcf7beb1
commit
6c7771f1b4
@ -3144,13 +3144,15 @@ show sess
|
||||
the last one that was created before the command was entered; those which
|
||||
die in the mean time will not appear.
|
||||
|
||||
show sess <id> | older <age> | all
|
||||
show sess <id> | older <age> | susp | all
|
||||
Display a lot of internal information about the matching sessions. In the
|
||||
first form, only the session matching the specified session identifier will
|
||||
be shown. This identifier is the first field at the beginning of the lines in
|
||||
the dumps of "show sess" (it corresponds to the session pointer). In the
|
||||
second form, only sessions older than <age> (in seconds by default) will be
|
||||
shown. If "all" is used instead, then all sessions will be dumped. Dumping
|
||||
shown. Passing "susp" instead will only report entries that are considered as
|
||||
suspicious by the developers based on criteria that may in time or vary along
|
||||
versions. If "all" is used instead, then all sessions will be dumped. Dumping
|
||||
many sessions can produce a huge output, take a lot of time and be CPU
|
||||
intensive, so it's always better to only dump the minimum needed. Those
|
||||
information are useless to most users but may be used by haproxy developers
|
||||
|
19
src/stream.c
19
src/stream.c
@ -3109,6 +3109,8 @@ void list_services(FILE *out)
|
||||
}
|
||||
|
||||
/* appctx context used by the "show sess" command */
|
||||
/* flags used for show_sess_ctx.flags */
|
||||
#define CLI_SHOWSESS_F_SUSP 0x00000001 /* show only suspicious streams */
|
||||
|
||||
struct show_sess_ctx {
|
||||
struct bref bref; /* back-reference from the session being dumped */
|
||||
@ -3116,6 +3118,7 @@ struct show_sess_ctx {
|
||||
unsigned int thr; /* the thread number being explored (0..MAX_THREADS-1) */
|
||||
unsigned int uid; /* if non-null, the uniq_id of the session being dumped */
|
||||
unsigned int min_age; /* minimum age of streams to dump */
|
||||
unsigned int flags; /* CLI_SHOWSESS_* */
|
||||
int section; /* section of the session being dumped */
|
||||
int pos; /* last position of the current session's buffer */
|
||||
};
|
||||
@ -3532,6 +3535,10 @@ static int cli_parse_show_sess(char **args, char *payload, struct appctx *appctx
|
||||
ctx->min_age = timeout;
|
||||
ctx->target = (void *)-1; /* show all matching entries */
|
||||
}
|
||||
else if (*args[2] && strcmp(args[2], "susp") == 0) {
|
||||
ctx->flags |= CLI_SHOWSESS_F_SUSP;
|
||||
ctx->target = (void *)-1; /* show all matching entries */
|
||||
}
|
||||
else if (*args[2] && strcmp(args[2], "all") == 0)
|
||||
ctx->target = (void *)-1;
|
||||
else if (*args[2])
|
||||
@ -3619,6 +3626,16 @@ static int cli_io_handler_dump_sess(struct appctx *appctx)
|
||||
goto next_sess;
|
||||
}
|
||||
|
||||
if (ctx->flags & CLI_SHOWSESS_F_SUSP) {
|
||||
/* only show suspicious streams. Non-suspicious ones have a valid
|
||||
* expiration date in the future and a valid front endpoint.
|
||||
*/
|
||||
if (curr_strm->task->expire &&
|
||||
!tick_is_expired(curr_strm->task->expire, now_ms) &&
|
||||
curr_strm->scf && curr_strm->scf->sedesc && curr_strm->scf->sedesc->se)
|
||||
goto next_sess;
|
||||
}
|
||||
|
||||
if (ctx->target) {
|
||||
if (ctx->target != (void *)-1 && ctx->target != curr_strm)
|
||||
goto next_sess;
|
||||
@ -3845,7 +3862,7 @@ static int cli_parse_shutdown_sessions_server(char **args, char *payload, struct
|
||||
|
||||
/* register cli keywords */
|
||||
static struct cli_kw_list cli_kws = {{ },{
|
||||
{ { "show", "sess", NULL }, "show sess [<id>|all|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 },
|
||||
{ { "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 },
|
||||
{ { "shutdown", "session", NULL }, "shutdown session [id] : kill a specific session", cli_parse_shutdown_session, NULL, NULL },
|
||||
{ { "shutdown", "sessions", "server" }, "shutdown sessions server <bk>/<srv> : kill sessions on a server", cli_parse_shutdown_sessions_server, NULL, NULL },
|
||||
{{},}
|
||||
|
Loading…
x
Reference in New Issue
Block a user