From 30cfed83c4d662a0996b49fe48eeb9a3ddd09944 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Thu, 25 Sep 2014 19:10:32 -0700 Subject: [PATCH] cpu plugin: Don't report empty cpu states. --- src/cpu.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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); -- 2.30.2