Cacti (home)ForumsRepositoryDocumentation
Cacti: offical forums and support  

 FAQFAQ   SearchSearch   MemberlistMemberlist    RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in    


Cablemodem template & perl script
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cacti Forum Index -> Scripts and Templates
Author Message
Alives
Cacti User


Joined: 11 Jul 2005
Posts: 103

PostPosted: Sat Jul 30, 2005 9:28 pm    Post subject: Cablemodem template & perl script Reply with quote

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:
#!/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";



diag_page.JPG
 Description:
This is what my modem status page looks like. Use this to help form your regex's.
 Filesize:  61.8 KB
 Viewed:  22678 Time(s)

diag_page.JPG



cacti_host_template_cablemodem.xml
 Description:

Download
 Filename:  cacti_host_template_cablemodem.xml
 Filesize:  30.22 KB
 Downloaded:  990 Time(s)


RCA_DCM325.pl.txt
 Description:

Download
 Filename:  RCA_DCM325.pl.txt
 Filesize:  699 Bytes
 Downloaded:  678 Time(s)

Back to top
Alives
Cacti User


Joined: 11 Jul 2005
Posts: 103

PostPosted: Sat Aug 06, 2005 6:35 pm    Post subject: Reply with quote

had to get a new cablemodem so i now have the RCA 425 templates as well.


425.png
 Description:
 Filesize:  26.19 KB
 Viewed:  22549 Time(s)

425.png




Last edited by Alives on Sun Aug 07, 2005 4:00 pm; edited 1 time in total
Back to top
Alives
Cacti User


Joined: 11 Jul 2005
Posts: 103

PostPosted: Sat Aug 06, 2005 6:37 pm    Post subject: Reply with quote

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

save script as .pl file



RCA_DCM425.pl.txt
 Description:

Download
 Filename:  RCA_DCM425.pl.txt
 Filesize:  883 Bytes
 Downloaded:  686 Time(s)


cacti_host_template_cablemodem.xml
 Description:

Download
 Filename:  cacti_host_template_cablemodem.xml
 Filesize:  40.45 KB
 Downloaded:  753 Time(s)

Back to top
kmichaels



Joined: 09 Feb 2005
Posts: 6

PostPosted: Tue Aug 16, 2005 11:05 am    Post subject: Good script Reply with quote

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
Back to top
Alives
Cacti User


Joined: 11 Jul 2005
Posts: 103

PostPosted: Tue Aug 16, 2005 11:14 am    Post subject: Reply with quote

quit drinking hatoraide
Back to top
ScaredyCat



Joined: 18 Aug 2005
Posts: 7

PostPosted: Thu Aug 18, 2005 12:42 pm    Post subject: Reply with quote

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
Back to top
Alives
Cacti User


Joined: 11 Jul 2005
Posts: 103

PostPosted: Thu Aug 18, 2005 12:50 pm    Post subject: Reply with quote

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)
Back to top
ScaredyCat



Joined: 18 Aug 2005
Posts: 7

PostPosted: Thu Aug 18, 2005 12:52 pm    Post subject: Reply with quote

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

SC
Back to top
Alives
Cacti User


Joined: 11 Jul 2005
Posts: 103

PostPosted: Thu Aug 18, 2005 1:08 pm    Post subject: Reply with quote

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.
Back to top
wazoqaz



Joined: 24 May 2006
Posts: 15
Location: md, us

PostPosted: Mon Jun 19, 2006 10:03 pm    Post subject: Cable modem - Motorola Surfboard SB5101 Reply with quote

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.


cm-powerlevels.png
 Description:
Power levels for Surfboard SB5101
 Filesize:  29.94 KB
 Viewed:  21560 Time(s)

cm-powerlevels.png



cm-frequency.png
 Description:
Frequency graph for Motorola Surfboard SB5101 - note it won't change much.
 Filesize:  18.53 KB
 Viewed:  21560 Time(s)

cm-frequency.png



Moto_SurfBoard_CM.pl.txt
 Description:
Motorola Surfboard SB5101 script - remove txt extension and upload to your scripts directory

Download
 Filename:  Moto_SurfBoard_CM.pl.txt
 Filesize:  769 Bytes
 Downloaded:  1108 Time(s)


cacti_host_template_cablemodem.xml
 Description:
Host template for Motorola Surfboard SB5101

Download
 Filename:  cacti_host_template_cablemodem.xml
 Filesize:  24.76 KB
 Downloaded:  1093 Time(s)

Back to top
BSOD2600
Cacti Moderator


Joined: 08 May 2004
Posts: 8831
Location: WA, USA

PostPosted: Mon Aug 28, 2006 4:05 pm    Post subject: Reply with quote

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.


moto_surfboard5100.pl.txt
 Description:
Surfboard SB5100 script

Download
 Filename:  moto_surfboard5100.pl.txt
 Filesize:  1.03 KB
 Downloaded:  670 Time(s)

Back to top
Loki



Joined: 30 Aug 2006
Posts: 1

PostPosted: Wed Aug 30, 2006 1:25 pm    Post subject: ERROR: Not a valid vname Reply with quote

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
[img][/img]



rrtool-debug.png
 Description:
Debug Screen
 Filesize:  24.13 KB
 Viewed:  20570 Time(s)

rrtool-debug.png


Back to top
abadaba
Cacti User


Joined: 23 Nov 2005
Posts: 52

PostPosted: Wed Sep 06, 2006 6:39 pm    Post subject: Drrnnn Reply with quote

When i run it from command line i get this

Any help would be appreciated

Code:

 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:

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' 
Back to top
abadaba
Cacti User


Joined: 23 Nov 2005
Posts: 52

PostPosted: Sat Sep 09, 2006 3:19 pm    Post subject: Reply with quote

Anyone have any ideas of the problem?
Back to top
BSOD2600
Cacti Moderator


Joined: 08 May 2004
Posts: 8831
Location: WA, USA

PostPosted: Sun Sep 10, 2006 7:27 pm    Post subject: Reply with quote

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.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Cacti Forum Index -> Scripts and Templates All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 



Powered by phpBB © 2001, 2005 phpBB Group