[colug-432] talking to your ISP
Bill Baker
bill_chris at earthlink.net
Sat Dec 29 15:42:59 EST 2012
I did have to modify the script because my modem has it at
http://192.168.100.1/signal.html with no authentication required. It is
in an HTML table, but different from yours. Mine looks like this:
http://i49.tinypic.com/1z1tgnn.png
On 12/29/2012 01:08 PM, Rick Hornsby wrote:
>
> On Dec 29, 2012, at 08:39 , Bill Baker <bill_chris at earthlink.net> wrote:
>
>> It must only work for your model modem, because all I got was this:
>>
>> Sat Dec 29 09:37:50 EST 2012 hwver:0.0 rx:0.0 snr:0.0 tx:0.0
>
> If it helps, breaking it down here's what happens:
>
> http://ktzr.net/files/twc_cable_modem_stats.png
>
> The script expects:
> to find your modem at 192.168.100.1
> to not find any 401 authentication
> to have the statistics be at a page called 'system.asp'
> to have the target data be in an HTML table
>
> The ruby script is pretty simple - it just dumps all content it finds on the page that is in an HTML table cell (a 'td' tag). The "stats=" line takes that result and does some filtering and clean up, turning this
>
> Hardware Version
> 2.0
>
> Software Version
> dpc2100rx-v202r1256-110531Uas-TWC
>
> Receive Power Level
> -14.4 dBmV
>
> Signal to Noise Ratio
> 32.8 dBmV
>
> Transmit Power Level
> 42.8 dBmV
>
> into this
>
> 2.0 -14.5 32.8 42.8
>
> Stepwise, that stats= line:
> - filters out some unprintable junk characters (tr)
> - filters for only lines that (grep)
> - start with a dash or a number
> - followed by a dot .
> - followed by a number
> - replaces the newlines with a single space (tr)
>
> We print the current date, then the awk command then makes a(nother) leap that the different values are presented in the order above and prints them formatted as floating point numbers.
>
> The script is by no means smart about how it processes. It doesn't even bother looking at the data's label in the HTML.
>
>
>
>> On 12/29/2012 07:05 AM, Rick Hornsby wrote:
>>>
>>> If anyone is interested in replicating my work for their own setup, here's what I'm using to record the modem stats (if I knew ruby better, I could probably write the whole thing in ruby; also, there are a crapton of improvements possible. this was a 15 minute hack job):
>>>
>>>
>>> === fetch_stats.rb ===
>>> #!/usr/bin/ruby
>>>
>>> require 'rubygems'
>>> require 'nokogiri'
>>> require 'open-uri'
>>>
>>> doc = Nokogiri::HTML(open('http://192.168.100.1/system.asp'))
>>> doc.xpath("//td").each do |td|
>>> puts td.content
>>> end
>>>
>>> === modem_stats.sh ===
>>> #!/bin/bash
>>>
>>> fetch_stats=~/bin/fetch_stats.rb
>>>
>>> stats=$($fetch_stats | tr -d '\302\240' | grep -o "^-*[0-9]\+\.[0-9]\+" | tr '\n' ' ')
>>>
>>> echo -n $(date)
>>> echo $stats | awk '{printf " hwver:%0.1f rx:%0.1f snr:%0.1f tx:%0.1f\n", $1, $2, $3, $4}'
>>>
>>> === cron entry ===
>>> * * * * * ~/bin/modem_stats.sh >> ~/tmp/modem_stats.log
>>>
>>> === result ===
>>> Sat Dec 29 06:02:01 CST 2012 hwver:2.0 rx:-13.8 snr:32.9 tx:42.8
>>> _______________________________________________
>>> colug-432 mailing list
>>> colug-432 at colug.net
>>> http://lists.colug.net/mailman/listinfo/colug-432
>>>
>> _______________________________________________
>> colug-432 mailing list
>> colug-432 at colug.net
>> http://lists.colug.net/mailman/listinfo/colug-432
>
>
> _______________________________________________
> colug-432 mailing list
> colug-432 at colug.net
> http://lists.colug.net/mailman/listinfo/colug-432
>
More information about the colug-432
mailing list