diff options
author | Nick Hainke <vincent@systemli.org> | 2021-01-10 12:45:25 +0100 |
---|---|---|
committer | Hannu Nyman <hannu.nyman@iki.fi> | 2021-01-11 15:16:43 +0200 |
commit | 014551314ead1fa061e4b381e008df9d8df42d11 (patch) | |
tree | 4363c4a63e3b895d68dae2fa88998e23d9026912 | |
parent | 67726c2b4993cf535f1d7b1e2fade97be3b870ed (diff) |
collectd: fix snmp6 collector
We scraped multiple times the same interface in one run.
Signed-off-by: Nick Hainke <vincent@systemli.org>
-rw-r--r-- | utils/collectd/Makefile | 2 | ||||
-rw-r--r-- | utils/collectd/patches/931-snmp6-add-ipv6-statistics.patch | 40 |
2 files changed, 20 insertions, 22 deletions
diff --git a/utils/collectd/Makefile b/utils/collectd/Makefile index b828dbe2b..2fedf5980 100644 --- a/utils/collectd/Makefile +++ b/utils/collectd/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=collectd PKG_VERSION:=5.12.0 -PKG_RELEASE:=4 +PKG_RELEASE:=5 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:=https://collectd.org/files/ \ diff --git a/utils/collectd/patches/931-snmp6-add-ipv6-statistics.patch b/utils/collectd/patches/931-snmp6-add-ipv6-statistics.patch index ed27502f9..213801ba6 100644 --- a/utils/collectd/patches/931-snmp6-add-ipv6-statistics.patch +++ b/utils/collectd/patches/931-snmp6-add-ipv6-statistics.patch @@ -90,27 +90,20 @@ Signed-off-by: Nick Hainke <vincent@systemli.org> # Port "8125" --- /dev/null +++ b/src/snmp6.c -@@ -0,0 +1,135 @@ +@@ -0,0 +1,133 @@ +/* + This Plugin is based opn the interface.c Plugin. +*/ -+ -+#if HAVE_LINUX_IF_H -+#include <linux/if.h> -+#elif HAVE_NET_IF_H -+#include <net/if.h> -+#endif -+ -+#include <ifaddrs.h> -+ +#include <stdint.h> +#include <stdlib.h> +#include <string.h> -+ +#include <errno.h> +#include <stdbool.h> +#include <stdio.h> ++ ++#include <net/if.h> +#include <sys/types.h> ++#include <ifaddrs.h> + +#include "plugin.h" +#include "utils/cmds/putval.h" @@ -124,7 +117,6 @@ Signed-off-by: Nick Hainke <vincent@systemli.org> +static int config_keys_num = STATIC_ARRAY_SIZE(config_keys); + +static ignorelist_t *ignorelist; -+struct ifaddrs *if_list; + +static int snmp6_config(const char *key, const char *value) { + if (ignorelist == NULL) @@ -151,9 +143,6 @@ Signed-off-by: Nick Hainke <vincent@systemli.org> + {.derive = tx}, + }; + -+ if (ignorelist_match(ignorelist, dev) != 0) -+ return; -+ + vl.values = values; + vl.values_len = STATIC_ARRAY_SIZE(values); + sstrncpy(vl.plugin, "snmp6", sizeof(vl.plugin)); @@ -173,6 +162,9 @@ Signed-off-by: Nick Hainke <vincent@systemli.org> + char procpath[1024]; + int offset = 0; + ++ if (ignorelist_match(ignorelist, ifname) != 0) ++ return 0; ++ + if (strncmp("all", ifname, strlen("all")) == 0) { + snprintf(procpath, 1024, "/proc/net/snmp6"); + offset = 1; @@ -181,7 +173,7 @@ Signed-off-by: Nick Hainke <vincent@systemli.org> + } + + if ((fh = fopen(procpath, "r")) == NULL) { -+ WARNING("interface plugin: fopen: %s", STRERRNO); ++ WARNING("snmp6 plugin: try opening %s : fopen: %s", procpath, STRERRNO); + return -1; + } + @@ -210,13 +202,19 @@ Signed-off-by: Nick Hainke <vincent@systemli.org> +#ifndef HAVE_IFADDRS_H + return -1; +#else -+ if (getifaddrs(&if_list) != 0) -+ return -1; ++ struct ifaddrs *addrs,*tmp; ++ ++ getifaddrs(&addrs); ++ tmp = addrs; + -+ for (struct ifaddrs *if_ptr = if_list; if_ptr != NULL; -+ if_ptr = if_ptr->ifa_next) { -+ snmp_read(if_ptr->ifa_name); ++ while (tmp) ++ { ++ if (tmp->ifa_addr && tmp->ifa_addr->sa_family == AF_PACKET) ++ snmp_read(tmp->ifa_name); ++ tmp = tmp->ifa_next; + } ++ ++ freeifaddrs(addrs); + snmp_read("all"); + return 0; +#endif |