projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'collectd-5.5'
[collectd.git]
/
src
/
interface.c
diff --git
a/src/interface.c
b/src/interface.c
index
e17711e
..
bc2121b
100644
(file)
--- 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;
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)
#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);
}
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);
else
{
return (-1);
@@
-125,7
+135,6
@@
static int interface_config (const char *key, const char *value)
static int interface_init (void)
{
kstat_t *ksp_chain;
static int interface_init (void)
{
kstat_t *ksp_chain;
- derive_t val;
numif = 0;
numif = 0;
@@
-142,7
+151,7
@@
static int interface_init (void)
continue;
if (kstat_read (kc, ksp_chain, NULL) == -1)
continue;
continue;
if (kstat_read (kc, ksp_chain, NULL) == -1)
continue;
- if (
(val = get_kstat_value (ksp_chain, "obytes")
) == -1LL)
+ if (
get_kstat_value (ksp_chain, "obytes"
) == -1LL)
continue;
ksp[numif++] = ksp_chain;
}
continue;
ksp[numif++] = ksp_chain;
}
@@
-180,7
+189,7
@@
static int interface_read (void)
struct ifaddrs *if_list;
struct ifaddrs *if_ptr;
struct ifaddrs *if_list;
struct ifaddrs *if_ptr;
-/* Darin/Mac OS X and possible other *BSDs */
+/* Dar
w
in/Mac OS X and possible other *BSDs */
#if HAVE_STRUCT_IF_DATA
# define IFA_DATA if_data
# define IFA_RX_BYTES ifi_ibytes
#if HAVE_STRUCT_IF_DATA
# define IFA_DATA if_data
# define IFA_RX_BYTES ifi_ibytes
@@
-276,6
+285,10
@@
static int interface_read (void)
incoming = atoll (fields[2]);
outgoing = atoll (fields[10]);
if_submit (device, "if_errors", incoming, outgoing);
incoming = atoll (fields[2]);
outgoing = atoll (fields[10]);
if_submit (device, "if_errors", incoming, outgoing);
+
+ incoming = atoll (fields[3]);
+ outgoing = atoll (fields[11]);
+ if_submit (device, "if_dropped", incoming, outgoing);
}
fclose (fh);
}
fclose (fh);
@@
-285,6
+298,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);
@@
-294,6
+308,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)
+ 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");
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");
@@
-303,7
+322,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");
@@
-314,13
+333,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 */
@@
-348,9
+367,8
@@
static int interface_read (void)
if (pnif != nif || ifstat == NULL)
{
if (pnif != nif || ifstat == NULL)
{
- if (ifstat != NULL)
- free(ifstat);
- ifstat = malloc(nif * sizeof(perfstat_netinterface_t));
+ free(ifstat);
+ ifstat = malloc(nif * sizeof (*ifstat));
}
pnif = nif;
}
pnif = nif;