summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a4e8b6a)
raw | patch | inline | side by side (parent: a4e8b6a)
author | Yoga Ramalingam <yramalingam1@bloomberg.net> | |
Mon, 7 Dec 2015 20:59:39 +0000 (15:59 -0500) | ||
committer | Florian Forster <octo@collectd.org> | |
Tue, 8 Dec 2015 08:21:18 +0000 (09:21 +0100) |
Issue: #1416
src/collectd.conf.in | patch | blob | history | |
src/collectd.conf.pod | patch | blob | history | |
src/interface.c | patch | blob | history |
diff --git a/src/collectd.conf.in b/src/collectd.conf.in
index eb230235f13c4412165aeea78fa39cae5296635e..a75bcc04f90c114046468d1f51a7149fe9bb75eb 100644 (file)
--- a/src/collectd.conf.in
+++ b/src/collectd.conf.in
#<Plugin interface>
# Interface "eth0"
# IgnoreSelected false
+# UniqueName false
#</Plugin>
#<Plugin ipmi>
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index a5af576239492a379ca88b40ac324bf5ed9d245a..ff95091168b69bc1880c3f37bdc18d499e82270b 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
B<Interface> is inverted: All selected interfaces are ignored and all
other interfaces are collected.
+=item B<UniqueName> I<true>|I<false>
+
+Interface name is not unique on Solaris (KSTAT), interface name is unique
+only within a module/instance. Following tuple is considered unique:
+ (ks_module, ks_instance, ks_name)
+If this option is set to true, interface name contains above three fields
+separated by an underscore. For more info on KSTAT, visit
+L<http://docs.oracle.com/cd/E23824_01/html/821-1468/kstat-3kstat.html#REFMAN3Ekstat-3kstat>
+
+This option is only available on Solaris.
+
=back
=head2 Plugin C<ipmi>
diff --git a/src/interface.c b/src/interface.c
index d9a0db3a6aea532976cb6bf12406a50724577afd..1c01f6ff773cf8e5bb92697b73e21e4bacee1663 100644 (file)
--- a/src/interface.c
+++ b/src/interface.c
static int config_keys_num = 2;
static ignorelist_t *ignorelist = NULL;
-static _Bool unique_name = 0;
#ifdef HAVE_LIBKSTAT
#define MAX_NUMIF 256
extern kstat_ctl_t *kc;
static kstat_t *ksp[MAX_NUMIF];
static int numif = 0;
+static _Bool unique_name = 0;
#endif /* HAVE_LIBKSTAT */
static int interface_config (const char *key, const char *value)
}
else if (strcasecmp (key, "UniqueName") == 0)
{
+ #ifdef HAVE_LIBKSTAT
if (IS_TRUE (value))
unique_name = 1;
+ #else
+ WARNING ("interface plugin: the \"UniqueName\" option is only valid on Solaris.");
+ #endif /* HAVE_LIBKSTAT */
}
else
{
continue;
if (unique_name)
- snprintf(iname, sizeof(iname), "%s_%d_%s", ksp[i]->ks_module, ksp[i]->ks_instance, ksp[i]->ks_name);
+ ssnprintf(iname, sizeof(iname), "%s_%d_%s", ksp[i]->ks_module, ksp[i]->ks_instance, ksp[i]->ks_name);
else
- snprintf(iname, sizeof(iname), "%s", ksp[i]->ks_name);
+ sstrncpy(iname, ksp[i]->ks_name, sizeof(iname));
/* try to get 64bit counters */
rx = get_kstat_value (ksp[i], "rbytes64");