Cacti (home)ForumsDocumentation
Cacti: offical forums and support
It is currently Sun Apr 21, 2019 9:21 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 42 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: Cablemodem template & perl script
PostPosted: Sat Jul 30, 2005 9:28 pm 
Offline
Cacti User

Joined: Mon Jul 11, 2005 11:39 am
Posts: 103
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";


Attachments:
cacti_host_template_cablemodem.xml [30.22 KiB]
Downloaded 1681 times
File comment: This is what my modem status page looks like. Use this to help form your regex's.
diag_page.JPG
diag_page.JPG [ 61.8 KiB | Viewed 47505 times ]
RCA_DCM325.pl.txt [699 Bytes]
Downloaded 1205 times
Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 06, 2005 6:35 pm 
Offline
Cacti User

Joined: Mon Jul 11, 2005 11:39 am
Posts: 103
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 47376 times ]


Last edited by Alives on Sun Aug 07, 2005 4:00 pm, edited 1 time in total.
Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 06, 2005 6:37 pm 
Offline
Cacti User

Joined: Mon Jul 11, 2005 11:39 am
Posts: 103
Here is the host template. this template contains all the graphs and data source templates.

save script as .pl file


Attachments:
RCA_DCM425.pl.txt [883 Bytes]
Downloaded 1294 times
cacti_host_template_cablemodem.xml [40.45 KiB]
Downloaded 1489 times
Top
 Profile  
 
 Post subject: Good script
PostPosted: Tue Aug 16, 2005 11:05 am 
Offline

Joined: Wed Feb 09, 2005 11:05 am
Posts: 6
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


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 16, 2005 11:14 am 
Offline
Cacti User

Joined: Mon Jul 11, 2005 11:39 am
Posts: 103
quit drinking hatoraide


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 18, 2005 12:42 pm 
Offline

Joined: Thu Aug 18, 2005 6:20 am
Posts: 7
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


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 18, 2005 12:50 pm 
Offline
Cacti User

Joined: Mon Jul 11, 2005 11:39 am
Posts: 103
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)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 18, 2005 12:52 pm 
Offline

Joined: Thu Aug 18, 2005 6:20 am
Posts: 7
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


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 18, 2005 1:08 pm 
Offline
Cacti User

Joined: Mon Jul 11, 2005 11:39 am
Posts: 103
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.


Top
 Profile  
 
 Post subject: Cable modem - Motorola Surfboard SB5101
PostPosted: Mon Jun 19, 2006 10:03 pm 
Offline

Joined: Wed May 24, 2006 9:40 am
Posts: 15
Location: md, us
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:
File comment: Motorola Surfboard SB5101 script - remove txt extension and upload to your scripts directory
Moto_SurfBoard_CM.pl.txt [769 Bytes]
Downloaded 1875 times
File comment: Host template for Motorola Surfboard SB5101
cacti_host_template_cablemodem.xml [24.76 KiB]
Downloaded 1847 times
File comment: Power levels for Surfboard SB5101
cm-powerlevels.png
cm-powerlevels.png [ 29.94 KiB | Viewed 46386 times ]
File comment: Frequency graph for Motorola Surfboard SB5101 - note it won't change much.
cm-frequency.png
cm-frequency.png [ 18.53 KiB | Viewed 46386 times ]
Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 28, 2006 4:05 pm 
Offline
Cacti Moderator
User avatar

Joined: Sat May 08, 2004 12:44 pm
Posts: 12158
Location: USA
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:
File comment: Surfboard SB5100 script
moto_surfboard5100.pl.txt [1.03 KiB]
Downloaded 1264 times

_________________

| Scripts: Monitor processes | RFC1213 MIB | DOCSIS Stats | Dell PowerEdge | Speedfan | APC UPS | DOCSIS CMTS | 3ware | Motorola Canopy |
| Guides: Windows Install | [HOWTO] Debug Windows NTFS permission problems |
| Tools: Windows All-in-one Installer |
Top
 Profile  
 
 Post subject: ERROR: Not a valid vname
PostPosted: Wed Aug 30, 2006 1:25 pm 
Offline

Joined: Wed Aug 30, 2006 1:12 pm
Posts: 1
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:
File comment: Debug Screen
rrtool-debug.png
rrtool-debug.png [ 24.13 KiB | Viewed 45397 times ]
Top
 Profile  
 
 Post subject: Drrnnn
PostPosted: Wed Sep 06, 2006 6:39 pm 
Offline
Cacti User

Joined: Wed Nov 23, 2005 10:43 pm
Posts: 52
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' 

_________________
| 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 |


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 09, 2006 3:19 pm 
Offline
Cacti User

Joined: Wed Nov 23, 2005 10:43 pm
Posts: 52
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 |


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 10, 2006 7:27 pm 
Offline
Cacti Moderator
User avatar

Joined: Sat May 08, 2004 12:44 pm
Posts: 12158
Location: USA
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.

_________________

| Scripts: Monitor processes | RFC1213 MIB | DOCSIS Stats | Dell PowerEdge | Speedfan | APC UPS | DOCSIS CMTS | 3ware | Motorola Canopy |
| Guides: Windows Install | [HOWTO] Debug Windows NTFS permission problems |
| Tools: Windows All-in-one Installer |


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 42 posts ]  Go to page 1, 2, 3  Next

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group