From: Florian Forster Date: Tue, 2 Dec 2014 10:22:13 +0000 (+0100) Subject: cpu plugin: Mark the "active" state as available. X-Git-Tag: collectd-5.5.0~117 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=9f472bd76feaebfe8a50f7ac3e9e05ce87ce3c6b;p=collectd.git cpu plugin: Mark the "active" state as available. This fixes the !ByState && ByCpu case, i.e. when the user requests one metric ("active") per CPU. Bug: #820 --- diff --git a/src/cpu.c b/src/cpu.c index 9d812c80..8d9c0a6f 100644 --- a/src/cpu.c +++ b/src/cpu.c @@ -419,6 +419,9 @@ static void aggregate (gauge_t *sum_by_state) /* {{{ */ RATE_ADD (this_cpu_states[COLLECTD_CPU_STATE_ACTIVE].rate, this_cpu_states[state].rate); } + if (!isnan (this_cpu_states[COLLECTD_CPU_STATE_ACTIVE].rate)) + this_cpu_states[COLLECTD_CPU_STATE_ACTIVE].has_value = 1; + RATE_ADD (sum_by_state[COLLECTD_CPU_STATE_ACTIVE], this_cpu_states[COLLECTD_CPU_STATE_ACTIVE].rate); } } /* }}} void aggregate */ @@ -514,7 +517,7 @@ static void cpu_commit (void) /* {{{ */ }; size_t state; - for (state = 0; state < COLLECTD_CPU_STATE_ACTIVE; state++) + for (state = 0; state < COLLECTD_CPU_STATE_MAX; state++) if (this_cpu_states[state].has_value) local_rates[state] = this_cpu_states[state].rate;