projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
interface plugin: Add UniqueName config property.
[collectd.git]
/
src
/
interface.c
diff --git
a/src/interface.c
b/src/interface.c
index
df8ffb4
..
d9a0db3
100644
(file)
--- a/
src/interface.c
+++ b/
src/interface.c
@@
-31,9
+31,6
@@
#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
-#if HAVE_SYS_SOCKET_H
-# include <sys/socket.h>
-#endif
/* One cannot include both. This sucks. */
#if HAVE_LINUX_IF_H
/* One cannot include both. This sucks. */
#if HAVE_LINUX_IF_H
@@
-92,6
+89,7
@@
static const char *config_keys[] =
static int config_keys_num = 2;
static ignorelist_t *ignorelist = NULL;
static int config_keys_num = 2;
static ignorelist_t *ignorelist = NULL;
+static _Bool unique_name = 0;
#ifdef HAVE_LIBKSTAT
#define MAX_NUMIF 256
#ifdef HAVE_LIBKSTAT
#define MAX_NUMIF 256
@@
-116,6
+114,11
@@
static int interface_config (const char *key, const char *value)
invert = 0;
ignorelist_set_invert (ignorelist, invert);
}
invert = 0;
ignorelist_set_invert (ignorelist, invert);
}
+ else if (strcasecmp (key, "UniqueName") == 0)
+ {
+ if (IS_TRUE (value))
+ unique_name = 1;
+ }
else
{
return (-1);
else
{
return (-1);
@@
-288,6
+291,7
@@
static int interface_read (void)
int i;
derive_t rx;
derive_t tx;
int i;
derive_t rx;
derive_t tx;
+ char iname[DATA_MAX_NAME_LEN];
if (kc == NULL)
return (-1);
if (kc == NULL)
return (-1);
@@
-297,6
+301,11
@@
static int interface_read (void)
if (kstat_read (kc, ksp[i], NULL) == -1)
continue;
if (kstat_read (kc, ksp[i], NULL) == -1)
continue;
+ 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");
tx = get_kstat_value (ksp[i], "obytes64");
/* try to get 64bit counters */
rx = get_kstat_value (ksp[i], "rbytes64");
tx = get_kstat_value (ksp[i], "obytes64");
@@
-306,7
+315,7
@@
static int interface_read (void)
if (tx == -1LL)
tx = get_kstat_value (ksp[i], "obytes");
if ((rx != -1LL) || (tx != -1LL))
if (tx == -1LL)
tx = get_kstat_value (ksp[i], "obytes");
if ((rx != -1LL) || (tx != -1LL))
- if_submit (
ksp[i]->ks_
name, "if_octets", rx, tx);
+ if_submit (
i
name, "if_octets", rx, tx);
/* try to get 64bit counters */
rx = get_kstat_value (ksp[i], "ipackets64");
/* try to get 64bit counters */
rx = get_kstat_value (ksp[i], "ipackets64");
@@
-317,13
+326,13
@@
static int interface_read (void)
if (tx == -1LL)
tx = get_kstat_value (ksp[i], "opackets");
if ((rx != -1LL) || (tx != -1LL))
if (tx == -1LL)
tx = get_kstat_value (ksp[i], "opackets");
if ((rx != -1LL) || (tx != -1LL))
- if_submit (
ksp[i]->ks_
name, "if_packets", rx, tx);
+ if_submit (
i
name, "if_packets", rx, tx);
/* no 64bit error counters yet */
rx = get_kstat_value (ksp[i], "ierrors");
tx = get_kstat_value (ksp[i], "oerrors");
if ((rx != -1LL) || (tx != -1LL))
/* no 64bit error counters yet */
rx = get_kstat_value (ksp[i], "ierrors");
tx = get_kstat_value (ksp[i], "oerrors");
if ((rx != -1LL) || (tx != -1LL))
- if_submit (
ksp[i]->ks_
name, "if_errors", rx, tx);
+ if_submit (
i
name, "if_errors", rx, tx);
}
/* #endif HAVE_LIBKSTAT */
}
/* #endif HAVE_LIBKSTAT */