From 04b5b266e5ede7b6e2c51c04acc9e6290728cd32 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 25 Nov 2022 15:36:48 +0100 Subject: [PATCH] MINOR: activity: report uptime in "show activity" It happened a few times that it was difficult to figure if a counter was normal or not in "show activity" based on the uptime. Let's just emit the uptime value along with the date. --- src/cli.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cli.c b/src/cli.c index 2b3ea3a3c..864031cf4 100644 --- a/src/cli.c +++ b/src/cli.c @@ -1469,6 +1469,7 @@ static int cli_io_handler_show_activity(struct appctx *appctx) struct stconn *sc = appctx_sc(appctx); struct show_activity_ctx *actctx = appctx->svcctx; int tgt = actctx->thr; // target thread, -1 for all, 0 for total only + struct timeval up; int thr; if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW))) @@ -1526,8 +1527,12 @@ static int cli_io_handler_show_activity(struct appctx *appctx) chunk_appendf(&trash, " %u\n", _v[tgt-1]);\ } while (0) + /* retrieve uptime */ + tv_remain(&start_date, &now, &up); + chunk_appendf(&trash, "thread_id: %u (%u..%u)\n", tid + 1, 1, global.nbthread); - chunk_appendf(&trash, "date_now: %lu.%06lu\n", (long)now.tv_sec, (long)now.tv_usec); + chunk_appendf(&trash, "date_now: %lu.%06lu\n", (ulong)now.tv_sec, (ulong)now.tv_usec); + chunk_appendf(&trash, "uptime_now: %lu.%06lu\n", (ulong)up.tv_sec, (ulong)up.tv_usec); chunk_appendf(&trash, "ctxsw:"); SHOW_TOT(thr, activity[thr].ctxsw); chunk_appendf(&trash, "tasksw:"); SHOW_TOT(thr, activity[thr].tasksw); chunk_appendf(&trash, "empty_rq:"); SHOW_TOT(thr, activity[thr].empty_rq);