Skip to content

Commit

Permalink
Improve kstat compatibility in sunos if_ plugins
Browse files Browse the repository at this point in the history
A long time ago, I made the sunos if_ plugins do magic with kstat to only get
the right statistics.  In newer versions of Illumos, some of the pattern
matching magic no longer works (I suspect this is because kstat was converted
from perl script into binary).

This commit fixes the plugins to support the whole spectrum again by moving the
matching magic to awk.
  • Loading branch information
bldewolf committed May 20, 2014
1 parent f4cda9c commit f5100a6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions plugins/node.d.sunos/if_.in
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fi

if [ "$1" = "suggest" ]; then
if [ -x /usr/bin/kstat ]; then
kstat -p -m '/^(link)/' -s rbytes64 | awk -F: '{ print $3 }'
kstat -p -s rbytes64 | awk -F: '$3 != "mac" { print $3 }'
exit 0
else
exit 1
Expand Down Expand Up @@ -87,5 +87,5 @@ if [ "$1" = "config" ]; then
exit 0
fi;

kstat -p -m '/^(link)/' -n $INTERFACE -s '*bytes64' | sed \
kstat -p -n $INTERFACE -s '*bytes64' | sed \
's/.*\(.bytes\)64./\1.value /'
6 changes: 3 additions & 3 deletions plugins/node.d.sunos/if_err_.in
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fi

if [ "$1" = "suggest" ]; then
if [ -x /usr/bin/kstat ]; then
kstat -p -m '/^(?!unix)/' -n '/^(?!mac$)/' -s ierrors | awk -F: '{ print $3 }'
kstat -p -s ierrors | awk -F: '$1 != "unix" && $3 != "mac" { print $3 }'
exit 0
else
exit 1
Expand Down Expand Up @@ -88,8 +88,8 @@ if [ "$1" = "config" ]; then
exit 0
fi;

kstat -p -m '/^(?!unix)/' -n $INTERFACE -s '/^([io]errors|collisions)$/' | awk -F: '
{
kstat -p -n $INTERFACE -s '/^([io]errors|collisions)$/' | awk -F: '
$1 != "unix" {
split($4, four, "\t")
print four[1] ".value", four[2]
}'

0 comments on commit f5100a6

Please sign in to comment.