summaryrefslogtreecommitdiff
path: root/sysutils/munin-common/files/patch-plugins_node.d.freebsd_if__errcoll__.in
blob: 85ec6c6d0dce3063aabf0b4404bf86087fbdc28e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
--- plugins/node.d.freebsd/if_errcoll_.in.orig	2014-11-24 21:46:24 UTC
+++ plugins/node.d.freebsd/if_errcoll_.in
@@ -19,7 +19,7 @@
 INTERFACE=${0##*if_errcoll_}
 
 if [ "$1" = "autoconf" ]; then
-	if [ -x /usr/bin/netstat ]; then
+	if [ -x /sbin/ifconfig -o -x /usr/bin/netstat ]; then
 		echo yes
 		exit 0
 	else
@@ -29,8 +29,12 @@ if [ "$1" = "autoconf" ]; then
 fi
 
 if [ "$1" = "suggest" ]; then
-	if [ -x /usr/bin/netstat ]; then
-		netstat -i -b -n | sed -n -e '/^faith/d' -e '/^lo[0-9]/d' -e '/^pflog/d' -e '/<Link#[0-9]*>/s/\** .*//p'
+	if [ -x /sbin/ifconfig ]
+	then
+		ifconfig -l | sed -Ee 's/[[:<:]](pfsync|faith|pf(log|sync)|lo|plip|carp|enc|fwe)[^ ]*//g' | xargs -n 1 echo
+		exit 0
+	elif [ -x /usr/bin/netstat ]; then
+		netstat -i -b -n | sed -n -e '/^faith/d' -e '/^lo[0-9]/d' -e '/^pf(log|sync)/d' -e '/<Link#[0-9]*>/s/\** .*//p'
 		exit 0
 	else
 		exit 1
@@ -59,9 +63,19 @@ fi;
 		print "ierrors.value", $5;
 		print "oerrors.value", $8;
 		print "collisions.value", $10;
-	} else {
+	} else if (NF == 11) {
+		if ($4 ~ /:/) {
+			print "ierrors.value", $6;
+			print "oerrors.value", $9;
+			print "collisions.value", $11;
+		} else {
+			print "ierrors.value", $5;
+			print "oerrors.value", $9;
+			print "collisions.value", $11;
+		}
+	} else { # NF == 12
 		print "ierrors.value", $6;
-		print "oerrors.value", $9;
-		print "collisions.value", $11;
+		print "oerrors.value", $10;
+		print "collisions.value", $12;
 	}
 }'