1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-25 02:18:08 +00:00

Cleanup suggested by maintainer

* family should be auto, not manual
* Combine multiple sed scripts into a single script
* Double quote sh variable dereferences
* Don't use deprecated backquotes
This commit is contained in:
Nye Liu 2016-11-05 14:52:03 -07:00
parent 2d13d2a50d
commit 6cb9ba170f

View file

@ -9,17 +9,17 @@
# Magic markers (optional - used by munin-config and some installation
# scripts):
#
#%# family=manual
#%# family=auto
#%# capabilities=autoconf suggest
DEVICE=${0##*/tc_}
mytc() {
/sbin/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
/sbin/tc -s class show dev "$1" | tr "\n" "|" | sed -e "s/ \+/ /g; s/ |/|/g; s/| /|/g; s/||/\n/g; s/|/ /g" | tr ":" "_" | grep -v -i sfq | sort -n
}
case $1 in
case "$1" in
autoconf)
if [ -r /proc/net/dev ]; then
echo yes
@ -36,13 +36,11 @@ case $1 in
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)
echo "graph_order `mytc $DEVICE | awk '{ print $2 "_" $3 }' | tr "\n" " "`"
echo "graph_order $(mytc "$DEVICE" | awk '{ print $2 "_" $3 }' | tr "\n" " ")"
echo "graph_title $DEVICE TC traffic"
echo 'graph_args --base 1000'
echo 'graph_vlabel bits per ${graph_period}'
@ -50,7 +48,7 @@ case $1 in
echo "graph_info This graph shows the TC classes traffic of the $DEVICE network interface. Please note that the traffic is shown in bits per second, not bytes."
# the root(s)
mytc $DEVICE | grep -v " parent " | tr "_" " " | awk '{
mytc "$DEVICE" | grep -v " parent " | tr "_" " " | awk '{
print $2 "_" $3 "_" $4 ".label " $2 "/" $3 ":" $4;
print $2 "_" $3 "_" $4 ".type DERIVE";
print $2 "_" $3 "_" $4 ".min 0";
@ -58,7 +56,7 @@ case $1 in
}'
# TODO: only AREASTACK things with no children
# the child(s)
mytc $DEVICE | grep " parent " | tr "_" " " | awk '{
mytc "$DEVICE" | grep " parent " | tr "_" " " | awk '{
print $2 "_" $3 "_" $4 ".label " $2 "/" $3 ":" $4;
print $2 "_" $3 "_" $4 ".type DERIVE";
print $2 "_" $3 "_" $4 ".min 0";
@ -70,13 +68,13 @@ case $1 in
esac
# the root(s)
mytc $DEVICE | grep -v " parent " | awk '{
mytc "$DEVICE" | grep -v " parent " | awk '{
split(substr($0, match($0, /[0-9]+ [Bb]ytes/)), a, " ");
print $2 "_" $3 ".value " a[1];
}'
# the child(s)
mytc $DEVICE | grep " parent " | awk '{
mytc "$DEVICE" | grep " parent " | awk '{
split(substr($0, match($0, /[0-9]+ [Bb]ytes/)), a, " ");
print $2 "_" $3 ".value " a[1];
}'