[collectd] cpu plugin patch

Oleg King king2 at kaluga.ru
Thu May 1 18:35:31 CEST 2008


  I made some workaround about cpu plugin and have found the

  In FreeBSD sysctlbyname(kern.cp_time) collects information about
  entire system, not for first CPU only (as documented). So, patch
  that uses libstatgrab is completely unnecessary because of:
  1. We already have right information about all CPUs together
  2. libstatgrab uses same methods to get info as collectd does.

  Only one thing we should do is turning off report about first
  CPU only if we have FreeBSD. Patch follows:

diff -pur collectd/src/cpu.c collectd.my/src/cpu.c
--- collectd/src/cpu.c  2008-05-01 20:26:53.000000000 +0400
+++ collectd.my/src/cpu.c       2008-05-01 20:34:44.000000000 +0400
@@ -150,8 +150,11 @@ static int init (void)
                return (-1);

+#ifndef __FreeBSD__
+        /* On FreeBSD, sysctlbyname reports info about entire system, not about first CPU only */
        if (numcpu != 1)
                NOTICE ("cpu: Only one processor supported when using `sysctlbyname' (found %i)", numcpu);
+#endif /* __FreeBSD__ */

        return (0);

 Oleg                          mailto:king2 at kaluga.ru

More information about the collectd mailing list