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.4'
[collectd.git]
/
src
/
interface.c
diff --git
a/src/interface.c
b/src/interface.c
index
d68240e
..
df8ffb4
100644
(file)
--- a/
src/interface.c
+++ b/
src/interface.c
@@
-1,6
+1,6
@@
/**
* collectd - src/interface.c
/**
* collectd - src/interface.c
- * Copyright (C) 2005-20
08
Florian octo Forster
+ * Copyright (C) 2005-20
10
Florian octo Forster
* Copyright (C) 2009 Manuel Sanmartin
*
* This program is free software; you can redistribute it and/or modify it
* Copyright (C) 2009 Manuel Sanmartin
*
* This program is free software; you can redistribute it and/or modify it
@@
-17,7
+17,7
@@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Authors:
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Authors:
- * Florian octo Forster <octo at
verplant
.org>
+ * Florian octo Forster <octo at
collectd
.org>
* Sune Marcher <sm at flork.dk>
* Manuel Sanmartin
**/
* Sune Marcher <sm at flork.dk>
* Manuel Sanmartin
**/
@@
-128,7
+128,7
@@
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;
-
unsigned long long
val;
+
derive_t
val;
numif = 0;
numif = 0;
@@
-141,17
+141,11
@@
static int interface_init (void)
{
if (strncmp (ksp_chain->ks_class, "net", 3))
continue;
{
if (strncmp (ksp_chain->ks_class, "net", 3))
continue;
- /* Ignore kstat entry if not the regular statistic set. This
- * avoids problems with "bogus" interfaces, such as
- * "wrsmd<num>" */
- if (strncmp (ksp_chain->ks_name, ksp_chain->ks_module,
- strlen (ksp_chain->ks_module)) != 0)
- continue;
if (ksp_chain->ks_type != KSTAT_TYPE_NAMED)
continue;
if (kstat_read (kc, ksp_chain, NULL) == -1)
continue;
if (ksp_chain->ks_type != KSTAT_TYPE_NAMED)
continue;
if (kstat_read (kc, ksp_chain, NULL) == -1)
continue;
- if ((val = get_kstat_value (ksp_chain, "
ifspeed
")) == -1LL)
+ if ((val = get_kstat_value (ksp_chain, "
obytes
")) == -1LL)
continue;
ksp[numif++] = ksp_chain;
}
continue;
ksp[numif++] = ksp_chain;
}
@@
-161,8
+155,8
@@
static int interface_init (void)
#endif /* HAVE_LIBKSTAT */
static void if_submit (const char *dev, const char *type,
#endif /* HAVE_LIBKSTAT */
static void if_submit (const char *dev, const char *type,
-
unsigned long long
rx,
-
unsigned long long
tx)
+
derive_t
rx,
+
derive_t
tx)
{
value_t values[2];
value_list_t vl = VALUE_LIST_INIT;
{
value_t values[2];
value_list_t vl = VALUE_LIST_INIT;
@@
-170,15
+164,15
@@
static void if_submit (const char *dev, const char *type,
if (ignorelist_match (ignorelist, dev) != 0)
return;
if (ignorelist_match (ignorelist, dev) != 0)
return;
- values[0].
counter
= rx;
- values[1].
counter
= tx;
+ values[0].
derive
= rx;
+ values[1].
derive
= tx;
vl.values = values;
vl.values_len = 2;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "interface", sizeof (vl.plugin));
vl.values = values;
vl.values_len = 2;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "interface", sizeof (vl.plugin));
+ sstrncpy (vl.plugin_instance, dev, sizeof (vl.plugin_instance));
sstrncpy (vl.type, type, sizeof (vl.type));
sstrncpy (vl.type, type, sizeof (vl.type));
- sstrncpy (vl.type_instance, dev, sizeof (vl.type_instance));
plugin_dispatch_values (&vl);
} /* void if_submit */
plugin_dispatch_values (&vl);
} /* void if_submit */
@@
-219,18
+213,19
@@
static int interface_read (void)
for (if_ptr = if_list; if_ptr != NULL; if_ptr = if_ptr->ifa_next)
{
for (if_ptr = if_list; if_ptr != NULL; if_ptr = if_ptr->ifa_next)
{
- if (
(if_data = (struct IFA_DATA *) if_ptr->ifa_data) == NULL)
-
continue
;
+ if (
if_ptr->ifa_addr != NULL && if_ptr->ifa_addr->sa_family == AF_LINK) {
+
if_data = (struct IFA_DATA *) if_ptr->ifa_data
;
- if_submit (if_ptr->ifa_name, "if_octets",
+
if_submit (if_ptr->ifa_name, "if_octets",
if_data->IFA_RX_BYTES,
if_data->IFA_TX_BYTES);
if_data->IFA_RX_BYTES,
if_data->IFA_TX_BYTES);
- if_submit (if_ptr->ifa_name, "if_packets",
+
if_submit (if_ptr->ifa_name, "if_packets",
if_data->IFA_RX_PACKT,
if_data->IFA_TX_PACKT);
if_data->IFA_RX_PACKT,
if_data->IFA_TX_PACKT);
- if_submit (if_ptr->ifa_name, "if_errors",
+
if_submit (if_ptr->ifa_name, "if_errors",
if_data->IFA_RX_ERROR,
if_data->IFA_TX_ERROR);
if_data->IFA_RX_ERROR,
if_data->IFA_TX_ERROR);
+ }
}
freeifaddrs (if_list);
}
freeifaddrs (if_list);
@@
-239,7
+234,7
@@
static int interface_read (void)
#elif KERNEL_LINUX
FILE *fh;
char buffer[1024];
#elif KERNEL_LINUX
FILE *fh;
char buffer[1024];
-
unsigned long long
incoming, outgoing;
+
derive_t
incoming, outgoing;
char *device;
char *dummy;
char *device;
char *dummy;
@@
-291,8
+286,8
@@
static int interface_read (void)
#elif HAVE_LIBKSTAT
int i;
#elif HAVE_LIBKSTAT
int i;
-
unsigned long long
rx;
-
unsigned long long
tx;
+
derive_t
rx;
+
derive_t
tx;
if (kc == NULL)
return (-1);
if (kc == NULL)
return (-1);