From: Yoga Ramalingam Date: Mon, 7 Dec 2015 15:09:08 +0000 (-0500) Subject: interface plugin: Add UniqueName config property. X-Git-Tag: collectd-5.6.0~516 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=a4e8b6a17640e1eaec51801fd0f61aef4cd287d9;p=collectd.git interface plugin: Add UniqueName config property. Issue: #1416 --- diff --git a/src/interface.c b/src/interface.c index c3f5d40a..d9a0db3a 100644 --- a/src/interface.c +++ b/src/interface.c @@ -89,6 +89,7 @@ static const char *config_keys[] = static int config_keys_num = 2; static ignorelist_t *ignorelist = NULL; +static _Bool unique_name = 0; #ifdef HAVE_LIBKSTAT #define MAX_NUMIF 256 @@ -113,6 +114,11 @@ static int interface_config (const char *key, const char *value) invert = 0; ignorelist_set_invert (ignorelist, invert); } + else if (strcasecmp (key, "UniqueName") == 0) + { + if (IS_TRUE (value)) + unique_name = 1; + } else { return (-1); @@ -295,7 +301,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) + snprintf(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); /* try to get 64bit counters */ rx = get_kstat_value (ksp[i], "rbytes64");