Projet

Général

Profil

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

root / plugins / network / tc_drops_ @ 6995742e

Historique | Voir | Annoter | Télécharger (1,94 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 "no (/proc/net/dev not found)"
26
	elif ! which tc >/dev/null; then
27
	    echo "no (missing 'tc' executable)"
28
	else
29
	    echo yes
30
	fi
31
	exit 0
32
	;;
33
    suggest)
34
	if [ -r /proc/net/dev ]; then
35
	    awk '
36
                /^ *(eth|tap|bond|wlan|ath|ra|sw|eno|ens|enp|wlp|wl)[0-9]*/ {
37
                   split($0, a, /: */);
38
                   gsub(/^ +/,"",a[1]);
39
                   if (($2 > 0) || ($10 > 0)) print a[1]; }' /proc/net/dev
40
	fi
41
	exit 0
42
	;;
43
    config)
44

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

    
52
#	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,*" }'
53
	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" }'
54
        exit 0
55
	;;
56
esac
57

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

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

    
64
exit 0