--- 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 '//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 '//s/\** .*//p' exit 0 else exit 1 @@ -68,8 +72,14 @@ BEGIN { rsum = 0; osum = 0; } // { 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 +