|
|
| Author |
Message |
Alives Cacti User
Joined: 11 Jul 2005 Posts: 103
|
Posted: Sat Jul 30, 2005 9:28 pm Post subject: Cablemodem template & perl script |
|
|
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"; |
| Description: |
| This is what my modem status page looks like. Use this to help form your regex's. |
|
| Filesize: |
61.8 KB |
| Viewed: |
18245 Time(s) |

|
| Description: |
|
 Download |
| Filename: |
cacti_host_template_cablemodem.xml |
| Filesize: |
30.22 KB |
| Downloaded: |
830 Time(s) |
| Description: |
|
 Download |
| Filename: |
RCA_DCM325.pl.txt |
| Filesize: |
699 Bytes |
| Downloaded: |
576 Time(s) |
|
|
| Back to top |
|
 |
Alives Cacti User
Joined: 11 Jul 2005 Posts: 103
|
Posted: Sat Aug 06, 2005 6:35 pm Post subject: |
|
|
had to get a new cablemodem so i now have the RCA 425 templates as well.
| Description: |
|
| Filesize: |
26.19 KB |
| Viewed: |
18116 Time(s) |

|
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
|
Posted: Sat Aug 06, 2005 6:37 pm Post subject: |
|
|
Here is the host template. this template contains all the graphs and data source templates.
save script as .pl file
| Description: |
|
 Download |
| Filename: |
RCA_DCM425.pl.txt |
| Filesize: |
883 Bytes |
| Downloaded: |
585 Time(s) |
| Description: |
|
 Download |
| Filename: |
cacti_host_template_cablemodem.xml |
| Filesize: |
40.45 KB |
| Downloaded: |
623 Time(s) |
|
|
| Back to top |
|
 |
kmichaels
Joined: 09 Feb 2005 Posts: 6
|
Posted: Tue Aug 16, 2005 11:05 am Post subject: Good script |
|
|
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
|
Posted: Tue Aug 16, 2005 11:14 am Post subject: |
|
|
| quit drinking hatoraide
|
|
| Back to top |
|
 |
ScaredyCat
Joined: 18 Aug 2005 Posts: 7
|
Posted: Thu Aug 18, 2005 12:42 pm Post subject: |
|
|
| 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
|
Posted: Thu Aug 18, 2005 12:50 pm Post subject: |
|
|
| 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
|
Posted: Thu Aug 18, 2005 12:52 pm Post subject: |
|
|
| 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
|
Posted: Thu Aug 18, 2005 1:08 pm Post subject: |
|
|
| 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
|
Posted: Mon Jun 19, 2006 10:03 pm Post subject: Cable modem - Motorola Surfboard SB5101 |
|
|
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.
| Description: |
| Power levels for Surfboard SB5101 |
|
| Filesize: |
29.94 KB |
| Viewed: |
17127 Time(s) |

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

|
| 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: |
925 Time(s) |
| Description: |
| Host template for Motorola Surfboard SB5101 |
|
 Download |
| Filename: |
cacti_host_template_cablemodem.xml |
| Filesize: |
24.76 KB |
| Downloaded: |
889 Time(s) |
|
|
| Back to top |
|
 |
BSOD2600 Cacti Moderator
Joined: 08 May 2004 Posts: 7852 Location: WA, USA
|
Posted: Mon Aug 28, 2006 4:05 pm Post subject: |
|
|
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.
| Description: |
|
 Download |
| Filename: |
moto_surfboard5100.pl.txt |
| Filesize: |
1.03 KB |
| Downloaded: |
574 Time(s) |
|
|
| Back to top |
|
 |
Loki
Joined: 30 Aug 2006 Posts: 1
|
Posted: Wed Aug 30, 2006 1:25 pm Post subject: ERROR: Not a valid vname |
|
|
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]
| Description: |
|
| Filesize: |
24.13 KB |
| Viewed: |
16137 Time(s) |

|
|
|
| Back to top |
|
 |
abadaba Cacti User
Joined: 23 Nov 2005 Posts: 52
|
Posted: Wed Sep 06, 2006 6:39 pm Post subject: Drrnnn |
|
|
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
|
Posted: Sat Sep 09, 2006 3:19 pm Post subject: |
|
|
| Anyone have any ideas of the problem?
|
|
| Back to top |
|
 |
BSOD2600 Cacti Moderator
Joined: 08 May 2004 Posts: 7852 Location: WA, USA
|
Posted: Sun Sep 10, 2006 7:27 pm Post subject: |
|
|
| 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 |
|
 |
|