Browse Source

collectd: interface plugin: revert to Linux defaults from BSD-like operations

Change the interface plugin to operate with collectd's default way for Linux
instead of trying to use BSD functionality with patches.

Openwrt's collectd Makefile has set "enable-getifaddrs" option since r7980
(in 2007, no explanations given for the reasons to add that config option),
causing the addition of 110-net-device-stats.patch in 2010 to fix things,
and then later (with 5.4.1 upgrade in 2014) 150-fix-interface-af-link
to undo BSD-specific changes in collectd code meant for only BSD systems
(as AF_LINK does not exist in Linux).

Revert to collectd's intended way in Linux by removing the config option
and deleting the two corresponding patches.

The same data fieds should be provided, so there is no visbile change to users.

References:
===========

Collectd changes introducing/explaining the option and later breaking things:
http://git.verplant.org/?p=collectd.git;a=commit;h=a05e34a0d4fdb2c15db8226689268a27f6f7163d
http://git.verplant.org/?p=collectd.git;a=commit;h=14740db4b415655abc58307352e406442f9933a0
http://git.verplant.org/?p=collectd.git;a=commitdiff;h=645dadb3fcc466e8880fda4eb23b21ad433631fc

Openwrt:
intro at r7980: https://dev.openwrt.org/changeset/7980
fix1 due to kernel 2.6.36 at r23467: https://dev.openwrt.org/changeset/23467
fix2 due to collectd 5.4.1: https://github.com/openwrt/packages/pull/298

Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
lilik-openwrt-22.03
Hannu Nyman 9 years ago
parent
commit
d91cd622c0
3 changed files with 1 additions and 69 deletions
  1. +1
    -2
      utils/collectd/Makefile
  2. +0
    -46
      utils/collectd/patches/110-net-device-stats.patch
  3. +0
    -21
      utils/collectd/patches/150-fix-interface-af-link

+ 1
- 2
utils/collectd/Makefile View File

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=collectd
PKG_VERSION:=5.5.0
PKG_RELEASE:=1
PKG_RELEASE:=2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=http://collectd.org/files/
@ -184,7 +184,6 @@ endif
CONFIGURE_ARGS+= \
--disable-debug \
--enable-daemon \
--enable-getifaddrs \
--with-nan-emulation \
--without-libgcrypt


+ 0
- 46
utils/collectd/patches/110-net-device-stats.patch View File

@ -1,46 +0,0 @@
---
src/interface.c | 33 ++++++++++++++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
--- a/src/interface.c
+++ b/src/interface.c
@@ -203,7 +203,38 @@ static int interface_read (void)
# define IFA_RX_ERROR rx_errors
# define IFA_TX_ERROR tx_errors
#else
-# error "No suitable type for `struct ifaddrs->ifa_data' found."
+struct net_device_stats {
+ unsigned long rx_packets;
+ unsigned long tx_packets;
+ unsigned long rx_bytes;
+ unsigned long tx_bytes;
+ unsigned long rx_errors;
+ unsigned long tx_errors;
+ unsigned long rx_dropped;
+ unsigned long tx_dropped;
+ unsigned long multicast;
+ unsigned long collisions;
+ unsigned long rx_length_errors;
+ unsigned long rx_over_errors;
+ unsigned long rx_crc_errors;
+ unsigned long rx_frame_errors;
+ unsigned long rx_fifo_errors;
+ unsigned long rx_missed_errors;
+ unsigned long tx_aborted_errors;
+ unsigned long tx_carrier_errors;
+ unsigned long tx_fifo_errors;
+ unsigned long tx_heartbeat_errors;
+ unsigned long tx_window_errors;
+ unsigned long rx_compressed;
+ unsigned long tx_compressed;
+};
+# define IFA_DATA net_device_stats
+# define IFA_RX_BYTES rx_bytes
+# define IFA_TX_BYTES tx_bytes
+# define IFA_RX_PACKT rx_packets
+# define IFA_TX_PACKT tx_packets
+# define IFA_RX_ERROR rx_errors
+# define IFA_TX_ERROR tx_errors
#endif
struct IFA_DATA *if_data;

+ 0
- 21
utils/collectd/patches/150-fix-interface-af-link View File

@ -1,21 +0,0 @@
--- a/src/interface.c
+++ b/src/interface.c
@@ -244,8 +244,8 @@ struct net_device_stats {
for (if_ptr = if_list; if_ptr != NULL; if_ptr = if_ptr->ifa_next)
{
- if (if_ptr->ifa_addr != NULL && if_ptr->ifa_addr->sa_family == AF_LINK) {
- if_data = (struct IFA_DATA *) if_ptr->ifa_data;
+ if ((if_data = (struct IFA_DATA *) if_ptr->ifa_data) == NULL)
+ continue;
if_submit (if_ptr->ifa_name, "if_octets",
if_data->IFA_RX_BYTES,
@@ -256,7 +256,6 @@ struct net_device_stats {
if_submit (if_ptr->ifa_name, "if_errors",
if_data->IFA_RX_ERROR,
if_data->IFA_TX_ERROR);
- }
}
freeifaddrs (if_list);

Loading…
Cancel
Save