Permalink
Browse files

initial commit of munin plugins for qwest modems

  • Loading branch information...
0 parents commit 54cee31316aa5069058d8170cd0098a8ef364cce @RyanAD committed Jul 31, 2011
Showing with 133 additions and 0 deletions.
  1. +28 −0 README.md
  2. +48 −0 dsl-connspeed
  3. +57 −0 dsl-stats
@@ -0,0 +1,28 @@
+This is a very early version of two munin plugins for Qwest DSL modems.
+
+Installing:
+
+* Download (clone repo) to get dsl-connspeed and dsl-stats
+* Run: `chmod a+x dsl-*`
+* Edit /etc/munin/plugin-conf.d/munin-node and add the following:
+```
+[dsl-connspeed]
+env.DSLMODEMIP 192.168.0.1
+env.DSLUSER admin
+env.DSLPASS admin
+
+[dsl-stats]
+env.DSLMODEMIP 192.168.0.1
+env.DSLUSER admin
+env.DSLPASS admin
+```
+DSLUSER and DSLPASS are optional.
+
+* Now restart munin-node `service munin-node restart`
+
+You can test the setup by running `munin-run dsl-connspeed` and `munin-run dsl-stats`
+I have only tested this with my Q1000 modem, let me know if it works for yours! I think it should work if your modem WAN status page looks similar to this:
+
+![Qwest WAN Status Page](http://www.mandrake.us/qwest-wan-status2.jpg)
+
+
@@ -0,0 +1,48 @@
+#!/bin/bash
+
+case $1 in
+ config)
+ cat <<'EOM'
+graph_order downspeed upspeed
+graph_title DSL Connection Speed
+graph_args --base 1000 -l 1000 --upper-limit 42000
+graph_category Network
+graph_scale no
+graph_vlabel DSL up / down speed
+downspeed.label Down speed
+downspeed.type GAUGE
+upspeed.label Up speed
+upspeed.type GAUGE
+graph_info Graph of DSL Connection Speed
+EOM
+ exit 0;;
+esac
+
+# verify we have the IP for the modem
+if [[ "$DSLMODEMIP" == "" ]]
+then
+ echo "DSLMODEMIP variable must be set!"
+ exit 1
+fi
+
+# create temp file for storing wget output
+TMPFILE=$(mktemp)
+
+# if we have auth variables then add them to
+# wget cmdline
+if [[ "$DSLUSER" != "" && "$DSLPASS" != "" ]]
+then
+ AUTH_OPT="--user=$DSLUSER --password='$DSLPASS' "
+fi
+
+# get wan stats page and store it to temp file
+wget $AUTH_OPT --tries=1 --timeout=10 -q -O $TMPFILE http://$DSLMODEMIP/modemstatus_wanstatus.html
+# parse tempfile to get connection speeds
+DOWNRATE=$(cat $TMPFILE | grep downrate= | sed -e "s/var.*downrate='\(.*\)';.*/\1/g" | sed -e 's/\s//g' | tail -n 1)
+UPRATE=$(cat $TMPFILE | grep uprate= | sed -e "s/var.*uprate='\(.*\)';.*/\1/g" | sed -e 's/\s//g' | tail -n 1)
+# done with the temp file, remove
+rm $TMPFILE
+
+# done, output speeds
+echo "upspeed.value $UPRATE"
+echo "downspeed.value $DOWNRATE"
@@ -0,0 +1,57 @@
+#!/bin/bash
+
+case $1 in
+ config)
+ cat <<'EOM'
+graph_order snrdown snrup pwrdown pwrup
+graph_title dsl stats
+graph_args --base 1000
+graph_category Network
+graph_scale no
+graph_vlabel DSL SNR and Power
+attndown.label Down Attenuation
+attndown.type GAUGE
+attnup.label Up Attenuation
+attnup.type GAUGE
+snrdown.label Down SNR
+snrdown.type GAUGE
+snrup.label Up SNR
+snrup.type GAUGE
+pwrup.label Up Power
+pwrup.type GAUGE
+pwrdown.label Down Power
+pwrdown.type GAUGE
+pwrdown.cdef pwrdown,10,/
+pwrup.cdef pwrup,10,/
+graph_info Graph of DSL Connection Stats
+EOM
+ exit 0;;
+esac
+
+
+# verify we have the IP for the modem
+if [[ "$DSLMODEMIP" == "" ]]
+then
+ echo "DSLMODEMIP variable must be set!"
+ exit 1
+fi
+
+
+# create temp file for storing wget output
+TMPFILE=$(mktemp)
+
+
+# if we have auth variables then add them to
+# wget cmdline
+if [[ "$DSLUSER" != "" && "$DSLPASS" != "" ]]
+then
+ AUTH_OPT="--user=$DSLUSER --password='$DSLPASS' "
+fi
+
+# get wan stats page and store it to temp file
+wget $AUTH_OPT --tries=1 --timeout=10 -q -O $TMPFILE http://$DSLMODEMIP/modemstatus_wanstatus.html
+# parse the javascript on the page to get the info we need and print it
+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}'
+
+#remove temp file
+rm $TMPFILE

0 comments on commit 54cee31

Please sign in to comment.