Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / network / tc_ @ afe87e90

Historique | Voir | Annoter | Télécharger (1,76 ko)

1
#!/bin/sh
2
# -*- sh -*-
3
#
4
# This plugin is based on the if_ plugin.
5
#
6
# Parameters
7
#     None
8
#
9
# Magic markers (optional - used by munin-config and some installation
10
# scripts):
11
#
12
#%# family=manual
13
#%# capabilities=autoconf suggest
14

    
15

    
16
DEVICE=${0##*/tc_}
17

    
18
mytc() {
19
	/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
20
}
21

    
22
case $1 in
23
    autoconf)
24
	if [ -r /proc/net/dev ]; then
25
	    echo yes
26
	    exit 0
27
	else
28
	    echo "no (/proc/net/dev not found)"
29
	    exit 1
30
	fi
31
	;;
32
    suggest)
33
	if [ -r /proc/net/dev ]; then
34
	    awk '
35
                /^ *(eth|tap|bond|wlan|ath|ra|sw)[0-9]+:/ {
36
                   split($0, a, /: */);
37
                   gsub(/^ +/,"",a[1]);
38
                   if (($2 > 0) || ($10 > 0)) print a[1]; }' /proc/net/dev
39

    
40
#	    egrep '^ *(eth|tap|bond|wlan|ath|ra|sw)[0-9]+:' /proc/net/dev | cut -f1 -d: | sed 's/ //g'
41
	fi
42
	exit 0
43
	;;
44
    config)
45
	echo "graph_order `mytc $DEVICE | awk '{ print $2 "_" $3 }' | tr "\n" " "`"
46
	echo "graph_title $DEVICE TC traffic"
47
	echo 'graph_args --base 1000'
48
	echo 'graph_vlabel bits per ${graph_period}'
49
	echo 'graph_category network'
50
	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."
51
	
52
	mytc $DEVICE | tr "_" " " | awk '{ print $2 "_" $3 "_" $4 ".label " $2 "/" $3 ":" $4 "\n" $2 "_" $3 "_" $4 ".type DERIVE\n" $2 "_" $3 "_" $4 ".min 0\n" $2 "_" $3 "_" $4 ".cdef " $2 "_" $3 "_" $4 ",8,*" }'
53
        exit 0
54
	;;
55
esac
56

    
57
# the root(s)
58
mytc $DEVICE | grep -v " parent " | awk "{ print \$2 \"_\" \$3 \".value \" \$14}"
59

    
60
# the child(s)
61
mytc $DEVICE | grep " parent " | awk "{ print \$2 \"_\" \$3 \".value \" \$19}"
62

    
63
exit 0