PDA

View Full Version : Graphing power levels


phoenix__
07-08-2009, 14:30
Does anyone know any easy way to graph the power levels from a cable modem? I can throw values into MRTG easily enough, but I don't know any way to pull the values out of the cable modem short of trying to 'screen scrape'. Does anyone know if they support SNMP, or if there are already scripts out there to do it?

I've had a look at the docsdiag stuff http://homepage.ntlworld.com/robin.d.h.walker/docsdiag/, but this doesn't seem to work for my modem.

Milambar
07-08-2009, 14:52
Theres probably a simpler way, but I use:

wget -q http://root:root@192.168.100.1/CmDnstream.asp -O - | grep "Power Level" | awk '{ print $10 $11; }' | sed -e 's/<[^>][^>]*>//g' -e '/^ *$/d'


I know its not quite what you wanted, and it IS a form of screenscraping, and in case anyone wonders what it does...

wget -q -O -
This calls the wget command with options -q for quiet and -O - to redirect the output to STDIO

The url http://root:root@ means connect to 192.168.100.1/CmDnstream.asp with the credentials of root for the username and root for the password.

| grep "Power Level" pushes the output of the previous command through a regular expression parser, and returns all lines with the words "Power Level" in them.

| awk '{print $9 $10;}' pushes the output of the grep through the awk command which splits the line on word boundaries, and prints the 9th and 10th tokens.

The | sed command then removes all html tags, and prints the final result to stdio. The final result is the power level in the form of xx.xxdBmV.

You can then take this output and throw it into any process you wish. Graphing, databasing...

Can't do this in windows that I know of. Aint Linux great?

Zhadnost
07-08-2009, 15:44
Are you sure, wget, sed, grep and awk can all run in cygwin.

Sadly I can't see anything in the VM300 version of CmDnstream.asp that makes that particular line distinct enough to make an equivalent.

phoenix__
07-08-2009, 15:59
Thanks Milambar, my main reason for not wanting to do screen scraping is because I really CBA to figure out how to do it - but as you've done all the hard bits ;)

A couple of changes to the grep and awk lines can pull the others values off too.

MRTG here I come.

AbyssUnderground
07-08-2009, 19:36
RouterStats... http://www.vwlowen.co.uk/internet/files.htm

My friend wrote this software and it works great.

davidb24v
08-08-2009, 10:53
Hadn't thought of monitoring any of this (until now :D)

Here's a simple Tcl script that appends Power Level and RxMER to files in the current directory:

#!/usr/bin/tclsh

package require http

proc main { } {
# Download modem status page
set s [http::data [http::geturl http://192.168.100.1/CmDnstream.asp]]

# remove all HTML tags (replace with space)
regsub -all {<([^<])*>} $s { } s

# Jump to the bits we want
strip s "Power Level (dBmV)"
set PowerLevels [lrange $s 0 3]

strip s "RxMER (dB)"
set RxMERs [lrange $s 0 3]

# timestamp
set TS [clock seconds]

# append data to logs
set f [open "PowerLevel" a]
puts $f "$TS $PowerLevels"
close $f

set f [open "RxMER" a]
puts $f "$TS $RxMERs"
close $f
}

proc strip { s txt } {
# find substring, remove it and all preceeding text
upvar $s S
set pos [string first "$txt" "$S"]
if { $pos < 0 } {
error "Couldn't find $txt in $S"
}
incr pos [string length $txt]
set S [string trimleft [string range $S $pos end]]
}

main


It'll run on anything that you can put Tcl on (so pretty much anything then). I'm running it every minute (using cron on my Ubuntu box) - perhaps I should Google to find out what an RxMER is :rolleyes:

Enjoy.

Dave