 jvl001 join:2008-06-09 Mississauga, ON Reviews:
·TekSavvy Cable
·TekSavvy DSL
| Line stats monitoring with RRDTool or MRTG SNR for one week. Note the break in data on the 4th was when I disconnected the phone network to install a POTS splitter. |  Average network traffic on WAN. Note Out=Downstream, In=Upstream. |  All line errors for 1 day. The errors are the result of disconnecting the line. Usually I get zero. |
Hi everyone.
I thought I would give back to the DSLReports/TSI community by providing some information on how to monitor your modem stats without running DMT, etc. Instead I'm using RRDTool (see »oss.oetiker.ch/rrdtool/) to periodically (every 5 mins) capture line stats information (SNR, Attenuation, Power, HEC, CRC, and FEC errors) and archive them in a round-robin database. The result allows you to generate pretty graphs on demand, at whatever time interval (past hour to past year) and resolution (5 mins to 1 day) you like.
I'm working with a ST516 but this should work with other SpeedTouch modems (may need tweaking) or even other brands of modems (definitely would need some changes). Provided you can reach your modem by telnet (i.e. DMT works ok) then you can use these scripts.
Originally I started with MRTG+RRDTool (»oss.oetiker.ch/mrtg/) which lets you sample and record anything you can imagine, but was initially developed to retrieve data via SNMP (e.g. record network traffic). I've found that I can do all that I want with RRDTool and scripts of my own, generating graphs on demand using simple CGI scripts. I've successfully enabled SNMP on my ST516 and can sample the network traffic on the routed PPPoE interface and on the LAN interface.
The following script was written in Perl to telnet into the modem, execute an adsl info command, and parse the output. The retrieved values are then saved to an RRDTool database. It should work on any OS that has Perl installed along with the Net::Telnet and RRDs modules. The nice thing about RRDTool is that the data is aggregated in a round-robin fashion. The files stay the same size and you can tune it for whatever interval/resolution you wish.
#!/usr/bin/perl
#
# Author: Jason Lassaline (jason.lassaline_at_gmail.com)
#
# Retrieve ADSL line stats from SpeedTouch 5x6 modem. Tested on ST516 with
# firmware version 6.2.16.3. Should work on other SpeedTouch modems but may
# need tweaking. If it doesn't work, telnet into the modem and run the command:
# :adsl info expand=enabled
# then check if parsing regex matches your output. Adjust as necessary.
#
# NOTE: Just like other modem utilities, your modem must be reachable from your
# local network. If it is in bridge modem, you'll need to add some routing
# to your router or machine to reach the modem. If you can't telnet into the
# modem then this script won't work!
#
# This script does the following:
# 1/ Telnet into modem and executes adsl info command (see ST5x6 Command
# Reference). Immediately closes telnet connection on retrieval of output.
# 2/ Parses output for specific line stats.
# 3/ If RRDTool file does not exist, creates it.
# 4/ Updates RRDTool file with current values using 'now' timestamp.
# 5/ Exits.
# You must have the Net::Telnet and RRDS (comes with RRDTool) Perl classes
use Net::Telnet ();
use RRDs;
# Set to your ST5x6 IP address or hostname (if any)
$host = '10.0.0.138';
# Set to your ST5x6 administator user id (Administrator or admin or whatever)
$user = 'admin';
# Set to your ST5x6 administator password (only you know what this is)
$pass = 'mysecret';
# Adjust to the desired output pathname for RRDTool. Should be within your Web
# server root directory if you wish to serve graphs via cgi script unless you
# want to mess with access rules.
$RRD_FILE="/var/www/rrdtool/st5x6.rrd";
# Call this script every $STEP seconds to update the RRDTool file (use cron)
$STEP=300;
# Keep the heartbeat at 2*$STEP for now in the event retrieving and parsing
# modem output takes an unusually long time. Recorded values may span more than
# one timestep at worst.
$HEARTBEAT=600;
$t = new Net::Telnet ( Timeout => 10,
Prompt => '/.*=>$/i',
Errmode => 'die');
# Open host
$t->open($host);
# Login
$t->login($user, $pass);
# Fire off adsl info command
@result = $t->cmd(':adsl info expand=enabled');
# Logout
$t->close();
# May not be necessary
chomp(@result);
# Initialize all outputs as unknown in case parsing fails
$snr_up="U";
$snr_down="U";
$att_up="U";
$att_down="U";
$power_up="U";
$power_down="U";
$fec_up="U";
$fec_down="U";
$crc_up="U";
$crc_down="U";
$hec_up="U";
$hec_down="U";
# Loop over results, parsing expanded adsl info output
while(@result)
{
if (@result[0] =~ /Margin\s+\(dB\)\s+:\s+(\d+.\d+)\s+(\d+.\d+)/)
{
# SNR Margin down/up in dB
$snr_down=$1;
$snr_up=$2;
}
if (@result[0] =~ /Attenuation\s+\(dB\)\s+:\s+(\d+.\d+)\s+(\d+.\d+)/)
{
# Attenuation down/up in dB
$att_down=$1;
$att_up=$2;
}
if (@result[0] =~ /OutputPower\s+\(dBm\)\s+:\s+(\d+.\d+)\s+(\d+.\d+)/)
{
# Output power down/up in dB
$power_down=$1;
$power_up=$2;
}
if (@result[0] =~ /Received FEC\s+:\s+(\d+)/)
{
# Count of FEC errors down
$fec_down=$1;
}
if (@result[0] =~ /Transmitted FEC\s+:\s+(\d+)/)
{
# Count of FEC errors up
$fec_up=$1;
}
if (@result[0] =~ /Received CRC\s+:\s+(\d+)/)
{
# Count of CRC errors down
$crc_down=$1;
}
if (@result[0] =~ /Transmitted CRC\s+:\s+(\d+)/)
{
# Count of CRC errors up
$crc_up=$1;
}
if (@result[0] =~ /Received HEC\s+:\s+(\d+)/)
{
# Count of HEC errors up
$hec_down=$1;
}
if (@result[0] =~ /Transmitted HEC\s+:\s+(\d+)/)
{
# Count of HEC errors down
$hec_up=$1;
}
# Note that there is more information available in the output, such
# as line profile up/down and maximum line up/down bandwidth. Parse
# as you see fit.
shift(@result);
}
if (not -e $RRD_FILE) # RRDTool file does not exist...
{
# ...so create it. SNR, Attenuation, and Power are all gauged values in
# RRDTool terminology, while FEC,HEC, and CRC errors are all counters.
# Note that values are archived using 4 different intervals.
# The data is archived (approximately) for 3.5 days at 5 minute intervals,
# for 21 days at 30 minute intervals, for 83 days at 2 hour intervals, and
# for 2.7 years at 24 hour intervals. Note that sampled data is averaged
# over these intervals so that you can retrieve data (graphs) from 5 minute
# resolution (over a few days) to daily resolution (over almost 3 years).
# See RRDTool documentation for more information.
RRDs::create("$RRD_FILE","--start=N","--step=$STEP",
"DS:snru:GAUGE:$HEARTBEAT:0:U",
"DS:snrd:GAUGE:$HEARTBEAT:0:U",
"DS:attu:GAUGE:$HEARTBEAT:0:U",
"DS:attd:GAUGE:$HEARTBEAT:0:U",
"DS:powu:GAUGE:$HEARTBEAT:0:U",
"DS:powd:GAUGE:$HEARTBEAT:0:U",
"DS:fecu:COUNTER:$HEARTBEAT:0:U",
"DS:fecd:COUNTER:$HEARTBEAT:0:U",
"DS:crcu:COUNTER:$HEARTBEAT:0:U",
"DS:crcd:COUNTER:$HEARTBEAT:0:U",
"DS:hecu:COUNTER:$HEARTBEAT:0:U",
"DS:hecd:COUNTER:$HEARTBEAT:0:U",
"RRA:AVERAGE:0.5:1:1000",
"RRA:AVERAGE:0.5:6:1000",
"RRA:AVERAGE:0.5:24:1000",
"RRA:AVERAGE:0.5:288:1000");
}
# File must exist, so update it with 'now' as the time stamp. This will be off
# a small amount due to the time it takes to retrieve and parse the modem data
# this is likely not significant and is probably a constant offset.
RRDs::update("$RRD_FILE","N:$snr_up:$snr_down:$att_up:$att_down:$power_up:$power_down:$fec_up:$fec_down:$crc_up:$crc_down:$hec_up:$hec_down");
The above script should be run periodically at the value specified by the STEP variable in the above script. I run mine on a Linux machine using a cron job every 5 minutes. The results are archived in a RRDTool database which I process on demand using a CGI script. I use the following CGI script to plot one set of up/down parameters for a particular interval (eg. 1h, 1w, 1m, or 1y).
#!/usr/bin/rrdcgi
<HTML>
<HEAD><TITLE>Line Stats for ST5x6</TITLE></HEAD>
<BODY>
<H1>ST5x6</H1>
<H2>Line Stats for <RRD::CV measure></H2>
<P>
<RRD::GOODFOR 300>
<RRD::GRAPH st5x6_<RRD::CV::PATH measure>_<RRD::CV interval>.png
--lazy --title=<RRD::CV measure>
--start end-<RRD::CV interval> --end now
DEF:dn=/var/www/rrdtool/st5x6.rrd:<RRD::CV measure>d:AVERAGE
DEF:up=/var/www/rrdtool/st5x6.rrd:<RRD::CV measure>u:AVERAGE
AREA:dn#0000ff80:
AREA:up#00ff0080:
LINE1:dn#0000ff:"Downstream [<RRD::CV units>]"
LINE1:up#00ff00:"Upstream [<RRD::CV units>]"
>
</P>
</BODY>
</HTML>
Note that the above CGI script makes use of the RRDTool CGI utility so adjust the path to rrdcgi as necessary. To plot SNR up/down for the past day I would use a link such as: INSERTYOURWEBSERVERURLHERE/cgi-bin/linestats.cgi?measure=snr&units=dB&interval=1d
I collect all this data and serve the CGI scripts on a NSLU2 re-flashed to run Debian. This is rather underpowered so my CGI only generates one graph on demand rather than regenerating all graphs every 5 minutes like with MRTG. You can easily modify the above to generate more graphs on one page if you like or plot other SNMP data. See the RRDTool documentation for more information.
If you have any questions or find any problems please let me know.
PS: It's interesting to note that my SNR margin has been rock solid after I installed a POTS splitter at the exterior NID. Prior to this I was using an inline filter to filter the entire house phone network and it would fluctuate by about 1 dB.
Also note that the network traffic is averaged over the 5 minute interval. It doesn't represent peak through put, although you can store and plot this if you wish. |
|
 jvl001 join:2008-06-09 Mississauga, ON Reviews:
·TekSavvy Cable
·TekSavvy DSL
| FYI.
Although I frequently program and write shell scripts, I'm no Perl expert. There may be better ways to do this but this works for me. YMMV. I patterned this script after others that I found online and discovered that a Perl script solution works quite simply with the telnet modules. |
|
 jvl001 join:2008-06-09 Mississauga, ON Reviews:
·TekSavvy Cable
·TekSavvy DSL
| reply to jvl001 I don't think SNMP is enabled by default on SpeedTouch modems. To do so, you'll need to telnet into the modem and complete the following tasks (as best I can remember).
1/ Make sure there is at least a read-only public SNMP community. Check the list of SNMP communities with: :snmp community list
Add a public read-only community with: :snmp community add securityname=ROCommunity communityname=public
2/ Enable the SNMP system service if it is not already. Check with: :service system list name=SNMP_AGENT
The state should be enabled. If not use: :service system name=SNMP_AGENT state=enabled
That should be all you need to make SNMP queries from your LAN, assuming that your modem is reachable by network (if not, fix your routing). Harden security if you wish.
e.g. to walk all the modem's public SNMP targets using net-snmp utility: snmp-walk -v1 -c public YOURMODEMIPORHOSTNAME
which should produce a stream of information. It appears that only SNMP version 1 is implemented on my modem. MRTG plays fine with these network targets but I use a short shell script to fetch network data using snmpget and populate a RRDTool database directly. |
|
 brassy join:2004-01-09 Brantford, ON | reply to jvl001 can you post a direct link to d/l these text files or post them so when you copy a # isnt inserted into each line? |
|
 | Do you mean from the code blocks? There is a plain view link at the top right of the code block, that should give you want you're looking for. |
|
|
|
 brassy join:2004-01-09 Brantford, ON | whoops, my bad, script blocker was blocking that from showing up.. thanks.  |
|
 kamal join:2008-04-11 Toronto, ON | reply to jvl001 nice effort. Got few questions, see if you can guide me, I got Cacti running on my web server which monitors various stuff, now do you have this script in PHP so i can use with Cacti? also i am using WRT54GL and my modem is bridged means port 161 needs to be forwarded to 192.168.1.254? my router is on 192.168.10.X range.
thanks  |
|
 TSI GabePremium,VIP join:2007-01-03 Chatham, ON kudos:2 | You don't need PHP to make this work with Cacti although porting that script to PHP would be easy. -- TSI Gabe - TekSavvy Solutions Inc. |
|
 kamal join:2008-04-11 Toronto, ON | any idea how? perhaps steps? thanks |
|
 TSI GabePremium,VIP join:2007-01-03 Chatham, ON kudos:2 | that's a good example.
»docs.cacti.net/?q=node/296 -- TSI Gabe - TekSavvy Solutions Inc. |
|
 jvl001 join:2008-06-09 Mississauga, ON Reviews:
·TekSavvy Cable
·TekSavvy DSL
1 edit | Sorry, I don't have enough experience with PHP so I wouldn't know where to start. Perhaps someone else can port my example to PHP.
The purpose of the first script is simply to poll the modem's stats, parse it and update an RRDtool database file. I expect you could do this with just about any scripting language but Perl seemed to be the easiest way as I didn't have to mess about with interfacing with telnet. Probably could have done it with a bash script and awk if I could figure out a foolproof way of dealing with telnet.
I've heard about Cacti but haven't tried it (the Cacti site is down at the moment for me). I would guess it's probably too much for a Linksys NSLU2 (see »en.wikipedia.org/wiki/NSLU2).
I was only looking for a barebones solution: one script run periodically to update a RRDtool database plus additional CGI scripts to output results on demand. |
|
 jvl001 join:2008-06-09 Mississauga, ON Reviews:
·TekSavvy Cable
·TekSavvy DSL
| reply to kamal To reach the bridge modem at 192.168.1.254 from the network 192.168.10.0/24 you'll need to masquerade access to 192.168.1.254 onto vlan1 on the WRT54GL.
Exactly how depends on what firmware you are running. You can add something like the following to the WRT54GL scripts.
If your vlan1 device doesn't have an IP address than you should give it a static one in the same network range, eg. 192.186.1.1. Routing should then be correct.
If your firmware uses iptables (likely) and you want to reach the modem at 192.168.1.254, then use: iptables -I POSTROUTING -t nat -o vlan1 -d 192.168.1.254/32 -j MASQUERADE
You may also need: iptables -A FORWARD -i br0 -o vlan1 -j ACCEPT if the FORWARD table doesn't already have it.
Try Google for more examples, perhaps specific to your firmware. |
|
 kamal join:2008-04-11 Toronto, ON 1 edit | reply to jvl001 thanks,
i got it working so far, i just need to tweak a little bit, now if anyone can tell me which are the ones used for snr,errors etc
101UpIP: loop OTHER 802.3 THOMSON SpeedTouch 5x6 6.2.16.3IP: loopnot usedother0127.0.0.1
102UpIP: LocalNetwork ETHERNET THOMSON SpeedTouch 5x6 6.2.16.3IP: LocalNetworknot usedethernetCsmacd10000000000:00:D0:00:00:63192.168.1.254
201UpETH: ethport1 THOMSON SpeedTouch 5x6 6.2.16.3ethport1not usedethernetCsmacd10000000000:90:00:00:00:63
301UpBRG: Internet THOMSON SpeedTouch 5x6 6.2.16.3ethernetCsmacd72400000:00:00:00:00:00
401UpAAL5: ATM PORT 4 THOMSON SpeedTouch 5x6 6.2.16.3AAL5not usedaal50
501UpATM: PORT 0 THOMSON SpeedTouch 5x6 6.2.16.3ATM: PORT 0not usedatm5056000
502UpATM: PORT 1 THOMSON SpeedTouch 5x6 6.2.16.3ATM: PORT 1not usedatm8000000
503DownATM: PORT 2 THOMSON SpeedTouch 5x6 6.2.16.3ATM: PORT 2not usedatm25600000
505UpPVIF: ATM PORT 4 THOMSON SpeedTouch 5x6 6.2.16.3PVIF: ATM PORT 4not usedpropVirtual0
506UpPVIF: ATM PORT 5 THOMSON SpeedTouch 5x6 6.2.16.3PVIF: ATM PORT 5not usedpropVirtual0
601UpADSL: LINE THOMSON SpeedTouch 5x6 6.2.16.3adsl601not usedadsl800000
602DownADSL: FAST-CHANNEL THOMSON SpeedTouch 5x6 6.2.16.3adsl602not usedfast0
603UpADSL: INTERLEAVED-CHANNEL THOMSON SpeedTouch 5x6 6.2.16.3adsl603not usedinterleave800000
|
|
 jvl001 join:2008-06-09 Mississauga, ON Reviews:
·TekSavvy Cable
·TekSavvy DSL
1 edit | Sorry if I confused things but the modem's SNMP doesn't provide line stats (as far as I know). You can use SNMP to retrieve network stats though which is the default way that MRTG (and probably Cacti) works.
For network traffic: You'll need to experiment to find which ones are actually used. A number of them appear in the list but only a couple actually count packets. On mine it works out to interface 102 and 103 (e.g. ifInOctets.102 and ifOutOctets.102)
For line stats: As the modem stats aren't available from an SNMP query, I wrote my own script to telnet into the modem, parse the output, and save the results in a RRDtool database, just like MRTG would with SNMP data. I don't think it would be too hard to get Cacti to make use of a script.
Now that I can reach the Cacti web site I see many additional user provided scripts including ones written in Perl. Why not install Perl if you haven't already?
Here's a modified script that should work with Cacti, but you'll need Perl and you'll need the Perl Net::Telnet module. I tested that it prints the correct string but I don't have Cacti installed to test it fully.
#!/usr/bin/perl
#
# Author: Jason Lassaline (jason.lassaline_at_gmail.com)
#
# Retrieve ADSL line stats from SpeedTouch 5x6 modem. Tested on ST516 with
# firmware version 6.2.16.3. Should work on other SpeedTouch modems but may
# need tweaking. If it doesn't work, telnet into the modem and run the command:
# :adsl info expand=enabled
# then check if parsing regex matches your output. Adjust as necessary.
#
# NOTE: Just like other modem utilities, your modem must be reachable from your
# local network. If it is in bridge modem, you'll need to add some routing
# to your router or machine to reach the modem. If you can't telnet into the
# modem then this script won't work!
#
# This script does the following:
# 1/ Telnet into modem and executes adsl info command (see ST5x6 Command
# Reference). Immediately closes telnet connection on retrieval of output.
# 2/ Parses output for specific line stats.
# 3/ Prints the results in a format suitable for use with Cacti
# 4/ Exits.
# You must have the Net::Telnet
use Net::Telnet ();
# Set to your ST5x6 IP address or hostname (if any)
$host = '10.0.0.138';
# Set to your ST5x6 administator user id (Administrator or admin or whatever)
$user = 'admin';
# Set to your ST5x6 administator password (only you know what this is)
$pass = 'mysecret';
$t = new Net::Telnet ( Timeout => 10,
Prompt => '/.*=>$/i',
Errmode => 'die');
# Open host
$t->open($host);
# Login
$t->login($user, $pass);
# Fire off adsl info command
@result = $t->cmd(':adsl info expand=enabled');
# Logout
$t->close();
# May not be necessary
chomp(@result);
# Initialize all outputs as unknown in case parsing fails
$snr_up="U";
$snr_down="U";
$att_up="U";
$att_down="U";
$power_up="U";
$power_down="U";
$fec_up="U";
$fec_down="U";
$crc_up="U";
$crc_down="U";
$hec_up="U";
$hec_down="U";
# Loop over results, parsing expanded adsl info output
while(@result)
{
if (@result[0] =~ /Margin\s+\(dB\)\s+:\s+(\d+.\d+)\s+(\d+.\d+)/)
{
# SNR Margin down/up in dB
$snr_down=$1;
$snr_up=$2;
}
if (@result[0] =~ /Attenuation\s+\(dB\)\s+:\s+(\d+.\d+)\s+(\d+.\d+)/)
{
# Attenuation down/up in dB
$att_down=$1;
$att_up=$2;
}
if (@result[0] =~ /OutputPower\s+\(dBm\)\s+:\s+(\d+.\d+)\s+(\d+.\d+)/)
{
# Output power down/up in dB
$power_down=$1;
$power_up=$2;
}
if (@result[0] =~ /Received FEC\s+:\s+(\d+)/)
{
# Count of FEC errors down
$fec_down=$1;
}
if (@result[0] =~ /Transmitted FEC\s+:\s+(\d+)/)
{
# Count of FEC errors up
$fec_up=$1;
}
if (@result[0] =~ /Received CRC\s+:\s+(\d+)/)
{
# Count of CRC errors down
$crc_down=$1;
}
if (@result[0] =~ /Transmitted CRC\s+:\s+(\d+)/)
{
# Count of CRC errors up
$crc_up=$1;
}
if (@result[0] =~ /Received HEC\s+:\s+(\d+)/)
{
# Count of HEC errors up
$hec_down=$1;
}
if (@result[0] =~ /Transmitted HEC\s+:\s+(\d+)/)
{
# Count of HEC errors down
$hec_up=$1;
}
# Note that there is more information available in the output, such
# as line profile up/down and maximum line up/down bandwidth. Parse
# as you see fit.
shift(@result);
}
# Print out the stats in a Cacti compatible format
print "snru:$snr_up snrd:$snr_down attu:$att_up attd:$att_down powu:$power_up powd:$power_down fecu:$fec_up fecd:$fec_down crcu:$crc_up crcd:$crc_down hecu:$hec_up hecd:$hec_down\n"
PS: I use my modem in Routed PPPoE mode so I get two interfaces with traffic. It looks like your traffic should be available on 102. |
|
 kamal join:2008-04-11 Toronto, ON 1 edit | reply to jvl001 thanks for the script, i am working hard on cacti to see if i can make it graph, but the script is outputting the info properly when ran through ssh
perl speedtouch.pl
snru:6.0 snrd:28.0 attu:23.5 attd:10.0
powu:12.5 powd:7.0 fecu:0 fecd:0 crcu:0
crcd:0 hecu:U hecd:0
above info has all the required one? SNR, Attenuation, Power, HEC, CRC, and FEC errors? or its not pulling all?
will post once i got it working with cacti, if you found step by step, let me know.
I am able to graph network traffic fine using snmp on speedtouch |
|
 jvl001 join:2008-06-09 Mississauga, ON | The numbers you posted look ok, and zero errors is not unusual give that your SNR, attenuation and power numbers all look good.
The HEC up error set to U (or unknown) is odd... perhaps there is a bug in the script for that number. |
|
 kamal join:2008-04-11 Toronto, ON | reply to jvl001 Currently i got the cacti to graph properly, i will post the graph once its full enough, only thing i couldn't get to output is hecu:U since i couldn't get any result for it, can you go through the script see if there is anything can be done? also is it possible to add profile sync stats to this script?
thanks for the script, i wanted to do it for long, finally found the script to do it. you were the author? |
|
 jvl001 join:2008-06-09 Mississauga, ON Reviews:
·TekSavvy Cable
·TekSavvy DSL
1 edit | Yes, I wrote both scripts.
On my modem I get all the outputs so there must be a small difference in the modem output between mine & yours...
It's line 115 in the above script that looks for the string of characters containing the transmitted HEC error count (the comments are up/down reversed by mistake).
Everything between the '/'s in line 115 is a regular expression (regex). It's looking for a pattern of characters that looks like the following:
'Transmitted HEC' : exactly this sequence of characters followed by '\s+' : zero or more spaces followed by ':' : a colon followed by '\s+' : zero or more spaces followed by (\d+) : an integer consisting of one or more digits
Whatever matches '(\d+)' will be stored as variable $1, which is then assigned to $hec_up.
Check your output. You may need to replace the space between 'Transmitted' and 'HEC' with '\s+'.
EDIT: Here's an updated version of the script adjusted to be a bit more forgiving
#!/usr/bin/perl
#
# Author: Jason Lassaline (jason.lassaline_at_gmail.com)
#
# Retrieve ADSL line stats from SpeedTouch 5x6 modem. Tested on ST516 with
# firmware version 6.2.16.3. Should work on other SpeedTouch modems but may
# need tweaking. If it doesn't work, telnet into the modem and run the command:
# :adsl info expand=enabled
# then check if parsing regex matches your output. Adjust as necessary.
#
# NOTE: Just like other modem utilities, your modem must be reachable from your
# local network. If it is in bridge modem, you'll need to add some routing
# to your router or machine to reach the modem. If you can't telnet into the
# modem then this script won't work!
#
# This script does the following:
# 1/ Telnet into modem and executes adsl info command (see ST5x6 Command
# Reference). Immediately closes telnet connection on retrieval of output.
# 2/ Parses output for specific line stats.
# 3/ Prints the results in a format suitable for use with Cacti
# 4/ Exits.
# You must have the Net::Telnet
use Net::Telnet ();
# Set to your ST5x6 IP address or hostname (if any)
$host = '10.0.0.138';
# Set to your ST5x6 administator user id (Administrator or admin or whatever)
$user = 'admin';
# Set to your ST5x6 administator password (only you know what this is)
$pass = 'mysecret';
$t = new Net::Telnet ( Timeout => 10,
Prompt => '/.*=>$/i',
Errmode => 'die');
# Open host
$t->open($host);
# Login
$t->login($user, $pass);
# Fire off adsl info command
@result = $t->cmd(':adsl info expand=enabled');
# Logout
$t->close();
# May not be necessary
chomp(@result);
# Initialize all outputs as unknown in case parsing fails
$snr_up="U";
$snr_down="U";
$att_up="U";
$att_down="U";
$power_up="U";
$power_down="U";
$fec_up="U";
$fec_down="U";
$crc_up="U";
$crc_down="U";
$hec_up="U";
$hec_down="U";
# Loop over results, parsing expanded adsl info output
while(@result)
{
if (@result[0] =~ /Margin\s+\(dB\)\s+:\s+(\d+.\d+)\s+(\d+.\d+)/)
{
# SNR Margin down/up in dB
$snr_down=$1;
$snr_up=$2;
}
if (@result[0] =~ /Attenuation\s+\(dB\)\s+:\s+(\d+.\d+)\s+(\d+.\d+)/)
{
# Attenuation down/up in dB
$att_down=$1;
$att_up=$2;
}
if (@result[0] =~ /OutputPower\s+\(dBm\)\s+:\s+(\d+.\d+)\s+(\d+.\d+)/)
{
# Output power down/up in dB
$power_down=$1;
$power_up=$2;
}
if (@result[0] =~ /Received\s+FEC\s+:\s+(\d+)/)
{
# Count of FEC errors down
$fec_down=$1;
}
if (@result[0] =~ /Transmitted\s+FEC\s+:\s+(\d+)/)
{
# Count of FEC errors up
$fec_up=$1;
}
if (@result[0] =~ /Received\s+CRC\s+:\s+(\d+)/)
{
# Count of CRC errors down
$crc_down=$1;
}
if (@result[0] =~ /Transmitted\s+CRC\s+:\s+(\d+)/)
{
# Count of CRC errors up
$crc_up=$1;
}
if (@result[0] =~ /Received\s+HEC\s+:\s+(\d+)/)
{
# Count of HEC errors down
$hec_down=$1;
}
if (@result[0] =~ /Transmitted\s+HEC\s+:\s+(\d+)/)
{
# Count of HEC errors up
$hec_up=$1;
}
# Note that there is more information available in the output, such
# as line profile up/down and maximum line up/down bandwidth. Parse
# as you see fit.
shift(@result);
}
# Print out the stats in a Cacti compatible format
print "snru:$snr_up snrd:$snr_down attu:$att_up attd:$att_down powu:$power_up powd:$power_down fecu:$fec_up fecd:$fec_down crcu:$crc_up crcd:$crc_down hecu:$hec_up hecd:$hec_down\n"
|
|
 kamal join:2008-04-11 Toronto, ON | reply to jvl001
thanks for the updated script, i tried that still getting hecu:U so i tried the following change i donno if its correct
was from if (@result[0] =~ /Transmitted\s+HEC\s+:\s+(\d+)/) to if (@result[0] =~ /Received\s+HEC\s+:\s+(\d+)/)
now i get hecu:0 hecd:0? is this correct?
Attaching the graphs as well.
why i am not able to get more details as sync from my modem, i am using same modem as yours ST516V6 |
|
 jvl001 join:2008-06-09 Mississauga, ON Reviews:
·TekSavvy Cable
·TekSavvy DSL
| Here's a version which includes the profile kbps up/down and the maximum kbps up/down.
Also, changing Transmitted to Received doesn't do what you want. Both are now set to HEC down values. Please take a look at the output of your modem's 'adsl info expand=enabled' command. You are likely using a different firmware version than I am. If the text doesn't match the regex then it won't work, hence the 'U' in the output.
You'll have to hack it yourself if you want more output.
#!/usr/bin/perl
#
# Author: Jason Lassaline (jason.lassaline_at_gmail.com)
#
# Retrieve ADSL line stats from SpeedTouch 5x6 modem. Tested on ST516 with
# firmware version 6.2.16.3. Should work on other SpeedTouch modems but may
# need tweaking. If it doesn't work, telnet into the modem and run the command:
# :adsl info expand=enabled
# then check if parsing regex matches your output. Adjust as necessary.
#
# NOTE: Just like other modem utilities, your modem must be reachable from your
# local network. If it is in bridge modem, you'll need to add some routing
# to your router or machine to reach the modem. If you can't telnet into the
# modem then this script won't work!
#
# This script does the following:
# 1/ Telnet into modem and executes adsl info command (see ST5x6 Command
# Reference). Immediately closes telnet connection on retrieval of output.
# 2/ Parses output for specific line stats.
# 3/ Prints the results in a format suitable for use with Cacti
# 4/ Exits.
# You must have the Net::Telnet
use Net::Telnet ();
# Set to your ST5x6 IP address or hostname (if any)
$host = '10.0.0.138';
# Set to your ST5x6 administator user id (Administrator or admin or whatever)
$user = 'admin';
# Set to your ST5x6 administator password (only you know what this is)
$pass = 'mysecret';
$t = new Net::Telnet ( Timeout => 10,
Prompt => '/.*=>$/i',
Errmode => 'die');
# Open host
$t->open($host);
# Login
$t->login($user, $pass);
# Fire off adsl info command
@result = $t->cmd(':adsl info expand=enabled');
# Logout
$t->close();
# May not be necessary
chomp(@result);
# Initialize all outputs as unknown in case parsing fails
$snr_up="U";
$snr_down="U";
$att_up="U";
$att_down="U";
$power_up="U";
$power_down="U";
$fec_up="U";
$fec_down="U";
$crc_up="U";
$crc_down="U";
$hec_up="U";
$hec_down="U";
$bw_up="U";
$bw_down="U";
$maxbw_up="U";
$maxbw_down="U";
# Loop over results, parsing expanded adsl info output
while(@result)
{
if (@result[0] =~ /Margin\s+\(dB\)\s+:\s+(\d+.\d+)\s+(\d+.\d+)/)
{
# SNR Margin down/up in dB
$snr_down=$1;
$snr_up=$2;
}
if (@result[0] =~ /Attenuation\s+\(dB\)\s+:\s+(\d+.\d+)\s+(\d+.\d+)/)
{
# Attenuation down/up in dB
$att_down=$1;
$att_up=$2;
}
if (@result[0] =~ /OutputPower\s+\(dBm\)\s+:\s+(\d+.\d+)\s+(\d+.\d+)/)
{
# Output power down/up in dB
$power_down=$1;
$power_up=$2;
}
if (@result[0] =~ /Received\s+FEC\s+:\s+(\d+)/)
{
# Count of FEC errors down
$fec_down=$1;
}
if (@result[0] =~ /Transmitted\s+FEC\s+:\s+(\d+)/)
{
# Count of FEC errors up
$fec_up=$1;
}
if (@result[0] =~ /Received\s+CRC\s+:\s+(\d+)/)
{
# Count of CRC errors down
$crc_down=$1;
}
if (@result[0] =~ /Transmitted\s+CRC\s+:\s+(\d+)/)
{
# Count of CRC errors up
$crc_up=$1;
}
if (@result[0] =~ /Received\s+HEC\s+:\s+(\d+)/)
{
# Count of HEC errors down
$hec_down=$1;
}
if (@result[0] =~ /Transmitted\s+HEC\s+:\s+(\d+)/)
{
# Count of HEC errors up
$hec_up=$1;
}
if (@result[0] =~ /Total\s+Available\s+Bandwidth/)
{
shift(@result);
#Extract profile down/up kbs
if (@result[0] =~ /Downstream\s+:\s+\d+\s+(\d+)/)
{
$bw_down=$1;
shift(@result);
}
if (@result[0] =~ /Upstream\s+:\s+\d+\s+(\d+)/)
{
$bw_up=$1;
}
}
if (@result[0] =~ /Intrinsic\/Actual\s+and\s+Maximum\s+Bandwidth/)
{
shift(@result);
#Extract max profile down/up kbs
if (@result[0] =~ /Downstream\s+:\s+\d+\s+(\d+)/)
{
$maxbw_down=$1;
shift(@result);
}
if (@result[0] =~ /Upstream\s+:\s+\d+\s+(\d+)/)
{
$maxbw_up=$1;
}
}
shift(@result);
}
# Print out the stats in a Cacti compatible format
print "snru:$snr_up snrd:$snr_down attu:$att_up attd:$att_down powu:$power_up powd:$power_down fecu:$fec_up fecd:$fec_down crcu:$crc_up crcd:$crc_down hecu:$hec_up hecd:$hec_down bwu:$bw_up bwd:$bw_down maxu:$maxbw_up maxd:$maxbw_down\n"
|
|