root / plugins / network / tc_packets_ @ 92483a04
Historique | Voir | Annoter | Télécharger (1,94 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 | 381101d2 | Samuel Smith | 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 | d216ea55 | Costa Tsaousis | } |
| 21 | |||
| 22 | case $1 in |
||
| 23 | autoconf) |
||
| 24 | 6995742e | Lars Kruse | if [ ! -r /proc/net/dev ]; then |
| 25 | d216ea55 | Costa Tsaousis | echo "no (/proc/net/dev not found)" |
| 26 | 6995742e | Lars Kruse | elif ! which tc >/dev/null; then |
| 27 | echo "no (missing 'tc' executable)" |
||
| 28 | else |
||
| 29 | echo yes |
||
| 30 | d216ea55 | Costa Tsaousis | fi |
| 31 | e4cd049b | Lars Kruse | exit 0 |
| 32 | d216ea55 | Costa Tsaousis | ;; |
| 33 | suggest) |
||
| 34 | if [ -r /proc/net/dev ]; then |
||
| 35 | awk ' |
||
| 36 | f3347821 | RubenKelevra | /^ *(eth|tap|bond|wlan|ath|ra|sw|eno|ens|enp|wlp|wl)[0-9]*/ {
|
| 37 | d216ea55 | Costa Tsaousis | 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 | 17f78427 | Lars Kruse | |
| 45 | 74aa84d5 | Samuel Smith | echo "graph_order `mytc $DEVICE | awk '{ print $2 "_" $3 "_packets" }' | tr "\n" " "`"
|
| 46 | d216ea55 | Costa Tsaousis | echo "graph_title $DEVICE TC traffic packets" |
| 47 | echo 'graph_args --base 1000' |
||
| 48 | b47505ce | Samuel Smith | echo 'graph_vlabel packets per ${graph_period}'
|
| 49 | d216ea55 | Costa Tsaousis | echo 'graph_category network' |
| 50 | echo "graph_info This graph shows the TC classes traffic packets of the $DEVICE network interface." |
||
| 51 | 17f78427 | Lars Kruse | |
| 52 | d216ea55 | Costa Tsaousis | # 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,*" }'
|
| 53 | 6b94ef02 | Samuel Smith | mytc $DEVICE | tr "_" " " | awk '{ print $2 "_" $3 "_" $4 "_packets.label " $2 "/" $3 ":" $4 "\n" $2 "_" $3 "_" $4 "_packets.type DERIVE\n" $2 "_" $3 "_" $4 "_packets.min 0" }'
|
| 54 | d216ea55 | Costa Tsaousis | exit 0 |
| 55 | ;; |
||
| 56 | esac |
||
| 57 | |||
| 58 | # the root(s) |
||
| 59 | mytc $DEVICE | grep -v " parent " | awk "{ print \$2 \"_\" \$3 \"_packets.value \" \$16}"
|
||
| 60 | |||
| 61 | # the child(s) |
||
| 62 | mytc $DEVICE | grep " parent " | awk "{ print \$2 \"_\" \$3 \"_packets.value \" \$21}"
|
||
| 63 | |||
| 64 | exit 0 |
