From: Florian Forster Date: Mon, 5 May 2008 12:03:41 +0000 (+0200) Subject: cpu plugin: Account wait-IO, system and swap separately when using libstatgrab. X-Git-Tag: collectd-4.4.0~19 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=aa3a8be60d82cc31e776acbfed30451c2afc45a9;p=collectd.git cpu plugin: Account wait-IO, system and swap separately when using libstatgrab. --- diff --git a/src/cpu.c b/src/cpu.c index 2165ce64..7692e2b5 100644 --- a/src/cpu.c +++ b/src/cpu.c @@ -387,13 +387,20 @@ static int cpu_read (void) #elif defined(HAVE_LIBSTATGRAB) sg_cpu_stats *cs; - if ((cs = sg_get_cpu_stats ()) == NULL) - return (0); - - submit (0, "idle", (counter_t) cs->idle); - submit (0, "nice", (counter_t) cs->nice); - submit (0, "user", (counter_t) cs->user); - submit (0, "system", (counter_t) (cs->kernel+cs->swap+cs->iowait)); + cs = sg_get_cpu_stats (); + + if (cs == NULL) + { + ERROR ("cpu plugin: sg_get_cpu_stats failed."); + return (-1); + } + + submit (0, "idle", (counter_t) cs->idle); + submit (0, "nice", (counter_t) cs->nice); + submit (0, "swap", (counter_t) cs->swap); + submit (0, "system", (counter_t) cs->kernel); + submit (0, "user", (counter_t) cs->user); + submit (0, "wait", (counter_t) cs->iowait); #endif /* HAVE_LIBSTATGRAB */ return (0);