From 16655964a9029f67f1b6d522d048d90131d8e6c8 Mon Sep 17 00:00:00 2001 From: Costa Tsaousis Date: Thu, 4 Dec 2008 17:22:14 +0100 Subject: [PATCH] Initial version --- plugins/other/tc_ | 64 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100755 plugins/other/tc_ diff --git a/plugins/other/tc_ b/plugins/other/tc_ new file mode 100755 index 00000000..1418222d --- /dev/null +++ b/plugins/other/tc_ @@ -0,0 +1,64 @@ +#!/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_} + +mytc() { + 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 ":" "_" | sort -n +} + +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) + + echo "graph_order `mytc $DEVICE | awk '{ print $2 "_" $3 }' | sort -n | tr "\n" " "`" + echo "graph_title $DEVICE TC traffic" + echo 'graph_args --base 1000' + echo 'graph_vlabel bits per ${graph_period}' + echo 'graph_category network' + 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." + + mytc $DEVICE | tr "_" " " | awk '{ print $2 "_" $3 "_" $4 ".label " $2 "/" $3 ":" $4 "\n" $2 "_" $3 "_" $4 ".type COUNTER\n" $2 "_" $3 "_" $4 ".min 0\n" $2 "_" $3 "_" $4 ".cdef " $2 "_" $3 "_" $4 ",8,*" }' + exit 0 + ;; +esac + +# the root(s) +mytc $DEVICE | grep -v " parent " | awk "{ print \$2 \"_\" \$3 \".value \" \$14}" + +# the child(s) +mytc $DEVICE | grep " parent " | awk "{ print \$2 \"_\" \$3 \".value \" \$19}" + +exit 0