interface plugin: Fix for bogus interfaces under Solaris.
authorEddy Geez <eddygeez@gmail.com>
Sat, 3 Sep 2011 13:10:21 +0000 (09:10 -0400)
committerFlorian Forster <octo@collectd.org>
Sat, 3 Sep 2011 13:10:21 +0000 (09:10 -0400)
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.

Change-Id: I1ae070ecbc820da25c0f0ad457aba80213339fd2
Signed-off-by: Florian Forster <octo@collectd.org>
src/interface.c

index 1ba6c8c..9aae5ae 100644 (file)
@@ -141,11 +141,17 @@ static int interface_init (void)
        {
                if (strncmp (ksp_chain->ks_class, "net", 3))
                        continue;
+               /* Ignore kstat entry if not the regular statistic set. This
+                * avoids problems with "bogus" interfaces, such as
+                * "wrsmd<num>" */
+               if (strncmp (ksp_chain->ks_name, ksp_chain->ks_module,
+                                       strlen (ksp_chain->ks_module)) != 0)
+                       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)
+               if ((val = get_kstat_value (ksp_chain, "ifspeed")) == -1LL)
                        continue;
                ksp[numif++] = ksp_chain;
        }