Graphing Motorola Surfboard SB5101 Cable Modem Stats with Cacti

So you’ve got a cable modem, and you’re having problems (or you just like to track everything). You’ve already been to the management page of your cable modem (in most cases it is reachable at http://192.168.100.1/), but now you want more, or at least to be able to track changes over time. What can you do?

Use Cacti to graph the stats on your cable modem. Man that would sure be easy if you only had SNMP access to your DOCSIS cable modem. If you do then check out this post. But, if you’re like me and you have good old Comcast who disables client side SNMP access then you’re going to need a script to scrape your modem’s web based interface.

Here is my script for a Motorola Surfboard SB5101 cable modem (based off this post) which will display the following two graphs within Cacti:

Cable Modem Power Graphs

This graph displays your power levels and signal to noise ratio.

Cable Modem Frequency Graphs

This graph displays the frequencies on which your modem is operating. These should almost never change.

In order to use these you will need to download two items. The first is my Motorola Surfboard SB5101 PERL script which can be downloaded from my Cablemodem Template post on the Cacti Forum and then upload to your Cacti scripts directory.

The second piece to download is my Cacti XML host template also from my Cablemodem Template post on the Cacti Forum. Once downloaded you can import it and then add your devices.

This is my first custom template. As I create additional ones, I add them. If you use this template, please let me know how it works for you.

Advertisements
Leave a comment

9 Comments

  1. Simon

     /  September 21, 2006

    Hi,

    The freqeuncy graph works great 🙂

    But when I run the power level graphs I’m getting the following error:

    ERROR: can’t parse ‘#FFF200:SNR’

    Any idea on how to look into this?

    Thanks

    Si

  2. Fred

     /  December 3, 2006

    There is a bit of a bug in the template that caused some problems for me.

    1) The data template for the power level is missing the downstream SNR value. This needs to be added.
    2) The graph template doesn’t automatically pickup the SNR, this needs to be assigned manually to the graph instance.

    I also had to modify the Moto script for use with my SB5100:


    $content =~ s/\ |\n//g;

    # regex in html source order
    if ($content =~ /Frequency\s+(\d+?)\s+Hz\s+Locked/i) { $data{DownFreq} = $1; }
    if ($content =~ /Signal To Noise Ratio(\d+?) dB/i) { $data{DownSNR} = $1; }
    if ($content =~ /Power Level(.+?) dB/i) { $data{DownPower} = $1; }
    if ($content =~ /Frequency\s+(\d+?) Hz\s+Ranged/i) { $data{UpFreq} = $1; }
    if ($content =~ /Power Level(\d+?) dBmV/i) { $data{UpPower} = $1; }

    Hope this helps,
    F

  3. Fred

     /  December 3, 2006

    Looks like WordPress polluted the output of the code above. Contact me at fhirsch@NOSPAM@darkhart.net if you need a valid copy.

    Thanks again..

  4. Rik

     /  December 12, 2006

    i get this output and no graphs

    Use of uninitialized value in concatenation (.) or string at Moto_SurfBoard_CM.pl line 32.
    Use of uninitialized value in concatenation (.) or string at Moto_SurfBoard_CM.pl line 32.
    Use of uninitialized value in concatenation (.) or string at Moto_SurfBoard_CM.pl line 32.
    Use of uninitialized value in concatenation (.) or string at Moto_SurfBoard_CM.pl line 32.
    Use of uninitialized value in concatenation (.) or string at Moto_SurfBoard_CM.pl line 32.
    DownFreq: DownSNR: DownPower: UpFreq: UpPower:

    the modem is a 4200

    i’ve changed the source webpage to point to the correct url:

    192.168.0.1/signaldata.html

    the html source looks like this:

    Frequency
    330750000 Hz Locked

    Signal to Noise Ratio
    37 dB

    Power Level
    -1 dBmV

    etc etc

    sorry but i don’t know perl well enough to hack the code.

    i think that the parsing of the data may be wrong causing the variable to not be written

    please help

    ta in advance

  5. Rick

     /  March 12, 2008

    Thanks! Here is the revised script for the 5100.

    #!/usr/bin/perl
    #use warnings;
    #use strict;

    use LWP::Simple;

    my %data;
    my @keys = qw(DownFreq DownSNR DownPower UpFreq UpPower);
    my $content = LWP::Simple::get(“http://192.168.100.1/signaldata.html”) or die “Couldn’t get it!”;
    $content =~ s/\ |\n//g;
    #print $content;

    # regex in html source order
    if ($content =~ /Frequency\s*(.+?) Hz/) { $data{DownFreq} = $1; }
    if ($content =~ /Signal to Noise Ratio\s*(.+?) dB/) { $data{DownSNR} = $1; }
    if ($content =~ /Power Level\s*(.+?) dBmV\s*Frequency\s*?\s*(.+?) Hz \s*?/) { $data{UpFreq} = $1; }
    if ($content =~ /Power Level(.+?) dBmV\s*/) { $data{UpPower} = $1; }

    for (@keys) {
    print “$_:” . $data{$_} . ” “;
    }
    print “\n”;

  6. Rick

     /  March 12, 2008

    Another try. WordPress is stripping the regex’s that contain html.

    b#!/usr/bin/perl
    #use warnings;
    #use strict;

    use LWP::Simple;

    my %data;
    my @keys = qw(DownFreq DownSNR DownPower UpFreq UpPower);
    my $content = LWP::Simple::get(“http://192.168.100.1/signaldata.html”) or die “Couldn’t get it!”;
    $content =~ s/\ |\n//g;
    #print $content;

    # regex in html source order
    if ($content =~ /<TD>Frequency<\/TD><TD>\s*(.+?) Hz/) { $data{DownFreq} = $1; }
    if ($content =~ /<TD>Signal to Noise Ratio<\/TD><TD>\s*(.+?) dB/) { $data{DownSNR} = $1; }
    if ($content =~ /<\/TR><TD>Power Level<\/TD><TD>\s*(.+?) dBmV\s*<TABLE/) { $data{DownPower} = $1; }
    if ($content =~ /<\/TD><\/TR><TR><TD>Frequency<\/TD>\s*?<TD>\s*(.+?) Hz \s*?/) { $data{UpFreq} = $1; }
    if ($content =~ /<TR><TD>Power Level<\/TD><TD>(.+?) dBmV\s*/) { $data{UpPower} = $1; }

    for (@keys) {
    print “$_:” . $data{$_} . ” “;
    }
    print “\n”;

  7. Duane Walker

     /  April 1, 2008

    I had to remove the spaces and “\s”s from the regexs to get it to work. The global substitution removes the spaces from “Signal to Noise Ratio” as well.

    I was trying to do something like this for my Sipura VOIP box as well and was going to use HTML::TableExtract but this is simpler and just as effective.

    #!/usr/bin/perl
    use warnings;
    use strict;

    use LWP::Simple;

    my %data;
    my @keys = qw(DownFreq DownSNR DownPower UpFreq UpPower);
    my $content = LWP::Simple::get(“http://192.168.100.1/signaldata.html”) or die “Couldn’t get it!”;
    $content =~ s/\ |\n//g;
    #print $content;

    # regex in html source order
    if ($content =~ /Frequency(.+?)Hz/) { $data{DownFreq} = $1; }
    if ($content =~ /SignaltoNoiseRatio(.+?)dB/) { $data{DownSNR} = $1; }
    if ($content =~ /PowerLevel(.+?)dBmV/) { $data{DownPower} = $1; }
    if ($content =~ /Frequency(.+?)Hz/) { $data{UpFreq} = $1; }
    if ($content =~ /PowerLevel(.+?)dBmV/) { $data{UpPower} = $1; }

    for (@keys) {
    print “$_:” . $data{$_} . ” “;
    }
    print “\n”;

  8. moto

     /  April 9, 2008

    Got motorola SB5101 Surfboard cable modem, it only works with windows. Not working with Macintosh OS. Can anyone help, the installation CD is not recognized by MAC. Please Help.

  9. lost404

     /  October 19, 2008

    I created a windows batch file that does a similar thing – it captures all the data from the motorola surfboard sb5101 and dumps it to the command window. You can optionally have it write the data to a .csv file. You can then plot the data from the csv file using your favorite plotting program.

    You can automate the script to have it run every x minutes by using windows task scheduler. It works pretty well for me.

    I posted the batch file (modemstats.bat) and a screeen cap of it in the forums at dslreports.com. Here is a link to the post: http://www.dslreports.com/forum/r21290225-AZ-Motorola-Modem-Data-Win-XP-Batch-File

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: