2008-12-04 17:24:28 +01:00
|
|
|
#!/bin/sh
|
|
|
|
# -*- sh -*-
|
|
|
|
#
|
|
|
|
# This plugin is based on the if_ plugin.
|
|
|
|
#
|
|
|
|
# Parameters
|
|
|
|
# None
|
|
|
|
#
|
|
|
|
# Magic markers (optional - used by munin-config and some installation
|
|
|
|
# scripts):
|
|
|
|
#
|
|
|
|
#%# family=manual
|
|
|
|
#%# capabilities=autoconf suggest
|
|
|
|
|
|
|
|
|
|
|
|
DEVICE=${0##*/tc_packets_}
|
|
|
|
|
|
|
|
mytc() {
|
2016-01-15 04:14:40 +01:00
|
|
|
tc -s class show dev $1 | tr "\n," "| " | sed "s/ \+/ /g" | sed "s/ |/|/g" | sed "s/| /|/g" | sed "s/||/\n/g" | sed "s/|/ /g" | tr ":" "_" | grep -v -i sfq | sort -n
|
2008-12-04 17:24:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
case $1 in
|
|
|
|
autoconf)
|
|
|
|
if [ -r /proc/net/dev ]; then
|
|
|
|
echo yes
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
echo "no (/proc/net/dev not found)"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
suggest)
|
|
|
|
if [ -r /proc/net/dev ]; then
|
|
|
|
awk '
|
|
|
|
/^ *(eth|tap|bond|wlan|ath|ra|sw)[0-9]+:/ {
|
|
|
|
split($0, a, /: */);
|
|
|
|
gsub(/^ +/,"",a[1]);
|
|
|
|
if (($2 > 0) || ($10 > 0)) print a[1]; }' /proc/net/dev
|
|
|
|
|
|
|
|
# egrep '^ *(eth|tap|bond|wlan|ath|ra|sw)[0-9]+:' /proc/net/dev | cut -f1 -d: | sed 's/ //g'
|
|
|
|
fi
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
config)
|
|
|
|
|
2016-01-15 05:59:15 +01:00
|
|
|
echo "graph_order `mytc $DEVICE | awk '{ print $2 "_" $3 "_packets" }' | tr "\n" " "`"
|
2008-12-04 17:24:28 +01:00
|
|
|
echo "graph_title $DEVICE TC traffic packets"
|
|
|
|
echo 'graph_args --base 1000'
|
2016-01-15 07:45:54 +01:00
|
|
|
echo 'graph_vlabel packets per ${graph_period}'
|
2008-12-04 17:24:28 +01:00
|
|
|
echo 'graph_category network'
|
|
|
|
echo "graph_info This graph shows the TC classes traffic packets of the $DEVICE network interface."
|
|
|
|
|
|
|
|
# mytc $DEVICE | tr "_" " " | awk '{ print $2 "_" $3 "_" $4 "_packets.label " $2 "/" $3 ":" $4 "\n" $2 "_" $3 "_" $4 "_packets.type COUNTER\n" $2 "_" $3 "_" $4 "_packets.min 0\n" $2 "_" $3 "_" $4 "_packets.cdef " $2 "_" $3 "_" $4 ",8,*" }'
|
2016-01-17 23:31:35 +01:00
|
|
|
mytc $DEVICE | tr "_" " " | awk '{ print $2 "_" $3 "_" $4 "_packets.label " $2 "/" $3 ":" $4 "\n" $2 "_" $3 "_" $4 "_packets.type DERIVE\n" $2 "_" $3 "_" $4 "_packets.min 0" }'
|
2008-12-04 17:24:28 +01:00
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# the root(s)
|
|
|
|
mytc $DEVICE | grep -v " parent " | awk "{ print \$2 \"_\" \$3 \"_packets.value \" \$16}"
|
|
|
|
|
|
|
|
# the child(s)
|
|
|
|
mytc $DEVICE | grep " parent " | awk "{ print \$2 \"_\" \$3 \"_packets.value \" \$21}"
|
|
|
|
|
|
|
|
exit 0
|