Projet

Général

Profil

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

root / plugins / network / mtr100_ @ 1bed50bb

Historique | Voir | Annoter | Télécharger (2,25 ko)

1 60728f04 Kenyon Ralph
#!/bin/sh
2
#
3
# Plugin plotting the Percentage of time needed to reach each host on the way to a certain host
4
# Uses MTR http://www.bitwizard.nl/mtr/ to do the job
5
#
6
# Version: 1.0
7
# Author: tobias.geiger@vido.info
8 dc129c54 Lee Clemens
# Please email me bugs/suggestions
9 60728f04 Kenyon Ralph
#
10 acc4135c Charlie Allom
# Version: 1.1
11
# Author: charlie@evilforbeginners.com
12
# changed: munin eats 1 character ds-names. prefix with "hop_"
13 60728f04 Kenyon Ralph
#
14
#
15
# HINT: Needs a bigger TIMEOUT-Value than the default (10) in /etc/munin/plugin-conf.d/munin-node ,
16
# e.g.:
17
#  [mtr100_*]
18
#  timeout 60
19
#
20
#
21
#
22
# Parameters:
23
#
24 d9cce216 Lee Clemens
#     config   (required)
25
#     autoconf (optional - only used by munin-config)
26 60728f04 Kenyon Ralph
#
27
# Magic markers (optional - used by munin-config and some installation
28
# scripts):
29
#%# family=contrib
30
#%# capabilities=autoconf
31
32
totrace=`basename $0 | sed 's/^mtr100_//g'`
33
34
if [ "$1" = "autoconf" ]; then
35 d9cce216 Lee Clemens
    if ( mtr -nrc 1 localhost 2>/dev/null >/dev/null ); then
36
        echo yes
37
        exit 0
38
    else
39
        if [ $? -eq 127 ]
40
        then
41
            echo "no (mtr program not found - install the mtr(-tiny) package)"
42
            exit 1
43
        else
44
            echo no
45
            exit 1
46
        fi
47
    fi
48 60728f04 Kenyon Ralph
exit 0
49
fi
50
51
dotrace() {
52
53 b3a486fa Lee Clemens
LC_ALL=C mtr -nrs 1024 -c 5 $totrace | grep -vi -E "^HOST:|^Start:" | LC_ALL=C  awk -v C=$1 -v SRC_HOSTNAME=$(hostname) ' {
54 60728f04 Kenyon Ralph
55
label=$2
56
x=gsub("\\.","_",label)
57
58
count=NR
59
lab[count]=count
60
name[count]=$2
61
val[count]=$6
62
total+=$6
63
}
64
65
END {
66 caa2f4be Lee Clemens
    # Hard code the first hop (hop_0) as the local hostname
67 d9cce216 Lee Clemens
    if ( C != "config" ) { print "hop_0.value U" }
68
    if ( C == "config" ) { print "hop_0.label " SRC_HOSTNAME }
69
    if ( C == "config" ) { print "hop_0.draw AREA" }
70
    for (x=1; x<=count; x++) {
71
        value=(val[x]/total)*100
72
        if ( C != "config" ) { printf "%s.value %2.2f\n","hop_" lab[x],value }
73
        if ( C == "config" ) { print "hop_" lab[x] ".label " name[x] }
74
        if ( C == "config" ) { print "hop_" lab[x]".draw STACK" }
75
    }
76 60728f04 Kenyon Ralph
}'
77
}
78
79
if [ "$1" = "config" ]; then
80 d9cce216 Lee Clemens
    echo 'graph_title Traceroute (%) to '$totrace
81
    echo 'graph_args --base 1000 -l 0 -u 100 -r'
82
    echo 'graph_vlabel ms (percentage)'
83
    echo 'graph_category network'
84
    echo 'graph_scale no'
85
    echo 'graph_period second'
86
    echo 'graph_info This graph shows the Percentage needed for each hop on the way to '$totrace
87
    dotrace config;
88
    exit 0
89 60728f04 Kenyon Ralph
else
90 d9cce216 Lee Clemens
    dotrace;
91 60728f04 Kenyon Ralph
fi