Cable Upstream SNR Viewer in Perl + snmpwalk

Here is where you talk about issues you see in your RF plant.

Cable Upstream SNR Viewer in Perl + snmpwalk

Postby netcrash » Wed Jan 06, 2010 6:43 pm

Currently I'm in a new project ( also new company ) and by that away from CMTS management or config, sometimes friends ask me to code a script or something
and something like this comes up.

Hope it will be usefull for more people. I like DOCSIS I just don't like noise ! :D

Code: Select all
#!/usr/bin/perl
#
# Get CMTS Status from upstream interfaces
#
#    Copyright (C) 2008 Fernando André < netriver at gmail . com >
#   
# This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation; Version 2 of the License
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place, Suite  330, Boston, MA 02111-1307 USA
#
# A copy online can be found at http://www.gnu.org/licenses/gpl-2.0.html
#

sub SnrStatus {
      $walker = '/usr/bin/snmpwalk ';
      $totalOn = 0;
      $totalOff = 0;
      $totalAct = 0;

        ($cmts, $comunity, $style) = @_;

        if ( $style eq 'cisco' ) {
                $mibTerayonSNRUp        = '1.3.6.1.2.1.10.127.1.1.4.1.5';
                $mib = $mibTerayonSNRUp;
        }elsif($style eq 'terayon'){
                $mibCiscoSNRUp          = 'SNMPv2-SMI::transmission.127.1.1.4.1.5';
                $mib = $mibCiscoSNRUp;
        }

        @out = `$walker -v1 -c $comunity $cmts IF-MIB::ifDescr `;

        foreach $i (@out) {
                chomp($i);
                ( $v, $maters) = split(/\./, $i);
                ($id, $descr) = split(/=/, $maters) ;
                $snrt = `$walker -v1 -c $comunity $cmts $mib.$id`;
               ($tmp, $upfreq) = split(/INTEGER: /, `$walker -v1 -c $comunity $cmts 1.3.6.1.2.1.10.127.1.1.2.1.2.$id` );
            if ($upfreq ne ''){
            ($tmp, $channelwidth) = split(/INTEGER: /, `$walker -v1 -c $comunity $cmts 1.3.6.1.2.1.10.127.1.1.2.1.3.$id` );
            ($tmp, $modprofile ) = split(/Gauge32: /, `$walker -v1 -c $comunity $cmts 1.3.6.1.2.1.10.127.1.1.2.1.4.$id` );
            ($tmp, $online) = split(/INTEGER: /, `$walker -v1 -c $comunity $cmts 1.3.6.1.4.1.9.9.116.1.4.1.1.5.$id` );
            ($tmp, $total) = split(/INTEGER: /, `$walker -v1 -c $comunity $cmts 1.3.6.1.4.1.9.9.116.1.4.1.1.3.$id` );
            $offline = $total - $online ;
                chomp($channelwidth, $upfreq, $modprofile, $online, $total);
                $descr =~ s/ +STRING://gi;
                ($tmp, $snr) = split(/INTEGER: /,$snrt);
                $snr = ($snr/10);

  print "CMTS:".$cmts." Descr: ".$descr." = ".($snr)." UPFREQ:".$upfreq." ChannelWidth:".$channelwidth." MODPROFILE: ".$modprofile." Modem Online: ".$online." Modem Offline: ".$offline." Total: ".$total."\n";
               $totalOn = $online + $totalOn;
               $totalOff = $offline + $totalOff;
               $totalAct = $total + $totalAct;
            }
        }

      if ($totalOn > 0 || $totalOff > 0 || $totalAct > 0 ) {
         print "start Report Total do Cmts: $cmts \n";
         print "Total Online: ".$totalOn."\n";
         print "Total Offline: ".$totalOff."\n";
         print "Total Active: ".$totalAct."\n";
         print "end Report Total do Cmts: $cmts \n";
      }

}

print " VXR \n";
SnrStatus('IP OF CMTS', 'COMMUNITY', 'cisco');
# Last parameter should be cisco usually in case of terayon CMTS I have found the second oid to work with terayon ctms
# The snr part works on bigband 12000 but the rest I did not test.

netcrash
Board User
 
Posts: 7
Joined: Thu Sep 04, 2008 6:26 am
Location: Portugal

Re: Cable Upstream SNR Viewer in Perl + snmpwalk

Postby penrodcc » Thu Jan 14, 2010 12:48 pm

Thanks for the script! Just for the other readers of this forum, here is an example output....


Code: Select all

penrod@netmon code]$ ./go
VXR
CMTS:10.252.205.2 Descr:  Cable1/0-upstream0 = 36.1 UPFREQ:29000000 ChannelWidth:3200000 MODPROFILE: 142 Modem Online: 1 Modem Offline: 0 Total: 1
CMTS:10.252.205.2 Descr:  Cable1/0-upstream1 = 36.1 UPFREQ:36000000 ChannelWidth:3200000 MODPROFILE: 142 Modem Online: 1 Modem Offline: 0 Total: 1
CMTS:10.252.205.2 Descr:  Cable1/0-upstream2 = 0 UPFREQ:0 ChannelWidth:1600000 MODPROFILE: 41 Modem Online: 0 Modem Offline: 0 Total: 0
CMTS:10.252.205.2 Descr:  Cable1/0-upstream3 = 0 UPFREQ:0 ChannelWidth:1600000 MODPROFILE: 41 Modem Online: 0 Modem Offline: 0 Total: 0
CMTS:10.252.205.2 Descr:  Cable1/0-upstream4 = 0 UPFREQ:0 ChannelWidth:1600000 MODPROFILE: 41 Modem Online: 0 Modem Offline: 0 Total: 0
CMTS:10.252.205.2 Descr:  Cable1/0-upstream5 = 0 UPFREQ:0 ChannelWidth:1600000 MODPROFILE: 41 Modem Online: 0 Modem Offline: 0 Total: 0
start Report Total do Cmts: 10.252.205.2
Total Online: 2
Total Offline: 0
Total Active: 2
end Report Total do Cmts: 10.252.205.2
[penrod@netmon code]$


penrodcc
Site Admin
 
Posts: 15
Joined: Mon Mar 16, 2009 3:03 pm


Return to RF Help

Who is online

Users browsing this forum: No registered users and 1 guest

cron