X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Finterface.c;h=b0d9eebb3e43f3de29e4c7069a41fbbc46c4a3c0;hp=6c80334e681a63e4d3825df39d05a3a5d8686cec;hb=54619dc85fd308b21ed09a0271e5c7383c7921b9;hpb=8e5e2e927f9cf051ef210473b1b48ff62d81f585 diff --git a/src/interface.c b/src/interface.c index 6c80334e..b0d9eebb 100644 --- a/src/interface.c +++ b/src/interface.c @@ -24,9 +24,9 @@ #include "collectd.h" -#include "common.h" #include "plugin.h" -#include "utils_ignorelist.h" +#include "utils/common/common.h" +#include "utils/ignorelist/ignorelist.h" #if HAVE_SYS_TYPES_H #include @@ -82,20 +82,25 @@ static int pnif; * (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 ignorelist_t *ignorelist = NULL; +static ignorelist_t *ignorelist; -static _Bool report_inactive = 1; +static bool report_inactive = true; #ifdef HAVE_LIBKSTAT +#if HAVE_KSTAT_H +#include +#endif #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) { @@ -114,7 +119,7 @@ static int interface_config(const char *key, const char *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."); @@ -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 = rx}, {.derive = tx}, + {.derive = rx}, + {.derive = tx}, }; 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 -/* #endif HAVE_STRUCT_IF_DATA */ + /* #endif HAVE_STRUCT_IF_DATA */ #elif HAVE_STRUCT_NET_DEVICE_STATS #define IFA_DATA net_device_stats @@ -223,7 +229,7 @@ static int interface_read(void) { } freeifaddrs(if_list); -/* #endif HAVE_GETIFADDRS */ + /* #endif HAVE_GETIFADDRS */ #elif KERNEL_LINUX FILE *fh; @@ -279,7 +285,7 @@ static int interface_read(void) { } fclose(fh); -/* #endif KERNEL_LINUX */ + /* #endif KERNEL_LINUX */ #elif HAVE_LIBKSTAT derive_t rx; @@ -294,8 +300,8 @@ static int interface_read(void) { continue; if (unique_name) - snprintf(iname, sizeof(iname), "%s_%d_%s", ksp[i]->ks_module, - ksp[i]->ks_instance, ksp[i]->ks_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)); @@ -329,7 +335,7 @@ static int interface_read(void) { 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; @@ -342,7 +348,7 @@ static int interface_read(void) { 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;