|
Packit |
667938 |
#!/usr/drwho/local/bin/perl
|
|
Packit |
667938 |
# -*- mode: Perl -*-
|
|
Packit |
667938 |
##################################################################
|
|
Packit |
667938 |
# Config file creator
|
|
Packit |
667938 |
##################################################################
|
|
Packit |
667938 |
# Created by Tobias Oetiker <oetiker@ee.ethz.ch>
|
|
Packit |
667938 |
# this produces a config file for one router, by bulling info
|
|
Packit |
667938 |
# off the router via snmp
|
|
Packit |
667938 |
#################################################################
|
|
Packit |
667938 |
#
|
|
Packit |
667938 |
# Distributed under the GNU copyleft
|
|
Packit |
667938 |
#
|
|
Packit |
667938 |
# $Id: cfgmaker_atm.pl,v 1.1.1.1 2002/02/26 10:16:31 oetiker Exp $
|
|
Packit |
667938 |
#
|
|
Packit |
667938 |
use SNMP_Session "0.56";
|
|
Packit |
667938 |
use BER "0.54";
|
|
Packit |
667938 |
use Socket;
|
|
Packit |
667938 |
use strict;
|
|
Packit |
667938 |
use vars '$DEBUG';
|
|
Packit |
667938 |
my $DEBUG = 0;
|
|
Packit |
667938 |
|
|
Packit |
667938 |
%snmpget::OIDS = ( 'sysDescr' => '1.3.6.1.2.1.1.1.0',
|
|
Packit |
667938 |
'sysContact' => '1.3.6.1.2.1.1.4.0',
|
|
Packit |
667938 |
'sysName' => '1.3.6.1.2.1.1.5.0',
|
|
Packit |
667938 |
'sysLocation' => '1.3.6.1.2.1.1.6.0',
|
|
Packit |
667938 |
'sysUptime' => '1.3.6.1.2.1.1.3.0',
|
|
Packit |
667938 |
'ifNumber' => '1.3.6.1.2.1.2.1.0',
|
|
Packit |
667938 |
###################################
|
|
Packit |
667938 |
# add the ifNumber ....
|
|
Packit |
667938 |
'ifDescr' => '1.3.6.1.2.1.2.2.1.2',
|
|
Packit |
667938 |
'ifType' => '1.3.6.1.2.1.2.2.1.3',
|
|
Packit |
667938 |
'ifIndex' => '1.3.6.1.2.1.2.2.1.1',
|
|
Packit |
667938 |
'ifSpeed' => '1.3.6.1.2.1.2.2.1.5',
|
|
Packit |
667938 |
'ifOperStatus' => '1.3.6.1.2.1.2.2.1.8',
|
|
Packit |
667938 |
'ifAdminStatus' => '1.3.6.1.2.1.2.2.1.7',
|
|
Packit |
667938 |
# up 1, down 2, testing 3
|
|
Packit |
667938 |
'ipAdEntAddr' => '1.3.6.1.2.1.4.20.1.1',
|
|
Packit |
667938 |
'ipAdEntIfIndex' => '1.3.6.1.2.1.4.20.1.2',
|
|
Packit |
667938 |
'sysObjectID' => '1.3.6.1.2.1.1.2.0',
|
|
Packit |
667938 |
'CiscolocIfDescr' => '1.3.6.1.4.1.9.2.2.1.1.28',
|
|
Packit |
667938 |
'ifAlias' => '1.3.6.1.2.1.31.1.1.1.18',
|
|
Packit |
667938 |
'ifAtmLecConfigEntry' => '1.3.6.1.4.1.18.3.5.9.5.20.1.1.8',
|
|
Packit |
667938 |
'ifAtmLecConfigName' => '1.3.6.1.4.1.18.3.5.9.5.20.1.1.3',
|
|
Packit |
667938 |
'ifAtmVclConfEntry' => '1.3.6.1.4.1.18.3.4.23.1.5.1.22',
|
|
Packit |
667938 |
'ifAtmVclConf2' => '1.3.6.1.4.1.18.3.4.23.1.5.1.2',
|
|
Packit |
667938 |
'ifAtmVclConf3' => '1.3.6.1.4.1.18.3.4.23.1.5.1.4',
|
|
Packit |
667938 |
'ifAtmizerVclStatsEntry' => '1.3.6.1.4.1.18.3.4.23.3.4.1.7',
|
|
Packit |
667938 |
'ifAtmizerVclStatsEntr1' => '1.3.6.1.4.1.18.3.4.23.3.4.1.1',
|
|
Packit |
667938 |
'ifAtmizerVclStatsEntr2' => '1.3.6.1.4.1.18.3.4.23.3.4.1.3',
|
|
Packit |
667938 |
|
|
Packit |
667938 |
|
|
Packit |
667938 |
);
|
|
Packit |
667938 |
|
|
Packit |
667938 |
|
|
Packit |
667938 |
|
|
Packit |
667938 |
sub main {
|
|
Packit |
667938 |
|
|
Packit |
667938 |
|
|
Packit |
667938 |
my(%ifType_d)=('1'=>'Other',
|
|
Packit |
667938 |
'2'=>'regular1822',
|
|
Packit |
667938 |
'3'=>'hdh1822',
|
|
Packit |
667938 |
'4'=>'ddnX25',
|
|
Packit |
667938 |
'5'=>'rfc877x25',
|
|
Packit |
667938 |
'6'=>'ethernetCsmacd',
|
|
Packit |
667938 |
'7'=>'iso88023Csmacd',
|
|
Packit |
667938 |
'8'=>'iso88024TokenBus',
|
|
Packit |
667938 |
'9'=>'iso88025TokenRing',
|
|
Packit |
667938 |
'10'=>'iso88026Man',
|
|
Packit |
667938 |
'11'=>'starLan',
|
|
Packit |
667938 |
'12'=>'proteon10Mbit',
|
|
Packit |
667938 |
'13'=>'proteon80Mbit',
|
|
Packit |
667938 |
'14'=>'hyperchannel',
|
|
Packit |
667938 |
'15'=>'fddi',
|
|
Packit |
667938 |
'16'=>'lapb',
|
|
Packit |
667938 |
'17'=>'sdlc',
|
|
Packit |
667938 |
'18'=>'ds1',
|
|
Packit |
667938 |
'19'=>'e1',
|
|
Packit |
667938 |
'20'=>'basicISDN',
|
|
Packit |
667938 |
'21'=>'primaryISDN',
|
|
Packit |
667938 |
'22'=>'propPointToPointSerial',
|
|
Packit |
667938 |
'23'=>'ppp',
|
|
Packit |
667938 |
'24'=>'softwareLoopback',
|
|
Packit |
667938 |
'25'=>'eon',
|
|
Packit |
667938 |
'26'=>'ethernet-3Mbit',
|
|
Packit |
667938 |
'27'=>'nsip',
|
|
Packit |
667938 |
'28'=>'slip',
|
|
Packit |
667938 |
'29'=>'ultra',
|
|
Packit |
667938 |
'30'=>'ds3',
|
|
Packit |
667938 |
'31'=>'sip',
|
|
Packit |
667938 |
'32'=>'frame-relay',
|
|
Packit |
667938 |
'33'=>'rs232',
|
|
Packit |
667938 |
'34'=>'para',
|
|
Packit |
667938 |
'35'=>'arcnet',
|
|
Packit |
667938 |
'36'=>'arcnetPlus',
|
|
Packit |
667938 |
'37'=>'atm',
|
|
Packit |
667938 |
'38'=>'miox25',
|
|
Packit |
667938 |
'39'=>'sonet',
|
|
Packit |
667938 |
'40'=>'x25ple',
|
|
Packit |
667938 |
'41'=>'iso88022llc',
|
|
Packit |
667938 |
'42'=>'localTalk',
|
|
Packit |
667938 |
'43'=>'smdsDxi',
|
|
Packit |
667938 |
'44'=>'frameRelayService',
|
|
Packit |
667938 |
'45'=>'v35',
|
|
Packit |
667938 |
'46'=>'hssi',
|
|
Packit |
667938 |
'47'=>'hippi',
|
|
Packit |
667938 |
'48'=>'modem',
|
|
Packit |
667938 |
'49'=>'aal5',
|
|
Packit |
667938 |
'50'=>'sonetPath',
|
|
Packit |
667938 |
'51'=>'sonetVT',
|
|
Packit |
667938 |
'52'=>'smdsIcip',
|
|
Packit |
667938 |
'53'=>'propVirtual',
|
|
Packit |
667938 |
'54'=>'propMultiplexor',
|
|
Packit |
667938 |
'55'=>'100BaseVG'
|
|
Packit |
667938 |
);
|
|
Packit |
667938 |
|
|
Packit |
667938 |
my($vendor)=0;
|
|
Packit |
667938 |
if ($ARGV[0] eq '--vendor') {
|
|
Packit |
667938 |
$vendor = 1; shift @ARGV};
|
|
Packit |
667938 |
|
|
Packit |
667938 |
my($community,$router) = split /\@/, $ARGV[0];
|
|
Packit |
667938 |
die <
|
|
Packit |
667938 |
|
|
Packit |
667938 |
USAGE: cfgmaker [--vendor] 'community'\@'router'
|
|
Packit |
667938 |
|
|
Packit |
667938 |
use the --vendor option to try and wrestle some better information
|
|
Packit |
667938 |
from willing livingston and cisco routers ... (may not work)
|
|
Packit |
667938 |
|
|
Packit |
667938 |
EXAMPLE: cfgmaker public\@ezwf7.ethz.ch >>mrtg.cfg
|
|
Packit |
667938 |
|
|
Packit |
667938 |
|
|
Packit |
667938 |
USAGE
|
|
Packit |
667938 |
|
|
Packit |
667938 |
|
|
Packit |
667938 |
|
|
Packit |
667938 |
my($sysDescr,$sysContact,$sysName,$sysLocation,$ifNumber,$sysObjectID) =
|
|
Packit |
667938 |
snmpget($router,$community,
|
|
Packit |
667938 |
'sysDescr','sysContact','sysName', 'sysLocation', 'ifNumber', 'sysObjectID');
|
|
Packit |
667938 |
|
|
Packit |
667938 |
$sysDescr =~ s/\r/ /g; # Change returns to
|
|
Packit |
667938 |
my($cisco_router_sysid) = '1\.3\.6\.1\.4\.1\.9';
|
|
Packit |
667938 |
my($livingston_router_sysid) = '1\.3\.6\.1\.4\.1\.307';
|
|
Packit |
667938 |
my($ciscobox) = ($sysObjectID =~ /^$cisco_router_sysid/);
|
|
Packit |
667938 |
my($portmaster) = ($sysObjectID =~ /^$livingston_router_sysid/);
|
|
Packit |
667938 |
|
|
Packit |
667938 |
print <
|
|
Packit |
667938 |
|
|
Packit |
667938 |
WorkDir: d:\\mrtg\\pub\\www\\stats\\mrtg
|
|
Packit |
667938 |
|
|
Packit |
667938 |
######################################################################
|
|
Packit |
667938 |
# Description: $sysDescr
|
|
Packit |
667938 |
# Contact: $sysContact
|
|
Packit |
667938 |
# System Name: $sysName
|
|
Packit |
667938 |
# Location: $sysLocation
|
|
Packit |
667938 |
#.....................................................................
|
|
Packit |
667938 |
ECHO
|
|
Packit |
667938 |
|
|
Packit |
667938 |
my @ipadent = snmpgettable($router,$community, 'ipAdEntAddr');
|
|
Packit |
667938 |
print "Got Addresses\n" if $DEBUG;
|
|
Packit |
667938 |
my @ipadentif = snmpgettable($router,$community, 'ipAdEntIfIndex');
|
|
Packit |
667938 |
print "Got IfTable\n" if $DEBUG;
|
|
Packit |
667938 |
my @ifatmlec = snmpgettable($router,$community, 'ifAtmLecConfigEntry');
|
|
Packit |
667938 |
print "Got ifAtmLecConfigEntry\n" if $DEBUG;
|
|
Packit |
667938 |
my @ifatmlecName = snmpgettable($router,$community, 'ifAtmLecConfigName');
|
|
Packit |
667938 |
print "Got ifatmlecName\n" if $DEBUG;
|
|
Packit |
667938 |
my @ifatmvcl = snmpgettable($router,$community, 'ifAtmVclConfEntry');
|
|
Packit |
667938 |
print "Got ifAtmVclConfEntry\n" if $DEBUG;
|
|
Packit |
667938 |
my @ifatmpvc = snmpgettable($router,$community, 'ifAtmizerVclStatsEntry');
|
|
Packit |
667938 |
print "Got ifAtmizerVclStatsEntry\n" if $DEBUG;
|
|
Packit |
667938 |
my @ifatmVclConf2 = snmpgettable($router,$community, 'ifAtmVclConf2');
|
|
Packit |
667938 |
print "Got ifAtmVclConf2\n" if $DEBUG;
|
|
Packit |
667938 |
my @ifatmVclConf3 = snmpgettable($router,$community, 'ifAtmVclConf3');
|
|
Packit |
667938 |
print "Got ifAtmVclConf3\n" if $DEBUG;
|
|
Packit |
667938 |
my @ifatmpvc1 = snmpgettable($router,$community, 'ifAtmizerVclStatsEntr1');
|
|
Packit |
667938 |
print "Got ifatmpvc1\n" if $DEBUG;
|
|
Packit |
667938 |
my @ifatmpvc2 = snmpgettable($router,$community, 'ifAtmizerVclStatsEntr2');
|
|
Packit |
667938 |
print "Got ifatmpvc2\n" if $DEBUG;
|
|
Packit |
667938 |
|
|
Packit |
667938 |
|
|
Packit |
667938 |
# get circuit name 'ifAtmVclConf2'
|
|
Packit |
667938 |
# get atm Interface number 'ifAtmVclConf3'
|
|
Packit |
667938 |
# get atm interface -> atm_name 'ifAtmVclConfEntry'
|
|
Packit |
667938 |
|
|
Packit |
667938 |
|
|
Packit |
667938 |
|
|
Packit |
667938 |
my(%ipaddr, %iphost,$index);
|
|
Packit |
667938 |
|
|
Packit |
667938 |
while (scalar @ipadentif){
|
|
Packit |
667938 |
$index = shift @ipadentif;
|
|
Packit |
667938 |
$ipaddr{$index} = shift @ipadent;
|
|
Packit |
667938 |
# $iphost{$index} =
|
|
Packit |
667938 |
# gethostbyaddr(pack('C4',split(/\./,$ipaddr{$index})), AF_INET);
|
|
Packit |
667938 |
# if ($iphost{$index} eq ''){
|
|
Packit |
667938 |
$iphost{$index} = ' ';
|
|
Packit |
667938 |
# }
|
|
Packit |
667938 |
}
|
|
Packit |
667938 |
|
|
Packit |
667938 |
my(@ifdescr) = snmpgettable($router,$community, 'ifDescr');
|
|
Packit |
667938 |
print "Got IfDescr\n" if $DEBUG;
|
|
Packit |
667938 |
my(@iftype) = snmpgettable($router,$community, 'ifType');
|
|
Packit |
667938 |
print "Got IfType\n" if $DEBUG;
|
|
Packit |
667938 |
my(@ifspeed) = snmpgettable($router,$community, 'ifSpeed');
|
|
Packit |
667938 |
print "Got IfSpeed\n" if $DEBUG;
|
|
Packit |
667938 |
my(@ifadminstatus) = snmpgettable($router,$community, 'ifAdminStatus');
|
|
Packit |
667938 |
print "Got IfAdminStatus\n" if $DEBUG;
|
|
Packit |
667938 |
my(@ifoperstatus) = snmpgettable($router,$community, 'ifOperStatus');
|
|
Packit |
667938 |
print "Got IfOperStatus\n" if $DEBUG;
|
|
Packit |
667938 |
my(@ifindex) = snmpgettable($router,$community, 'ifIndex');
|
|
Packit |
667938 |
print "Got IfIndex\n" if $DEBUG;
|
|
Packit |
667938 |
|
|
Packit |
667938 |
my(%sifdesc,%siftype,%sifspeed,%sifadminstatus,%sifoperstatus,%sciscodescr);
|
|
Packit |
667938 |
|
|
Packit |
667938 |
### May need the cisco IOS version number so we know which oid to use
|
|
Packit |
667938 |
### to get the cisco description.
|
|
Packit |
667938 |
###
|
|
Packit |
667938 |
### - mjd 2/5/98 (Mike Diehn) (mdiehn@mindspring.net)
|
|
Packit |
667938 |
###
|
|
Packit |
667938 |
my ($cisco_ver, $cisco_descr_oid, @ciscodescr);
|
|
Packit |
667938 |
my (%atmindex, %atmindex2, %atmCir, %atmindex5, $atmindex2);
|
|
Packit |
667938 |
|
|
Packit |
667938 |
if ( $ciscobox ) {
|
|
Packit |
667938 |
($cisco_ver) = ($sysDescr =~ m/Version\s+([\d.]+)\(\d+\)\w*?,/o);
|
|
Packit |
667938 |
$cisco_descr_oid = ($cisco_ver ge "11.2") ? "ifAlias" : "CiscolocIfDescr";
|
|
Packit |
667938 |
}
|
|
Packit |
667938 |
print "Print from ifatmlecname \n" if $DEBUG;
|
|
Packit |
667938 |
|
|
Packit |
667938 |
while (scalar @ifatmlecName) {
|
|
Packit |
667938 |
$index = shift @ifatmlecName;
|
|
Packit |
667938 |
$sifdesc{$index} = shift @ifatmlec;
|
|
Packit |
667938 |
$siftype{$index} = '';
|
|
Packit |
667938 |
$sifspeed{$index} = '';
|
|
Packit |
667938 |
$sifadminstatus{$index} = '';
|
|
Packit |
667938 |
$sifoperstatus{$index} = '';
|
|
Packit |
667938 |
my $atm_Index = $index;
|
|
Packit |
667938 |
my $name = "$router.$index";
|
|
Packit |
667938 |
my $name2 = "$router.$sifdesc{$index}";
|
|
Packit |
667938 |
|
|
Packit |
667938 |
print "$sifdesc{$index}: '$sifdesc{$index}'\n" if $DEBUG;
|
|
Packit |
667938 |
print "$index: $atm_Index: $name: $name2: $sifdesc{$index}\n" if $DEBUG;
|
|
Packit |
667938 |
|
|
Packit |
667938 |
}
|
|
Packit |
667938 |
my $jet2;
|
|
Packit |
667938 |
|
|
Packit |
667938 |
|
|
Packit |
667938 |
print " sifdesc \n" if $DEBUG;
|
|
Packit |
667938 |
foreach $jet2 (%sifdesc) {
|
|
Packit |
667938 |
print "$jet2 \n" if $DEBUG;
|
|
Packit |
667938 |
}
|
|
Packit |
667938 |
|
|
Packit |
667938 |
|
|
Packit |
667938 |
print "Print from ifatmpvc1 \n" if $DEBUG;
|
|
Packit |
667938 |
|
|
Packit |
667938 |
while (scalar @ifatmpvc2) {
|
|
Packit |
667938 |
$index = shift @ifatmpvc2;
|
|
Packit |
667938 |
$atmindex{$index} = $index;
|
|
Packit |
667938 |
$atmCir{$index} = shift @ifatmpvc1;
|
|
Packit |
667938 |
my $atm_Index_Base = $index;
|
|
Packit |
667938 |
my $atm_Index = $atmindex{$index};
|
|
Packit |
667938 |
my $name = $atmCir{$index};
|
|
Packit |
667938 |
my $atm_index2 = $atmindex2{$index};
|
|
Packit |
667938 |
print "$index: $atm_Index_Base: $atm_Index: $name: $atm_index2\n" if $DEBUG;
|
|
Packit |
667938 |
|
|
Packit |
667938 |
|
|
Packit |
667938 |
print "$index: '$index'\n" if $DEBUG;
|
|
Packit |
667938 |
print "$atmindex{$index}: '$atmindex{$index}'\n" if $DEBUG;
|
|
Packit |
667938 |
print "$atmCir{$index}: '$atmCir{$index}'\n" if $DEBUG;
|
|
Packit |
667938 |
print "$atmindex2{$index}: '$atmindex2{$index}'\n" if $DEBUG;
|
|
Packit |
667938 |
}
|
|
Packit |
667938 |
|
|
Packit |
667938 |
while (scalar @ifatmVclConf3) {
|
|
Packit |
667938 |
$index = shift @ifatmVclConf3;
|
|
Packit |
667938 |
$atmindex2{$index} = shift @ifatmvcl;
|
|
Packit |
667938 |
}
|
|
Packit |
667938 |
print " atmindex \n" if $DEBUG;
|
|
Packit |
667938 |
|
|
Packit |
667938 |
foreach $jet2 (%atmindex) {
|
|
Packit |
667938 |
print "$jet2 \n" if $DEBUG;
|
|
Packit |
667938 |
}
|
|
Packit |
667938 |
|
|
Packit |
667938 |
|
|
Packit |
667938 |
print " atmCir \n" if $DEBUG;
|
|
Packit |
667938 |
foreach $jet2 (%atmCir) {
|
|
Packit |
667938 |
print "$jet2 \n" if $DEBUG;
|
|
Packit |
667938 |
}
|
|
Packit |
667938 |
|
|
Packit |
667938 |
print " atmindex2 \n" if $DEBUG;
|
|
Packit |
667938 |
foreach $jet2 (%atmindex2) {
|
|
Packit |
667938 |
print "$jet2 \n" if $DEBUG;
|
|
Packit |
667938 |
}
|
|
Packit |
667938 |
|
|
Packit |
667938 |
|
|
Packit |
667938 |
print "Print from ifatmVclconf3 \n" if $DEBUG;
|
|
Packit |
667938 |
|
|
Packit |
667938 |
|
|
Packit |
667938 |
|
|
Packit |
667938 |
while (scalar @ifindex) {
|
|
Packit |
667938 |
|
|
Packit |
667938 |
# as these arrays get filled from the bottom,
|
|
Packit |
667938 |
# we need to empty them from the botom as well ...
|
|
Packit |
667938 |
# fifo
|
|
Packit |
667938 |
|
|
Packit |
667938 |
$index = shift @ifindex;
|
|
Packit |
667938 |
$sifdesc{$index} = shift @ifdescr;
|
|
Packit |
667938 |
$siftype{$index} = shift @iftype;
|
|
Packit |
667938 |
$sifspeed{$index} = shift @ifspeed;
|
|
Packit |
667938 |
$sifadminstatus{$index} = shift @ifadminstatus;
|
|
Packit |
667938 |
$sifoperstatus{$index} = shift @ifoperstatus;
|
|
Packit |
667938 |
|
|
Packit |
667938 |
if ($portmaster && $vendor) {
|
|
Packit |
667938 |
|
|
Packit |
667938 |
# We can only approximate speeds
|
|
Packit |
667938 |
#
|
|
Packit |
667938 |
# so we think that ppp can do 76800 bit/s, and slip 38400.
|
|
Packit |
667938 |
# (actualy, slip is a bit faster, but usualy users with newer modems
|
|
Packit |
667938 |
# use ppp). Alternatively, you can set async speed to 115200 or
|
|
Packit |
667938 |
# 230400 (the maximum speed supported by portmaster).
|
|
Packit |
667938 |
#
|
|
Packit |
667938 |
# But if the interface is ptpW (sync), max speed is 128000
|
|
Packit |
667938 |
# change it to your needs. On various Portmasters there are
|
|
Packit |
667938 |
# various numbers of sync interfaces, so modify it.
|
|
Packit |
667938 |
#
|
|
Packit |
667938 |
# The most commonly used PM-2ER has only one sync.
|
|
Packit |
667938 |
#
|
|
Packit |
667938 |
# Paul Makeev (mac@redline.ru)
|
|
Packit |
667938 |
#
|
|
Packit |
667938 |
|
|
Packit |
667938 |
if ($siftype{$index} eq '23') {
|
|
Packit |
667938 |
if ($sifdesc{$index} eq 'ptpW1') {
|
|
Packit |
667938 |
$sifspeed{$index} = 128000;
|
|
Packit |
667938 |
} else {
|
|
Packit |
667938 |
$sifspeed{$index} = 76800;
|
|
Packit |
667938 |
}
|
|
Packit |
667938 |
} elsif ($siftype{$index} eq '28') {
|
|
Packit |
667938 |
$sifspeed{$index} = 38400;
|
|
Packit |
667938 |
} elsif ($siftype{$index} eq '6') {
|
|
Packit |
667938 |
$sifspeed{$index} = 10000000;
|
|
Packit |
667938 |
}
|
|
Packit |
667938 |
}
|
|
Packit |
667938 |
|
|
Packit |
667938 |
### Move this section south so we know what type of
|
|
Packit |
667938 |
### circuit we're looking at before we retrieve
|
|
Packit |
667938 |
### the cisco interface alias.
|
|
Packit |
667938 |
###
|
|
Packit |
667938 |
### This whole cicso thing should be re-written, but since
|
|
Packit |
667938 |
### this script doesn't need to run quickly...
|
|
Packit |
667938 |
###
|
|
Packit |
667938 |
### - mjd 2/5/98
|
|
Packit |
667938 |
###
|
|
Packit |
667938 |
# Get the user configurable interface description entered in the config
|
|
Packit |
667938 |
# if it's a cisco-box
|
|
Packit |
667938 |
#
|
|
Packit |
667938 |
if ($ciscobox && $vendor) {
|
|
Packit |
667938 |
|
|
Packit |
667938 |
my ($enoid, @descr);
|
|
Packit |
667938 |
|
|
Packit |
667938 |
$enoid = $snmpget::OIDS{"$cisco_descr_oid"} . "." . $index;
|
|
Packit |
667938 |
|
|
Packit |
667938 |
if ( $cisco_ver ge "11.2" or $siftype{$index} != '32' ) {
|
|
Packit |
667938 |
|
|
Packit |
667938 |
### This is either not a frame-relay sub-interface or
|
|
Packit |
667938 |
### this router is running IOS 11.2+ and interface
|
|
Packit |
667938 |
### type won't matter. In either of these cases, it's
|
|
Packit |
667938 |
### ok to try getting the ifAlias or ciscoLocIfDesc.
|
|
Packit |
667938 |
###
|
|
Packit |
667938 |
@descr = snmpget($router,$community, $enoid);
|
|
Packit |
667938 |
|
|
Packit |
667938 |
} else {
|
|
Packit |
667938 |
|
|
Packit |
667938 |
### This is a frame-relay sub-interface *and* the router
|
|
Packit |
667938 |
### is running an IOS older than 11.2. Therefore, we can
|
|
Packit |
667938 |
### get neither ifAlias nor ciscoLocIfDesc. Do something
|
|
Packit |
667938 |
### useful.
|
|
Packit |
667938 |
###
|
|
Packit |
667938 |
@descr = ("Cisco PVCs descriptions require IOS 11.2+.");
|
|
Packit |
667938 |
|
|
Packit |
667938 |
} # end if else
|
|
Packit |
667938 |
|
|
Packit |
667938 |
### Put whatever I got into the array we'll use later to append the result
|
|
Packit |
667938 |
### of this operation onto the results from the ifDescr fetch.
|
|
Packit |
667938 |
###
|
|
Packit |
667938 |
push @ciscodescr, shift @descr;
|
|
Packit |
667938 |
|
|
Packit |
667938 |
} # end if ($cisco_box && $vendor)
|
|
Packit |
667938 |
|
|
Packit |
667938 |
# especially since cisco does not return a if
|
|
Packit |
667938 |
# descr for each interface it has ...
|
|
Packit |
667938 |
## JB 2/8/97 - sometimes IOS inserts E1 controllers in the standard-MIB
|
|
Packit |
667938 |
## interface table, but not in the local interface table. This puts the
|
|
Packit |
667938 |
## local interface description table out-of-sync. the following
|
|
Packit |
667938 |
## modification skips over E1 cards as interfaces.
|
|
Packit |
667938 |
#
|
|
Packit |
667938 |
### I suspect that the mod I made above, to use the ifAlias
|
|
Packit |
667938 |
### oid if possible, may cause problems here. If it seems
|
|
Packit |
667938 |
### that your descriptions are out of sync, try commenting
|
|
Packit |
667938 |
### out the "if ( condition )" and it's closing right brace
|
|
Packit |
667938 |
### so that the "shift @ciscodescr" get executed for *all*
|
|
Packit |
667938 |
### iterations of this loop.
|
|
Packit |
667938 |
###
|
|
Packit |
667938 |
### - mjd 2/5/95
|
|
Packit |
667938 |
###
|
|
Packit |
667938 |
if ($ciscobox && $siftype{$index} != 18) {
|
|
Packit |
667938 |
$sciscodescr{$index} = " " . (shift @ciscodescr) if @ciscodescr;
|
|
Packit |
667938 |
}
|
|
Packit |
667938 |
}
|
|
Packit |
667938 |
|
|
Packit |
667938 |
my $jet;
|
|
Packit |
667938 |
print " atmindex2 \n" if $DEBUG;
|
|
Packit |
667938 |
|
|
Packit |
667938 |
foreach $jet (%atmindex2) {
|
|
Packit |
667938 |
print "$jet \n" if $DEBUG;
|
|
Packit |
667938 |
}
|
|
Packit |
667938 |
|
|
Packit |
667938 |
print " sifdesc \n" if $DEBUG;
|
|
Packit |
667938 |
foreach $jet (%sifdesc) {
|
|
Packit |
667938 |
print "$jet \n" if $DEBUG;
|
|
Packit |
667938 |
}
|
|
Packit |
667938 |
|
|
Packit |
667938 |
print " atmCir \n" if $DEBUG;
|
|
Packit |
667938 |
foreach $jet (%atmCir) {
|
|
Packit |
667938 |
print "$jet \n" if $DEBUG;
|
|
Packit |
667938 |
}
|
|
Packit |
667938 |
|
|
Packit |
667938 |
print " atmindex \n" if $DEBUG;
|
|
Packit |
667938 |
foreach $jet (%atmindex) {
|
|
Packit |
667938 |
print "$jet \n" if $DEBUG;
|
|
Packit |
667938 |
}
|
|
Packit |
667938 |
|
|
Packit |
667938 |
print " Possible Targets \n" if $DEBUG;
|
|
Packit |
667938 |
|
|
Packit |
667938 |
foreach $index ( sort { $atmindex2{$a} <=> $atmindex2{$b} } keys %atmindex2) {
|
|
Packit |
667938 |
my $c;
|
|
Packit |
667938 |
my $index2 = $atmindex2{$index};
|
|
Packit |
667938 |
# my $name = "$router.$sifdesc{$index2}.$atmindex2{$index}.$index";
|
|
Packit |
667938 |
my $name = "$router.$index2.$index";
|
|
Packit |
667938 |
my $target1 = "1.3.6.1.4.1.18.3.4.23.3.4.1.7.$atmCir{$index}.0.$index";
|
|
Packit |
667938 |
my $target2 = "1.3.6.1.4.1.18.3.4.23.3.4.1.21.$atmCir{$index}.0.$index";
|
|
Packit |
667938 |
|
|
Packit |
667938 |
print "$index: $index2: $name: $target1: $target2: \n" if $DEBUG;
|
|
Packit |
667938 |
|
|
Packit |
667938 |
$c = '';
|
|
Packit |
667938 |
|
|
Packit |
667938 |
print <
|
|
Packit |
667938 |
${c}
|
|
Packit |
667938 |
${c}Target[$name]: $target1&$target2:$community\@$router * 53
|
|
Packit |
667938 |
${c}MaxBytes[$name]: 19400000
|
|
Packit |
667938 |
${c}Title[$name]: $sysName ($iphost{$index}): $index2 <- $index $sifdesc{$index2}
|
|
Packit |
667938 |
${c}PageTop[$name]: Traffic Analysis for $index2 <- $index $sifdesc{$index2}
|
|
Packit |
667938 |
${c} $sciscodescr{$index}
|
|
Packit |
667938 |
${c}
|
|
Packit |
667938 |
${c} System:$sysName in $sysLocation
|
|
Packit |
667938 |
${c} Maintainer:$sysContact
|
|
Packit |
667938 |
${c} Interface:$sifdesc{$index} ($index)
|
|
Packit |
667938 |
${c} IP:$iphost{$index} ($ipaddr{$index})
|
|
Packit |
667938 |
${c} Max Speed:
|
|
Packit |
667938 |
${c} 19.4MB ($ifType_d{$siftype{$index}})
|
|
Packit |
667938 |
${c}
|
|
Packit |
667938 |
${c}
|
|
Packit |
667938 |
#---------------------------------------------------------------
|
|
Packit |
667938 |
ECHO
|
|
Packit |
667938 |
}
|
|
Packit |
667938 |
}
|
|
Packit |
667938 |
|
|
Packit |
667938 |
main;
|
|
Packit |
667938 |
exit(0);
|
|
Packit |
667938 |
|
|
Packit |
667938 |
sub snmpget{
|
|
Packit |
667938 |
my($host,$community,@vars) = @_;
|
|
Packit |
667938 |
my(@enoid, $var,$response, $bindings, $binding, $value, $inoid,$outoid,
|
|
Packit |
667938 |
$upoid,$oid,@retvals);
|
|
Packit |
667938 |
my($hackcisco);
|
|
Packit |
667938 |
foreach $var (@vars) {
|
|
Packit |
667938 |
die "Unknown SNMP var $var\n"
|
|
Packit |
667938 |
unless $snmpget::OIDS{$var} || $var =~ /^\d+[\.\d+]*\.\d+$/;
|
|
Packit |
667938 |
if ($var =~ /^\d+[\.\d+]*\.\d+/) {
|
|
Packit |
667938 |
push @enoid, encode_oid((split /\./, $var));
|
|
Packit |
667938 |
$hackcisco = 1;
|
|
Packit |
667938 |
} else {
|
|
Packit |
667938 |
push @enoid, encode_oid((split /\./, $snmpget::OIDS{$var}));
|
|
Packit |
667938 |
$hackcisco = 0;
|
|
Packit |
667938 |
}
|
|
Packit |
667938 |
}
|
|
Packit |
667938 |
srand();
|
|
Packit |
667938 |
my $session = SNMP_Session->open ($host ,
|
|
Packit |
667938 |
$community,
|
|
Packit |
667938 |
161);
|
|
Packit |
667938 |
if ($session->get_request_response(@enoid)) {
|
|
Packit |
667938 |
$response = $session->pdu_buffer;
|
|
Packit |
667938 |
($bindings) = $session->decode_get_response ($response);
|
|
Packit |
667938 |
$session->close ();
|
|
Packit |
667938 |
while ($bindings) {
|
|
Packit |
667938 |
($binding,$bindings) = decode_sequence ($bindings);
|
|
Packit |
667938 |
($oid,$value) = decode_by_template ($binding, "%O%@");
|
|
Packit |
667938 |
my $tempo = pretty_print($value);
|
|
Packit |
667938 |
$tempo=~s/\t/ /g;
|
|
Packit |
667938 |
$tempo=~s/\n/ /g;
|
|
Packit |
667938 |
$tempo=~s/^\s+//;
|
|
Packit |
667938 |
$tempo=~s/\s+$//;
|
|
Packit |
667938 |
|
|
Packit |
667938 |
push @retvals, $tempo;
|
|
Packit |
667938 |
}
|
|
Packit |
667938 |
|
|
Packit |
667938 |
return (@retvals);
|
|
Packit |
667938 |
} else {
|
|
Packit |
667938 |
if ($hackcisco) {
|
|
Packit |
667938 |
return ("");
|
|
Packit |
667938 |
} else {
|
|
Packit |
667938 |
die "No answer from $ARGV[0]. You may be using the wrong community\n";
|
|
Packit |
667938 |
}
|
|
Packit |
667938 |
}
|
|
Packit |
667938 |
}
|
|
Packit |
667938 |
|
|
Packit |
667938 |
sub snmpgettable{
|
|
Packit |
667938 |
my($host,$community,$var) = @_;
|
|
Packit |
667938 |
my($next_oid,$enoid,$orig_oid,
|
|
Packit |
667938 |
$response, $bindings, $binding, $value, $inoid,$outoid,
|
|
Packit |
667938 |
$upoid,$oid,@table,$tempo);
|
|
Packit |
667938 |
die "Unknown SNMP var $var\n"
|
|
Packit |
667938 |
unless $snmpget::OIDS{$var};
|
|
Packit |
667938 |
|
|
Packit |
667938 |
$orig_oid = encode_oid(split /\./, $snmpget::OIDS{$var});
|
|
Packit |
667938 |
$enoid=$orig_oid;
|
|
Packit |
667938 |
srand();
|
|
Packit |
667938 |
my $session = SNMP_Session->open ($host ,
|
|
Packit |
667938 |
$community,
|
|
Packit |
667938 |
161);
|
|
Packit |
667938 |
for(;;) {
|
|
Packit |
667938 |
if ($session->getnext_request_response(($enoid))) {
|
|
Packit |
667938 |
$response = $session->pdu_buffer;
|
|
Packit |
667938 |
($bindings) = $session->decode_get_response ($response);
|
|
Packit |
667938 |
($binding,$bindings) = decode_sequence ($bindings);
|
|
Packit |
667938 |
($next_oid,$value) = decode_by_template ($binding, "%O%@");
|
|
Packit |
667938 |
# quit once we are outside the table
|
|
Packit |
667938 |
last unless BER::encoded_oid_prefix_p($orig_oid,$next_oid);
|
|
Packit |
667938 |
$tempo = pretty_print($value);
|
|
Packit |
667938 |
print "$var: '$tempo'\n" if $DEBUG;
|
|
Packit |
667938 |
|
|
Packit |
667938 |
$tempo=~s/\t/ /g;
|
|
Packit |
667938 |
$tempo=~s/\n/ /g;
|
|
Packit |
667938 |
$tempo=~s/^\s+//;
|
|
Packit |
667938 |
$tempo=~s/\s+$//;
|
|
Packit |
667938 |
push @table, $tempo;
|
|
Packit |
667938 |
|
|
Packit |
667938 |
} else {
|
|
Packit |
667938 |
warn "No sensible answer from $ARGV[0] for $var ... results may be wrong!\n";
|
|
Packit |
667938 |
last;
|
|
Packit |
667938 |
}
|
|
Packit |
667938 |
$enoid=$next_oid;
|
|
Packit |
667938 |
}
|
|
Packit |
667938 |
$session->close ();
|
|
Packit |
667938 |
return (@table);
|
|
Packit |
667938 |
}
|
|
Packit |
667938 |
|
|
Packit |
667938 |
sub fmi {
|
|
Packit |
667938 |
my($number) = $_[0];
|
|
Packit |
667938 |
my(@short);
|
|
Packit |
667938 |
@short = ("Bytes/s","kBytes/s","MBytes/s","GBytes/s");
|
|
Packit |
667938 |
my $digits=length("".$number);
|
|
Packit |
667938 |
my $divm=0;
|
|
Packit |
667938 |
while ($digits-$divm*3 > 4) { $divm++; }
|
|
Packit |
667938 |
my $divnum = $number/10**($divm*3);
|
|
Packit |
667938 |
return sprintf("%1.1f %s",$divnum,$short[$divm]);
|
|
Packit |
667938 |
}
|
|
Packit |
667938 |
|
|
Packit |
667938 |
|