From: Florian Forster Date: Fri, 26 Sep 2014 02:10:32 +0000 (-0700) Subject: cpu plugin: Don't report empty cpu states. X-Git-Tag: collectd-5.5.0~174 X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=30cfed83c4d662a0996b49fe48eeb9a3ddd09944;p=collectd.git cpu plugin: Don't report empty cpu states. --- diff --git a/src/cpu.c b/src/cpu.c index 475d18ac..fae7ab9a 100644 --- a/src/cpu.c +++ b/src/cpu.c @@ -343,6 +343,12 @@ static void submit_percent(int cpu_num, int cpu_state, gauge_t percent) { value_t value; + /* This function is called for all known CPU states, but each read + * method will only report a subset. The remaining states are left as + * NAN and we ignore them here. */ + if (isnan (percent)) + return; + value.gauge = percent; submit_value (cpu_num, cpu_state, "percent", value); } @@ -362,9 +368,6 @@ static int cpu_states_alloc (size_t cpu_num) /* {{{ */ cpu_state_t *tmp; size_t sz; - if (cpu_num < 0) - return (EINVAL); - sz = (((size_t) cpu_num) + 1) * CPU_STATE_MAX; assert (sz > 0);