Projet

Général

Profil

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

root / plugins / router / dsl-stats @ 7cf2dda9

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

1 45d9fa12 Icedrake
#!/bin/bash
2
3
case $1 in
4
   config)
5
        cat <<'EOM'
6
graph_order snrdown snrup pwrdown pwrup
7
graph_title dsl stats
8
graph_args --base 1000
9 e10e386b dipohl
graph_category network
10 45d9fa12 Icedrake
graph_scale no
11
graph_vlabel DSL SNR and Power
12
attndown.label Down Attenuation
13
attndown.type GAUGE
14
attnup.label Up Attenuation
15
attnup.type GAUGE
16
snrdown.label Down SNR
17
snrdown.type GAUGE
18
snrup.label Up SNR
19
snrup.type GAUGE
20
pwrup.label Up Power
21
pwrup.type GAUGE
22
pwrdown.label Down Power
23
pwrdown.type GAUGE
24
pwrdown.cdef pwrdown,10,/
25
pwrup.cdef pwrup,10,/
26
graph_info Graph of DSL Connection Stats
27
EOM
28
        exit 0;;
29
esac
30
31
32
# verify we have the IP for the modem
33
if [[ "$DSLMODEMIP" == "" ]]
34
then
35
	echo "DSLMODEMIP variable must be set!"
36
	exit 1
37
fi
38
39
40
# create temp file for storing wget output
41
TMPFILE=$(mktemp)
42
43
44 17f78427 Lars Kruse
# if we have auth variables then add them to
45 45d9fa12 Icedrake
# wget cmdline
46
if [[ "$DSLUSER" != ""  && "$DSLPASS" != "" ]]
47
then
48
	AUTH_OPT="--user=$DSLUSER --password='$DSLPASS' "
49
fi
50
51
# get wan stats page and store it to temp file
52
wget $AUTH_OPT --tries=1 --timeout=10 -q -O $TMPFILE http://$DSLMODEMIP/modemstatus_wanstatus.html
53
# parse the javascript on the page to get the info we need and print it
54
cat $TMPFILE | grep  'dslstatus = '| sed -e "s/['; ]//g" | head -n 1 | awk -F '[|/]' '{print "snrdown.value "$5"\nsnrup.value "$6"\nattndown.value "$7"\nattnup.value "$8"\npwrup.value "$29"\npwrdown.value "$30}'
55
56
#remove temp file
57
rm $TMPFILE