From e09cdc6d4823cb0e78518d82362f6cc7568a9cf8 Mon Sep 17 00:00:00 2001 From: William Lallemand Date: Mon, 19 Nov 2018 18:46:16 +0100 Subject: [PATCH] MINOR: cli: format `show proc` to be more readable Add more space on the output to be more readable and separate old processes from current ones. --- src/cli.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/cli.c b/src/cli.c index 199d25fcf..3d3abb893 100644 --- a/src/cli.c +++ b/src/cli.c @@ -1398,18 +1398,36 @@ static int cli_io_handler_show_proc(struct appctx *appctx) { struct stream_interface *si = appctx->owner; struct mworker_proc *child; + int old = 0; if (unlikely(si_ic(si)->flags & (CF_WRITE_ERROR|CF_SHUTW))) return 1; chunk_reset(&trash); - chunk_printf(&trash, "# \n"); - chunk_appendf(&trash, "%u %s %u %d\n", getpid(), "master", 0, -1); + chunk_printf(&trash, "#%-14s %-15s %-15s %-15s\n", "", "", "", ""); + chunk_appendf(&trash, "%-15u %-15s %-15u %-15s\n", getpid(), "master", 0, "-"); + /* displays current processes */ + chunk_appendf(&trash, "# workers\n"); list_for_each_entry(child, &proc_list, list) { - chunk_appendf(&trash, "%u %s %u %d\n", child->pid, "worker", child->relative_pid, child->reloads); + + if (child->reloads > 0) { + old++; + continue; + } + chunk_appendf(&trash, "%-15u %-15s %-15u %-15d\n", child->pid, "worker", child->relative_pid, child->reloads); +} + + /* displays old processes */ + + if (old) { + chunk_appendf(&trash, "# old workers\n"); + list_for_each_entry(child, &proc_list, list) { + if (child->reloads > 0) + chunk_appendf(&trash, "%-15u %-15s %-15u %-15d\n", child->pid, "worker", child->relative_pid, child->reloads); + } } if (ci_putchk(si_ic(si), &trash) == -1) {