]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: activity: report uptime in "show activity"
authorWilly Tarreau <w@1wt.eu>
Fri, 25 Nov 2022 14:36:48 +0000 (15:36 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 25 Nov 2022 14:36:48 +0000 (15:36 +0100)
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

index 2b3ea3a3c9d8e0341e544a7d9e4619e3537fde5b..864031cf46702ad91b6659762e0f959894188cfa 100644 (file)
--- 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);