瀏覽代碼

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=a05e34a0d4
http://git.verplant.org/?p=collectd.git;a=commit;h=14740db4b4
http://git.verplant.org/?p=collectd.git;a=commitdiff;h=645dadb3fc

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>
Hannu Nyman 9 年之前
父節點
當前提交
d91cd622c0

+ 1
- 2
utils/collectd/Makefile 查看文件

@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
9 9
 
10 10
 PKG_NAME:=collectd
11 11
 PKG_VERSION:=5.5.0
12
-PKG_RELEASE:=1
12
+PKG_RELEASE:=2
13 13
 
14 14
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
15 15
 PKG_SOURCE_URL:=http://collectd.org/files/
@@ -184,7 +184,6 @@ endif
184 184
 CONFIGURE_ARGS+= \
185 185
 	--disable-debug \
186 186
 	--enable-daemon \
187
-	--enable-getifaddrs \
188 187
 	--with-nan-emulation \
189 188
 	--without-libgcrypt
190 189
 

+ 0
- 46
utils/collectd/patches/110-net-device-stats.patch 查看文件

@@ -1,46 +0,0 @@
1
----
2
- src/interface.c |   33 ++++++++++++++++++++++++++++++++-
3
- 1 file changed, 32 insertions(+), 1 deletion(-)
4
-
5
---- a/src/interface.c
6
-+++ b/src/interface.c
7
-@@ -203,7 +203,38 @@ static int interface_read (void)
8
- #  define IFA_RX_ERROR rx_errors
9
- #  define IFA_TX_ERROR tx_errors
10
- #else
11
--#  error "No suitable type for `struct ifaddrs->ifa_data' found."
12
-+struct net_device_stats {
13
-+	unsigned long	rx_packets;
14
-+	unsigned long	tx_packets;
15
-+	unsigned long	rx_bytes;
16
-+	unsigned long	tx_bytes;
17
-+	unsigned long	rx_errors;
18
-+	unsigned long	tx_errors;
19
-+	unsigned long	rx_dropped;
20
-+	unsigned long	tx_dropped;
21
-+	unsigned long	multicast;
22
-+	unsigned long	collisions;
23
-+	unsigned long	rx_length_errors;
24
-+	unsigned long	rx_over_errors;
25
-+	unsigned long	rx_crc_errors;
26
-+	unsigned long	rx_frame_errors;
27
-+	unsigned long	rx_fifo_errors;
28
-+	unsigned long	rx_missed_errors;
29
-+	unsigned long	tx_aborted_errors;
30
-+	unsigned long	tx_carrier_errors;
31
-+	unsigned long	tx_fifo_errors;
32
-+	unsigned long	tx_heartbeat_errors;
33
-+	unsigned long	tx_window_errors;
34
-+	unsigned long	rx_compressed;
35
-+	unsigned long	tx_compressed;
36
-+};
37
-+#  define IFA_DATA net_device_stats
38
-+#  define IFA_RX_BYTES rx_bytes
39
-+#  define IFA_TX_BYTES tx_bytes
40
-+#  define IFA_RX_PACKT rx_packets
41
-+#  define IFA_TX_PACKT tx_packets
42
-+#  define IFA_RX_ERROR rx_errors
43
-+#  define IFA_TX_ERROR tx_errors
44
- #endif
45
- 
46
- 	struct IFA_DATA *if_data;

+ 0
- 21
utils/collectd/patches/150-fix-interface-af-link 查看文件

@@ -1,21 +0,0 @@
1
---- a/src/interface.c
2
-+++ b/src/interface.c
3
-@@ -244,8 +244,8 @@ struct net_device_stats {
4
- 
5
- 	for (if_ptr = if_list; if_ptr != NULL; if_ptr = if_ptr->ifa_next)
6
- 	{
7
--		if (if_ptr->ifa_addr != NULL && if_ptr->ifa_addr->sa_family == AF_LINK) {
8
--			if_data = (struct IFA_DATA *) if_ptr->ifa_data;
9
-+		if ((if_data = (struct IFA_DATA *) if_ptr->ifa_data) == NULL)
10
-+			continue;
11
- 
12
- 			if_submit (if_ptr->ifa_name, "if_octets",
13
- 				if_data->IFA_RX_BYTES,
14
-@@ -256,7 +256,6 @@ struct net_device_stats {
15
- 			if_submit (if_ptr->ifa_name, "if_errors",
16
- 				if_data->IFA_RX_ERROR,
17
- 				if_data->IFA_TX_ERROR);
18
--		}
19
- 	}
20
- 
21
- 	freeifaddrs (if_list);