[collectd] [patch] Fix for bogus interfaces under Solaris

Eddy Geez eddygeez at gmail.com
Wed Aug 31 16:18:35 CEST 2011


Under newer versions of Solaris, the method for finding network
interfaces results in 'collectd' gathering statistics on an interface
called 'mac', along with 16 interfaces named 'wrsmd0' through
'wrsmd15' (which are for WCI Remote Shared Memory). The 'mac'
interface is especially problematic because it occurs multiple times,
which results in warnings from rrdtool about insertions with the same
timestamp.

This patch addresses the issue by identifying only the physical
network interfaces:

*** interface.c.orig    Sun Mar 27 16:35:08 2011
--- interface.c Wed Aug 31 13:20:20 2011
***************
*** 141,151 ****
        {
                if (strncmp (ksp_chain->ks_class, "net", 3))
                        continue;
                if (ksp_chain->ks_type != KSTAT_TYPE_NAMED)
                        continue;
                if (kstat_read (kc, ksp_chain, NULL) == -1)
                        continue;
!               if ((val = get_kstat_value (ksp_chain, "obytes")) == -1LL)
                        continue;
                ksp[numif++] = ksp_chain;
        }
--- 141,153 ----
        {
                if (strncmp (ksp_chain->ks_class, "net", 3))
                        continue;
+               /* ignore kstat entry if not the regular statistic set */
+               if (strncmp (ksp_chain->ks_name, ksp_chain->ks_module,
strlen(ksp_chain->ks_module)))
+                       continue;
                if (ksp_chain->ks_type != KSTAT_TYPE_NAMED)
                        continue;
                if (kstat_read (kc, ksp_chain, NULL) == -1)
                        continue;
+               /* ifspeed is a better indicator of a physical network
interface than obytes */
!               if ((val = get_kstat_value (ksp_chain, "ifspeed")) == -1LL)
                        continue;
                ksp[numif++] = ksp_chain;
        }

Also, for what it's worth, I needed to add this line to 'configure.in'
so that 'errno' worked properly under Solaris. Otherwise the call to
stat() in rrd_write in 'rrdtool.c' always resulted in a bogus error
about the disk being out of space.

if test "x$ac_system" = "xSolaris"
then
        AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1, [Define to enforce
POSIX thread semantics under Solaris.])
        AC_DEFINE(_REENTRANT, 1, [Define so errno works under Solaris.])
fi



More information about the collectd mailing list