Projet

Général

Profil

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

root / plugins / network / tc_drops_ @ f3347821

Historique | Voir | Annoter | Télécharger (1,88 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_drops_}
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 ":" "_" | 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|eno|ens|enp|wlp|wl)[0-9]*/ {
36
                   split($0, a, /: */);
37
                   gsub(/^ +/,"",a[1]);
38
                   if (($2 > 0) || ($10 > 0)) print a[1]; }' /proc/net/dev
39
	fi
40
	exit 0
41
	;;
42
    config)
43

    
44
	echo "graph_order `mytc $DEVICE | awk '{ print $2 "_" $3 "_drops" }' | tr "\n" " "`"
45
	echo "graph_title $DEVICE TC traffic drops"
46
        echo 'graph_args --base 1000'
47
        echo 'graph_vlabel drops per ${graph_period}'
48
	echo 'graph_category network'
49
	echo "graph_info This graph shows the TC classes traffic drops of the $DEVICE network interface, epxressed in packets."
50

    
51
#	mytc $DEVICE | tr "_" " " | awk '{ print $2 "_" $3 "_" $4 "_drops.label " $2 "/" $3 ":" $4 "\n" $2 "_" $3 "_" $4 "_drops.type COUNTER\n" $2 "_" $3 "_" $4 "_drops.min 0\n" $2 "_" $3 "_" $4 "_drops.cdef " $2 "_" $3 "_" $4 ",8,*" }'
52
	mytc $DEVICE | tr "_" " " | awk '{ print $2 "_" $3 "_" $4 "_drops.label " $2 "/" $3 ":" $4 "\n" $2 "_" $3 "_" $4 "_drops.type DERIVE\n" $2 "_" $3 "_" $4 "_drops.min 0" }'
53
        exit 0
54
	;;
55
esac
56

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

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

    
63
exit 0