]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: activity: add a line reporting the average CPU usage to "show activity"
authorWilly Tarreau <w@1wt.eu>
Tue, 11 Apr 2023 13:26:24 +0000 (15:26 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 12 Apr 2023 06:42:52 +0000 (08:42 +0200)
It was missing from the output but is sometimes convenient to observe
and understand how incoming connections are distributed. The CPU usage
is reported as the instant measurement of 100-idle_pct for each thread,
and the average value is shown for the aggregated value.

This could be backported as it's helpful in certain troublehsooting
sessions.

src/activity.c

index 9d396cd9066a0ab7a46d47aa50f2e6d025a7cc6d..0e021b08e51894f776718719e8fb7688f9f125de 100644 (file)
@@ -1109,6 +1109,7 @@ static int cli_io_handler_show_activity(struct appctx *appctx)
        chunk_appendf(&trash, "cpust_ms_tot:"); SHOW_TOT(thr, activity[thr].cpust_total / 2);
        chunk_appendf(&trash, "cpust_ms_1s:");  SHOW_TOT(thr, read_freq_ctr(&activity[thr].cpust_1s) / 2);
        chunk_appendf(&trash, "cpust_ms_15s:"); SHOW_TOT(thr, read_freq_ctr_period(&activity[thr].cpust_15s, 15000) / 2);
+       chunk_appendf(&trash, "avg_cpu_pct:");  SHOW_AVG(thr, (100 - ha_thread_ctx[thr].idle_pct));
        chunk_appendf(&trash, "avg_loop_us:");  SHOW_AVG(thr, swrate_avg(activity[thr].avg_loop_us, TIME_STATS_SAMPLES));
        chunk_appendf(&trash, "accepted:");     SHOW_TOT(thr, activity[thr].accepted);
        chunk_appendf(&trash, "accq_pushed:");  SHOW_TOT(thr, activity[thr].accq_pushed);