X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Finterface.c;h=1c01f6ff773cf8e5bb92697b73e21e4bacee1663;hb=0d9a0eb065fda6f89fc597e760ae56edd47337d9;hp=c3f5d40affe4c1a5dbb88e1a352858e0532c276a;hpb=2b9c9acf48c81dba1ea69c84bc282b5a926759a0;p=collectd.git diff --git a/src/interface.c b/src/interface.c index c3f5d40a..1c01f6ff 100644 --- a/src/interface.c +++ b/src/interface.c @@ -95,6 +95,7 @@ static ignorelist_t *ignorelist = NULL; 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) @@ -113,6 +114,15 @@ static int interface_config (const char *key, const char *value) invert = 0; ignorelist_set_invert (ignorelist, invert); } + 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 { return (-1); @@ -295,7 +305,10 @@ static int interface_read (void) if (kstat_read (kc, ksp[i], NULL) == -1) continue; - snprintf(iname, sizeof(iname), "%s_%d_%s", ksp[i]->ks_module, ksp[i]->ks_instance, ksp[i]->ks_name); + if (unique_name) + ssnprintf(iname, sizeof(iname), "%s_%d_%s", ksp[i]->ks_module, ksp[i]->ks_instance, ksp[i]->ks_name); + else + sstrncpy(iname, ksp[i]->ks_name, sizeof(iname)); /* try to get 64bit counters */ rx = get_kstat_value (ksp[i], "rbytes64");