From bb041043a6ec30a284d140ef9cae1d1e51965889 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Fri, 19 Jan 2024 21:01:21 +0100 Subject: [PATCH] cpu plugin: Apply code review suggestions. Co-authored-by: Eero Tamminen --- src/collectd.conf.pod | 2 +- src/cpu.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod index d0956097b..0de74a291 100644 --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@ -1790,7 +1790,7 @@ Sets whether CPU usage (in jiffies/seconds) is reported. Defaults to B. =item B B|B -Sets whether CPU utilization (a ratio) is reported. Defaults to B. +Sets whether CPU utilization ratio is reported. Defaults to B. When enabled, the B and B options can be used to report aggregated data. diff --git a/src/cpu.c b/src/cpu.c index f25d80b6d..4c40dd6a8 100644 --- a/src/cpu.c +++ b/src/cpu.c @@ -428,6 +428,8 @@ static void usage_finalize(usage_t *u) { size_t cpu_num = u->states_num / STATE_MAX; gauge_t state_ratio[STATE_MAX] = {0}; + // Aggregate non-idle CPU states to STATE_ACTIVE and all CPUs' states to + // global states. for (size_t cpu = 0; cpu < cpu_num; cpu++) { size_t active_index = (cpu * STATE_MAX) + STATE_ACTIVE; usage_state_t *active = u->states + active_index; -- 2.47.2