ports/sysutils/munin-common/files/patch-plugins_node.d.freebsd_if__.in
Mathieu Arnold 2ff6de7ee9 Fix the bind9_rndc plugin wrt Perl 5.18+ hash randomzation.
While there, group all patches for the three ports in munin-common, and remove
an obsolete patch.

PR:		195689
Submitted by:	Vlad "Blackflow" K.
Sponsored by:	Absolight
2014-12-10 15:52:14 +00:00

65 lines
1.6 KiB
Text

--- plugins/node.d.freebsd/if_.in.orig 2014-11-24 21:46:24 UTC
+++ plugins/node.d.freebsd/if_.in
@@ -22,7 +22,7 @@
INTERFACE=${0##*if_}
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
@@ -32,8 +32,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
@@ -68,8 +72,14 @@ BEGIN { rsum = 0; osum = 0; }
/<Link#[0-9]*>/ {
if (NF == 10) {
rsum += $6; osum += $9;
- } else {
- rsum += $7; osum += $10;
+ } else if (NF == 11) {
+ if ($4 ~ /:/) {
+ rsum += $7; osum += $10;
+ } else {
+ rsum += $7; osum += $10;
+ }
+ } else { # NF == 12
+ rsum += $8; osum += $11;
}
}
END {
@@ -83,9 +93,18 @@ else
if (NF == 10) {
print "rbytes.value", $6;
print "obytes.value", $9;
- } else {
- print "rbytes.value", $7;
- print "obytes.value", $10;
+ } else if (NF == 11) {
+ if ($4 ~ /:/) {
+ print "rbytes.value", $7;
+ print "obytes.value", $10;
+ } else {
+ print "rbytes.value", $7;
+ print "obytes.value", $10;
+ }
+ } else { # NF == 12
+ print "rbytes.value", $8;
+ print "obytes.value", $11;
}
}'
fi
+