Projet

Général

Profil

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

root / plugins / network / tc_packets_ @ dd4afac8

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

1 d216ea55 Costa Tsaousis
#!/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_packets_}
17
18
mytc() {
19
	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
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
		       
46
	echo "graph_order `mytc $DEVICE | awk '{ print $2 "_" $3 "_packets" }' | sort -n | tr "\n" " "`"
47
	echo "graph_title $DEVICE TC traffic packets"
48
        echo 'graph_args --base 1000'
49
        echo 'graph_vlabel bits per ${graph_period}'
50
	echo 'graph_category network'
51
	echo "graph_info This graph shows the TC classes traffic packets of the $DEVICE network interface."
52
	
53
#	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,*" }'
54
	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" }'
55
        exit 0
56
	;;
57
esac
58
59
# the root(s)
60
mytc $DEVICE | grep -v " parent " | awk "{ print \$2 \"_\" \$3 \"_packets.value \" \$16}"
61
62
# the child(s)
63
mytc $DEVICE | grep " parent " | awk "{ print \$2 \"_\" \$3 \"_packets.value \" \$21}"
64
65
exit 0