projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
cosmetic changes.
[collectd.git]
/
src
/
interface.c
diff --git
a/src/interface.c
b/src/interface.c
index
b7c6f90
..
b0d9eeb
100644
(file)
--- a/
src/interface.c
+++ b/
src/interface.c
@@
-24,9
+24,9
@@
#include "collectd.h"
#include "collectd.h"
-#include "common.h"
#include "plugin.h"
#include "plugin.h"
-#include "utils_ignorelist.h"
+#include "utils/common/common.h"
+#include "utils/ignorelist/ignorelist.h"
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
@@
-82,20
+82,25
@@
static int pnif;
* (Module-)Global variables
*/
static const char *config_keys[] = {
* (Module-)Global variables
*/
static const char *config_keys[] = {
- "Interface", "IgnoreSelected", "ReportInactive",
+ "Interface",
+ "IgnoreSelected",
+ "ReportInactive",
};
static int config_keys_num = STATIC_ARRAY_SIZE(config_keys);
};
static int config_keys_num = STATIC_ARRAY_SIZE(config_keys);
-static ignorelist_t *ignorelist
= NULL
;
+static ignorelist_t *ignorelist;
-static
_Bool report_inactive = 1
;
+static
bool report_inactive = true
;
#ifdef HAVE_LIBKSTAT
#ifdef HAVE_LIBKSTAT
+#if HAVE_KSTAT_H
+#include <kstat.h>
+#endif
#define MAX_NUMIF 256
extern kstat_ctl_t *kc;
static kstat_t *ksp[MAX_NUMIF];
#define MAX_NUMIF 256
extern kstat_ctl_t *kc;
static kstat_t *ksp[MAX_NUMIF];
-static int numif
= 0
;
-static
_Bool unique_name = 0
;
+static int numif;
+static
bool unique_name
;
#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) {
@@
-114,16
+119,16
@@
static int interface_config(const char *key, const char *value) {
else if (strcasecmp(key, "UniqueName") == 0) {
#ifdef HAVE_LIBKSTAT
if (IS_TRUE(value))
else if (strcasecmp(key, "UniqueName") == 0) {
#ifdef HAVE_LIBKSTAT
if (IS_TRUE(value))
- unique_name =
1
;
+ unique_name =
true
;
#else
WARNING("interface plugin: the \"UniqueName\" option is only valid on "
"Solaris.");
#endif /* HAVE_LIBKSTAT */
} else {
#else
WARNING("interface plugin: the \"UniqueName\" option is only valid on "
"Solaris.");
#endif /* HAVE_LIBKSTAT */
} else {
- return
(-1)
;
+ return
-1
;
}
}
- return
(0)
;
+ return
0
;
}
#if HAVE_LIBKSTAT
}
#if HAVE_LIBKSTAT
@@
-133,7
+138,7
@@
static int interface_init(void) {
numif = 0;
if (kc == NULL)
numif = 0;
if (kc == NULL)
- return
(-1)
;
+ return
-1
;
for (numif = 0, ksp_chain = kc->kc_chain;
(numif < MAX_NUMIF) && (ksp_chain != NULL);
for (numif = 0, ksp_chain = kc->kc_chain;
(numif < MAX_NUMIF) && (ksp_chain != NULL);
@@
-149,7
+154,7
@@
static int interface_init(void) {
ksp[numif++] = ksp_chain;
}
ksp[numif++] = ksp_chain;
}
- return
(0)
;
+ return
0
;
} /* int interface_init */
#endif /* HAVE_LIBKSTAT */
} /* int interface_init */
#endif /* HAVE_LIBKSTAT */
@@
-157,7
+162,8
@@
static void if_submit(const char *dev, const char *type, derive_t rx,
derive_t tx) {
value_list_t vl = VALUE_LIST_INIT;
value_t values[] = {
derive_t tx) {
value_list_t vl = VALUE_LIST_INIT;
value_t values[] = {
- {.derive = rx}, {.derive = tx},
+ {.derive = rx},
+ {.derive = tx},
};
if (ignorelist_match(ignorelist, dev) != 0)
};
if (ignorelist_match(ignorelist, dev) != 0)
@@
-185,7
+191,7
@@
static int interface_read(void) {
#define IFA_TX_PACKT ifi_opackets
#define IFA_RX_ERROR ifi_ierrors
#define IFA_TX_ERROR ifi_oerrors
#define IFA_TX_PACKT ifi_opackets
#define IFA_RX_ERROR ifi_ierrors
#define IFA_TX_ERROR ifi_oerrors
-/* #endif HAVE_STRUCT_IF_DATA */
+
/* #endif HAVE_STRUCT_IF_DATA */
#elif HAVE_STRUCT_NET_DEVICE_STATS
#define IFA_DATA net_device_stats
#elif HAVE_STRUCT_NET_DEVICE_STATS
#define IFA_DATA net_device_stats
@@
-202,7
+208,7
@@
static int interface_read(void) {
struct IFA_DATA *if_data;
if (getifaddrs(&if_list) != 0)
struct IFA_DATA *if_data;
if (getifaddrs(&if_list) != 0)
- return
(-1)
;
+ return
-1
;
for (struct ifaddrs *if_ptr = if_list; if_ptr != NULL;
if_ptr = if_ptr->ifa_next) {
for (struct ifaddrs *if_ptr = if_list; if_ptr != NULL;
if_ptr = if_ptr->ifa_next) {
@@
-223,7
+229,7
@@
static int interface_read(void) {
}
freeifaddrs(if_list);
}
freeifaddrs(if_list);
-/* #endif HAVE_GETIFADDRS */
+
/* #endif HAVE_GETIFADDRS */
#elif KERNEL_LINUX
FILE *fh;
#elif KERNEL_LINUX
FILE *fh;
@@
-236,10
+242,8
@@
static int interface_read(void) {
int numfields;
if ((fh = fopen("/proc/net/dev", "r")) == NULL) {
int numfields;
if ((fh = fopen("/proc/net/dev", "r")) == NULL) {
- char errbuf[1024];
- WARNING("interface plugin: fopen: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
- return (-1);
+ WARNING("interface plugin: fopen: %s", STRERRNO);
+ return -1;
}
while (fgets(buffer, 1024, fh) != NULL) {
}
while (fgets(buffer, 1024, fh) != NULL) {
@@
-281,7
+285,7
@@
static int interface_read(void) {
}
fclose(fh);
}
fclose(fh);
-/* #endif KERNEL_LINUX */
+
/* #endif KERNEL_LINUX */
#elif HAVE_LIBKSTAT
derive_t rx;
#elif HAVE_LIBKSTAT
derive_t rx;
@@
-289,7
+293,7
@@
static int interface_read(void) {
char iname[DATA_MAX_NAME_LEN];
if (kc == NULL)
char iname[DATA_MAX_NAME_LEN];
if (kc == NULL)
- return
(-1)
;
+ return
-1
;
for (int i = 0; i < numif; i++) {
if (kstat_read(kc, ksp[i], NULL) == -1)
for (int i = 0; i < numif; i++) {
if (kstat_read(kc, ksp[i], NULL) == -1)
@@
-331,7
+335,7
@@
static int interface_read(void) {
if ((rx != -1LL) || (tx != -1LL))
if_submit(iname, "if_errors", rx, tx);
}
if ((rx != -1LL) || (tx != -1LL))
if_submit(iname, "if_errors", rx, tx);
}
-/* #endif HAVE_LIBKSTAT */
+
/* #endif HAVE_LIBKSTAT */
#elif defined(HAVE_LIBSTATGRAB)
sg_network_io_stats *ios;
#elif defined(HAVE_LIBSTATGRAB)
sg_network_io_stats *ios;
@@
-344,7
+348,7
@@
static int interface_read(void) {
continue;
if_submit(ios[i].interface_name, "if_octets", ios[i].rx, ios[i].tx);
}
continue;
if_submit(ios[i].interface_name, "if_octets", ios[i].rx, ios[i].tx);
}
-/* #endif HAVE_LIBSTATGRAB */
+
/* #endif HAVE_LIBSTATGRAB */
#elif defined(HAVE_PERFSTAT)
perfstat_id_t id;
#elif defined(HAVE_PERFSTAT)
perfstat_id_t id;
@@
-352,10
+356,8
@@
static int interface_read(void) {
if ((nif = perfstat_netinterface(NULL, NULL, sizeof(perfstat_netinterface_t),
0)) < 0) {
if ((nif = perfstat_netinterface(NULL, NULL, sizeof(perfstat_netinterface_t),
0)) < 0) {
- char errbuf[1024];
- WARNING("interface plugin: perfstat_netinterface: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
- return (-1);
+ WARNING("interface plugin: perfstat_netinterface: %s", STRERRNO);
+ return -1;
}
if (pnif != nif || ifstat == NULL) {
}
if (pnif != nif || ifstat == NULL) {
@@
-367,10
+369,9
@@
static int interface_read(void) {
id.name[0] = '\0';
if ((ifs = perfstat_netinterface(&id, ifstat, sizeof(perfstat_netinterface_t),
nif)) < 0) {
id.name[0] = '\0';
if ((ifs = perfstat_netinterface(&id, ifstat, sizeof(perfstat_netinterface_t),
nif)) < 0) {
- char errbuf[1024];
WARNING("interface plugin: perfstat_netinterface (interfaces=%d): %s", nif,
WARNING("interface plugin: perfstat_netinterface (interfaces=%d): %s", nif,
-
sstrerror(errno, errbuf, sizeof(errbuf))
);
- return
(-1)
;
+
STRERRNO
);
+ return
-1
;
}
for (int i = 0; i < ifs; i++) {
}
for (int i = 0; i < ifs; i++) {
@@
-385,7
+386,7
@@
static int interface_read(void) {
}
#endif /* HAVE_PERFSTAT */
}
#endif /* HAVE_PERFSTAT */
- return
(0)
;
+ return
0
;
} /* int interface_read */
void module_register(void) {
} /* int interface_read */
void module_register(void) {