Projet

Général

Profil

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

root / plugins / router / dsl-connection-speed @ 7cf2dda9

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

1 ea1e9c73 Icedrake
#!/bin/bash
2
3
case $1 in
4
   config)
5
        cat <<'EOM'
6
graph_order downspeed upspeed
7
graph_title DSL Connection Speed
8
graph_args --base 1000 -l 1000 --upper-limit 42000
9 e10e386b dipohl
graph_category network
10 ea1e9c73 Icedrake
graph_scale no
11
graph_vlabel DSL up / down speed
12
downspeed.label Down speed
13
downspeed.type GAUGE
14
upspeed.label Up speed
15
upspeed.type GAUGE
16
graph_info Graph of DSL Connection Speed
17
EOM
18
        exit 0;;
19
esac
20
21
# verify we have the IP for the modem
22
if [[ "$DSLMODEMIP" == "" ]]
23
then
24
	echo "DSLMODEMIP variable must be set!"
25
	exit 1
26
fi
27
28
# create temp file for storing wget output
29
TMPFILE=$(mktemp)
30
31 17f78427 Lars Kruse
# if we have auth variables then add them to
32 ea1e9c73 Icedrake
# wget cmdline
33
if [[ "$DSLUSER" != ""  && "$DSLPASS" != "" ]]
34
then
35
	AUTH_OPT="--user=$DSLUSER --password='$DSLPASS' "
36
fi
37
38
# get wan stats page and store it to temp file
39
wget $AUTH_OPT --tries=1 --timeout=10 -q -O $TMPFILE http://$DSLMODEMIP/modemstatus_wanstatus.html
40
# parse tempfile to get connection speeds
41
DOWNRATE=$(cat $TMPFILE | grep downrate= | sed -e "s/var.*downrate='\(.*\)';.*/\1/g" | sed -e 's/\s//g' | tail -n 1)
42
UPRATE=$(cat $TMPFILE | grep uprate= | sed -e "s/var.*uprate='\(.*\)';.*/\1/g" | sed -e 's/\s//g' | tail -n 1)
43
# done with the temp file, remove
44
rm $TMPFILE
45
46
# done, output speeds
47
echo "upspeed.value $UPRATE"
48
echo "downspeed.value $DOWNRATE"