Cablemodem template & perl script

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Alives
Cacti User
Posts: 103
Joined: Mon Jul 11, 2005 11:39 am

Cablemodem template & perl script

Post by Alives »

This script reads the results of an http page grab and populates the data sources with the values.

The script is set to run on an RCA modem's status page which is located here: http://192.168.100.1/diagnostics_body.html . This is my page location. Yours may differ. You should look at http://192.168.100.1 and find the actual address of yours. This goes in line 7 of the perl script.

SNMP would have been useful but it is turned off aytime the modem gets a sync. I think the ISP uses snmp to configure the modems.

I have attached the script and xml template. Enjoy!

You will have to edit the perl script to match your page.

Code: Select all

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

use LWP::Simple;

my $httpaddr = "http://192.168.100.1/diagnostics_body.html";

my %data;
my @keys = qw(DownFreq DownSNR DownPower UpFreq UpPower);
my $content = LWP::Simple::get($httpaddr) or die "Couldn't get it!";
$content =~ s/\ |\n//g;

# regex in html source order
if ($content =~ /Acquired at (\d+\.\d)\d+ MHz/) { $data{DownFreq} = $1; }
if ($content =~ /SNR: (.+?) dB/) { $data{DownSNR} = $1; }
if ($content =~ /Frequency: (.+?) MHz/) { $data{DownPower} = $1; }
if ($content =~ /Received Signal Strength: (.+?) dBmV/) { $data{UpFreq} = $1; }
if ($content =~ /Power Level: (.+?) dBmV/) { $data{UpPower} = $1; }

for (@keys) {
	print "$_:" . $data{$_} . " ";
}
print "\n";
Attachments
This is what my modem status page looks like.  Use this to help form your regex's.
This is what my modem status page looks like. Use this to help form your regex's.
diag_page.JPG (61.8 KiB) Viewed 52417 times
RCA_DCM325.pl.txt
(699 Bytes) Downloaded 1385 times
cacti_host_template_cablemodem.xml
(30.22 KiB) Downloaded 1949 times
Alives
Cacti User
Posts: 103
Joined: Mon Jul 11, 2005 11:39 am

Post by Alives »

had to get a new cablemodem so i now have the RCA 425 templates as well.
Attachments
425.png
425.png (26.19 KiB) Viewed 52288 times
Last edited by Alives on Sun Aug 07, 2005 4:00 pm, edited 1 time in total.
Alives
Cacti User
Posts: 103
Joined: Mon Jul 11, 2005 11:39 am

Post by Alives »

Here is the host template. this template contains all the graphs and data source templates.

save script as .pl file
Attachments
cacti_host_template_cablemodem.xml
(40.45 KiB) Downloaded 1676 times
RCA_DCM425.pl.txt
(883 Bytes) Downloaded 1472 times
kmichaels
Posts: 6
Joined: Wed Feb 09, 2005 11:05 am

Good script

Post by kmichaels »

Just and FYI


QAM is the modems modulation profile.
Frequency very rarley changes.
Your downstream power level appears to be graphing improperly.

Oh, and BTW, if that is your cable modem, and your upstream is 61dbvm, you may want to call the cable company and see about getting a service call, chances are you are currrently or will be dropping offline.

Good; thoughtful; and well written script otherwise
Alives
Cacti User
Posts: 103
Joined: Mon Jul 11, 2005 11:39 am

Post by Alives »

quit drinking hatoraide
ScaredyCat
Posts: 7
Joined: Thu Aug 18, 2005 6:20 am

Post by ScaredyCat »

Alives wrote:Here is the host template. this template contains all the graphs and data source templates.
Thanks Alives works well for me, although there are never any error stats - is that correct? Do they only actually appear when the modem is in an error state?

SC
Alives
Cacti User
Posts: 103
Joined: Mon Jul 11, 2005 11:39 am

Post by Alives »

do you have the 325 or 425? my 325 didnt show errors but i got the 425 recently and it does. (NYC Time Warner Cable)
ScaredyCat
Posts: 7
Joined: Thu Aug 18, 2005 6:20 am

Post by ScaredyCat »

Alives wrote:do you have the 325 or 425? my 325 didnt show errors but i got the 425 recently and it does. (NYC Time Warner Cable)
Actualy it's a Thomson (TCM 390) cable modem, but the pages are identical in layout and colours :D

SC
Alives
Cacti User
Posts: 103
Joined: Mon Jul 11, 2005 11:39 am

Post by Alives »

well the script just does a straight html scrape to get the data... you should be able to edit the script and chane it to what your page looks like. standard regex pulls.
wazoqaz
Posts: 15
Joined: Wed May 24, 2006 9:40 am
Location: md, us
Contact:

Cable modem - Motorola Surfboard SB5101

Post by wazoqaz »

I've modified the script and templates to work with a Motorola Surfboard SB5101 cable modem. I hope you enjoy! Let me know if they work for you.
Attachments
Frequency graph for Motorola Surfboard SB5101 - note it won't change much.
Frequency graph for Motorola Surfboard SB5101 - note it won't change much.
cm-frequency.png (18.53 KiB) Viewed 51298 times
Power levels for Surfboard SB5101
Power levels for Surfboard SB5101
cm-powerlevels.png (29.94 KiB) Viewed 51298 times
cacti_host_template_cablemodem.xml
Host template for Motorola Surfboard SB5101
(24.76 KiB) Downloaded 1975 times
Moto_SurfBoard_CM.pl.txt
Motorola Surfboard SB5101 script - remove txt extension and upload to your scripts directory
(769 Bytes) Downloaded 2043 times
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Post by BSOD2600 »

Was bored at work so I modified the script to work with my Surfboard SB5100 modem. Use the same template as the other surfboard modem above.
Attachments
moto_surfboard5100.pl.txt
Surfboard SB5100 script
(1.03 KiB) Downloaded 1402 times
Loki
Posts: 1
Joined: Wed Aug 30, 2006 1:12 pm

ERROR: Not a valid vname

Post by Loki »

wazoqaz

Was able to import your xml file, but i am unable to view the 'Power Levels' graph. Getting a rrdtool error. Any thoughts ?

thanks for the help.

------------------------------------------------------------------------------
Import Results

Cacti has imported the following items:

Round Robin Archive
[success] Daily (5 Minute Average) [update]
[success] Weekly (30 Minute Average) [update]
[success] Monthly (2 Hour Average) [update]
[success] Yearly (1 Day Average) [update]

GPRINT Preset
[success] Normal [update]

Data Input Method
[success] Cablemodem - Diagnostics Page [new]

Data Template
[success] Cablemodem - Power Levels [new]
[success] Cablemodem - Frequencies [new]

Graph Template
[success] Cablemodem - Power Levels [new]
+ Found Dependency: (Data Template Item) cable_uppower
+ Found Dependency: (GPRINT Preset) Normal
+ Found Dependency: (Data Template Item) cable_downpower
+ Unmet Dependency: (Data Template Item)
+ Unmet Dependency: (Data Template Item)
+ Unmet Dependency: (Data Template Item)
+ Unmet Dependency: (Data Template Item)
+ Unmet Dependency: (Data Template Item)
[success] Cablemodem - Frequency [new]

Host Template
[success] Cablemodem [update]
------------------------------------------------------------------------------

RRDTool Command:

/usr/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-300 \
--title="Localhost - Power Levels" \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="dBmV" \
--slope-mode \
DEF:a="/usr/share/cacti/site/rra/localhost_cable_downpower_46.rrd":cable_uppower:LAST \
DEF:b="/usr/share/cacti/site/rra/localhost_cable_downpower_46.rrd":cable_downpower:LAST \
AREA:a#005199:"Upstream" \
GPRINT:a:LAST:" Current\:%8.2lf %s" \
GPRINT:a:MIN:"Min\:%8.2lf %s" \
GPRINT:a:AVERAGE:"Ave\:%8.2lf %s" \
GPRINT:a:MAX:"Max\:%8.2lf %s\n" \
AREA:b#FF5700:"Downstream" \
GPRINT:b:LAST:"Current\:%8.2lf %s" \
GPRINT:b:MIN:"Min\:%8.2lf %s" \
GPRINT:b:AVERAGE:"Ave\:%8.2lf %s" \
GPRINT:b:MAX:"Max\:%8.2lf %s\n" \
LINE2:#FFF200:"SNR" \
GPRINT::LAST:" Current\:%8.2lf %s" \
GPRINT::MIN:"Min\:%8.2lf %s" \
GPRINT::AVERAGE:"Ave\:%8.2lf %s" \
GPRINT::MAX:"Max\:%8.2lf %s\n"

RRDTool Says:

ERROR: Not a valid vname: #FFF200 in line LINE2:#FFF200:SNR


------------------------------------------------------------------------------

example scriptoutput


DownFreq:687000000 DownSNR:35 DownPower:-4 UpFreq:23984000 UpPower:45
Attachments
Debug Screen
Debug Screen
rrtool-debug.png (24.13 KiB) Viewed 50309 times
abadaba
Cacti User
Posts: 52
Joined: Wed Nov 23, 2005 10:43 pm

Drrnnn

Post by abadaba »

When i run it from command line i get this

Any help would be appreciated

Code: Select all

 perl /var/www/html/monitor/scripts/moto_surfboard_cm.pl 192.168.100.1
Use of uninitialized value in concatenation (.) or string at /var/www/html/monitor/scripts/moto_surfboard_cm.pl line 25.
Use of uninitialized value in concatenation (.) or string at /var/www/html/monitor/scripts/moto_surfboard_cm.pl line 25.
DownFreq: DownSNR:38 DownPower:4 UpFreq: UpPower:4
But in my logs i get this

Code: Select all

09/06/2006 06:35:45 PM - CACTID: Poller[0] Host[56] DS[369] WARNING: Result from SCRIPT not valid. Partial Result: ...  
09/06/2006 06:35:45 PM - CACTID: Poller[0] Host[56] ERROR: Empty result [192.168.100.1]: 'perl /var/www/html/monitor/scripts/moto_surfboard_cm.pl'  
09/06/2006 06:35:45 PM - CACTID: Poller[0] Host[56] DS[368] WARNING: Result from SCRIPT not valid. Partial Result: ...  
09/06/2006 06:35:45 PM - CACTID: Poller[0] Host[56] ERROR: Empty result [192.168.100.1]: 'perl /var/www/html/monitor/scripts/moto_surfboard_cm.pl'  
| Cacti 0.8.6h | MySQL 5.0.22 | PHP 5.1.2
|Apache2.20 | RRDtool 1.2.13 | CentOS 4.3 | P4 3200Mhz | 2.5GB |
abadaba
Cacti User
Posts: 52
Joined: Wed Nov 23, 2005 10:43 pm

Post by abadaba »

Anyone have any ideas of the problem?
| Cacti 0.8.6h | MySQL 5.0.22 | PHP 5.1.2
|Apache2.20 | RRDtool 1.2.13 | CentOS 4.3 | P4 3200Mhz | 2.5GB |
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Post by BSOD2600 »

Loki: Your problem is likely the same I experienced with Bug 816. There is not a fix for it yet, that I'm aware of.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests