Blame contrib/cfgmaker_cisco/cfgmaker.cisco

Packit 667938
#! /pkg/gnu/bin/perl
Packit 667938
# -*- mode: Perl -*-
Packit 667938
##################################################################
Packit 667938
# MRTG 2.7.2  -- 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
use BER "0.57";
Packit 667938
use SNMP_Session "0.59";
Packit 667938
use SNMP_util "0.57";
Packit 667938

Packit 667938
use Socket;
Packit 667938
use strict;
Packit 667938
use vars '$DEBUG';
Packit 667938
my $DEBUG = 0;
Packit 667938

Packit 667938
my ($session, %ipaddr, %iphost);
Packit 667938

Packit 667938
sub main {
Packit 667938

Packit 667938
    snmpmapOID('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

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
                 #### New IF Types added 9/24/98 by Russ Carleton (roccor@livenetworking.com)
Packit 667938
                 #### based on the IANA file updated at ftp://ftp.isi.edu/mib/ianaiftype.mib
Packit 667938
                 '56'=>'Fibre Channel',
Packit 667938
                 '57'=>'HIPPI Interface',
Packit 667938
                 '58'=>'Obsolete for FrameRelay',
Packit 667938
                 '59'=>'ATM Emulation of 802.3 LAN',
Packit 667938
                 '60'=>'ATM Emulation of 802.5 LAN',
Packit 667938
                 '61'=>'ATM Emulation of a Circuit',
Packit 667938
                 '62'=>'FastEthernet (100BaseT)',
Packit 667938
                 '63'=>'ISDN & X.25',
Packit 667938
                 '64'=>'CCITT V.11/X.21',
Packit 667938
                 '65'=>'CCITT V.36',
Packit 667938
                 '66'=>'CCITT G703 at 64Kbps',
Packit 667938
                 '67'=>'Obsolete G702 see DS1-MIB',
Packit 667938
                 '68'=>'SNA QLLC',
Packit 667938
                 '69'=>'Full Duplex Fast Ethernet (100BaseFX)',
Packit 667938
                 '70'=>'Channel',
Packit 667938
                 '71'=>'Radio Spread Spectrum (802.11)',
Packit 667938
                 '72'=>'IBM System 360/370 OEMI Channel',
Packit 667938
                 '73'=>'IBM Enterprise Systems Connection',
Packit 667938
                 '74'=>'Data Link Switching',
Packit 667938
                 '75'=>'ISDN S/T Interface',
Packit 667938
                 '76'=>'ISDN U Interface',
Packit 667938
                 '77'=>'Link Access Protocol D (LAPD)',
Packit 667938
                 '78'=>'IP Switching Opjects',
Packit 667938
                 '79'=>'Remote Source Route Bridging',
Packit 667938
                 '80'=>'ATM Logical Port',
Packit 667938
                 '81'=>'AT&T DS0 Point (64 Kbps)',
Packit 667938
                 '82'=>'AT&T Group of DS0 on a single DS1',
Packit 667938
                 '83'=>'BiSync Protocol (BSC)',
Packit 667938
                 '84'=>'Asynchronous Protocol',
Packit 667938
                 '85'=>'Combat Net Radio',
Packit 667938
                 '86'=>'ISO 802.5r DTR',
Packit 667938
                 '87'=>'Ext Pos Loc Report Sys',
Packit 667938
                 '88'=>'Apple Talk Remote Access Protocol',
Packit 667938
                 '89'=>'Proprietary Connectionless Protocol',
Packit 667938
                 '90'=>'CCITT-ITU X.29 PAD Protocol',
Packit 667938
                 '91'=>'CCITT-ITU X.3 PAD Facility',
Packit 667938
                 '92'=>'MultiProtocol Connection over Frame/Relay',
Packit 667938
                 '93'=>'CCITT-ITU X213',
Packit 667938
                 '94'=>'Asymetric Digitial Subscriber Loop (ADSL)',
Packit 667938
                 '95'=>'Rate-Adapt Digital Subscriber Loop (RDSL)',
Packit 667938
                 '96'=>'Symetric Digitial Subscriber Loop (SDSL)',
Packit 667938
                 '97'=>'Very High Speed Digitial Subscriber Loop (HDSL)',
Packit 667938
                 '98'=>'ISO 802.5 CRFP',
Packit 667938
                 '99'=>'Myricom Myrinet',
Packit 667938
                 '100'=>'Voice recEive and transMit (voiceEM)',
Packit 667938
                 '101'=>'Voice Foreign eXchange Office (voiceFXO)',
Packit 667938
                 '102'=>'Voice Foreign eXchange Station (voiceFXS)',
Packit 667938
                 '103'=>'Voice Encapulation',
Packit 667938
                 '104'=>'Voice Over IP Encapulation',
Packit 667938
                 '105'=>'ATM DXI',
Packit 667938
                 '106'=>'ATM FUNI',
Packit 667938
                 '107'=>'ATM IMA',
Packit 667938
                 '108'=>'PPP Multilink Bundle',
Packit 667938
                 '109'=>'IBM IP over CDLC',
Packit 667938
                 '110'=>'IBM Common Link Access to Workstation',
Packit 667938
                 '111'=>'IBM Stack to Stack',
Packit 667938
                 '112'=>'IBM Virtual IP Address (VIPA)',
Packit 667938
                 '113'=>'IBM Multi-Protocol Channel Support',
Packit 667938
                 '114'=>'IBM IP over ATM',
Packit 667938
                 '115'=>'ISO 802.5j Fiber Token Ring',
Packit 667938
                 '116'=>'IBM Twinaxial Data Link Control (TDLC)',
Packit 667938
                 '117'=>'Gigabit Ethernet',
Packit 667938
                 '118'=>'Higher Data Link Control (HDLC)',
Packit 667938
                 '119'=>'Link Access Protocol F (LAPF)',
Packit 667938
                 '120'=>'CCITT V.37',
Packit 667938
                 '121'=>'CCITT X.25 Multi-Link Protocol',
Packit 667938
                 '122'=>'CCITT X.25 Hunt Group',
Packit 667938
                 '123'=>'Transp HDLC',
Packit 667938
                 '124'=>'Interleave Channel',
Packit 667938
                 '125'=>'Fast Channel',
Packit 667938
                 '126'=>'IP (for APPN HPR in IP Networks)',
Packit 667938
                 '127'=>'CATV MAC Layer',
Packit 667938
                 '128'=>'CATV Downstream Interface',
Packit 667938
                 '129'=>'CATV Upstream Interface',
Packit 667938
                 '130'=>'Avalon Parallel Processor',
Packit 667938
                 '131'=>'Encapsulation Interface',
Packit 667938
                 '132'=>'Coffee Pot',
Packit 667938
                 '133'=>'Circuit Emulation Service',
Packit 667938
                 '134'=>'ATM Sub Interface',
Packit 667938
                 '135'=>'Layer 2 Virtual LAN using 802.1Q',
Packit 667938
                 '136'=>'Layer 3 Virtual LAN using IP',
Packit 667938
                 '137'=>'Layer 3 Virtual LAN using IPX',
Packit 667938
                 '138'=>'IP Over Power Lines',
Packit 667938
                 '139'=>'Multi-Media Mail over IP',
Packit 667938
                 '140'=>'Dynamic synchronous Transfer Mode (DTM)',
Packit 667938
                 '141'=>'Data Communications Network',
Packit 667938
                 '142'=>'IP Forwarding Interface'
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) = ($1,$2) if $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
  print "# Add a WorkDir: /some/path line to this file\n\n";
Packit 667938

Packit 667938
    $session = SNMP_Session->open ($router, $community, 161)
Packit 667938
	|| die "Error opening SNMP session to $router";
Packit 667938
  
Packit 667938
  my($sysDescr,$sysContact,$sysName,$sysLocation,$ifNumber,$sysObjectID) =
Packit 667938
    snmpget("$community\@$router",
Packit 667938
	    'sysDescr','sysContact','sysName',	'sysLocation', 'ifNumber', 'sysObjectID');
Packit 667938

Packit 667938
   $sysDescr =~ s/\r\n?/
/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: /pkg/mon/www/mrtg/
Packit 667938
Refresh: 300
Packit 667938
Interval: 5
Packit 667938
WriteExpires: yes 
Packit 667938

Packit 667938
#Global Modifications:
Packit 667938
Unscaled[_]: ymwd
Packit 667938
Options[_]: bits,growright
Packit 667938
YLegend[_]: Bits Per Second
Packit 667938
ShortLegend[_]: b/s
Packit 667938
LegendI[_]:  Bits/s:
Packit 667938
LegendO[_]:  Bits/s: 
Packit 667938

Packit 667938
#################################################################
Packit 667938
#    Location: $sysLocation
Packit 667938
#     Contact: $sysContact
Packit 667938
# System Name: $sysName
Packit 667938
#
Packit 667938
# System Description including Software and Hardware Versions.
Packit 667938
#
Packit 667938
# $sysDescr
Packit 667938
#################################################################
Packit 667938
# Modified Mrtg cfgmaker Configuration file for SMNP Equipment
Packit 667938
# Last edited - 1999, Mar 31th, revision 2.0
Packit 667938
# Edited By   - mpburton (mpburton\@europa.com)
Packit 667938
# Time        - 11:10 pm
Packit 667938
# Created By  - Jlatimer (J.Latimer\@sussex.ac.uk)  
Packit 667938
################################################################# 
Packit 667938
#---------------------------------------------------------------  
Packit 667938
ECHO
Packit 667938

Packit 667938
  $session->map_table ([[1,3,6,1,2,1,4,20,1,1],	# ipAdEntAddr
Packit 667938
			[1,3,6,1,2,1,4,20,1,2]], # ipAdEntIf
Packit 667938
		       sub ($@) {
Packit 667938
			   my ($index, $ipadentaddr, $ipadentif) = @_;
Packit 667938
			   grep (defined $_ && ($_=pretty_print $_),
Packit 667938
				 ($ipadentif, $ipadentaddr));
Packit 667938
			   $ipaddr{$ipadentif} = $ipadentaddr;
Packit 667938
			   $iphost{$ipadentif} = 
Packit 667938
			       gethostbyaddr(pack('C4',split(/\./,$ipaddr{$ipadentif})), AF_INET);
Packit 667938
			   if (!defined $iphost{$ipadentif} || ($iphost{$ipadentif} eq '')){
Packit 667938
			       $iphost{$ipadentif} = 'No hostname defined for IP address';
Packit 667938
			   }
Packit 667938
		       });
Packit 667938

Packit 667938
  print STDERR "Got Addresses\n" if $DEBUG;
Packit 667938
  print STDERR "Got IfTable\n" if $DEBUG;
Packit 667938

Packit 667938
  my(%sifdesc,%siftype,%sifspeed,%sifadminstatus,%sifoperstatus,%sciscodescr,%sifrawdesc);
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
  if ( $ciscobox ) {
Packit 667938
    ($cisco_ver) = ($sysDescr =~ m/Version\s+([\d\.]+)\(\d/o);
Packit 667938
    $cisco_descr_oid = ($cisco_ver ge "11.2") ? "ifAlias" : "CiscolocIfDescr";
Packit 667938
  }
Packit 667938

Packit 667938

Packit 667938
#mod by jon: create a hash table to map ifIndex integers to module/port names:
Packit 667938
my $cat5500 = 0;
Packit 667938
if ( $sysDescr =~ /WS-C55.*/i ) {
Packit 667938
  $cat5500 = 1;
Packit 667938
}
Packit 667938

Packit 667938
my (%iftomp, %iftovlan);
Packit 667938
if ($cat5500) {
Packit 667938

Packit 667938
$session->map_table ([[1,3,6,1,4,1,9,5,1,4,1,1,11]],	#5500 port group
Packit 667938

Packit 667938
sub ($@) {
Packit 667938
  my ($rowindex, $index) = @_;
Packit 667938
  grep (defined $_ && ($_=pretty_print $_),
Packit 667938
	($index));
Packit 667938

Packit 667938
#  $rowindex =~ s/\./\//g;
Packit 667938
  $iftomp{$index} = $rowindex;
Packit 667938
#  print "row:$rowindex; idx:$index";
Packit 667938
#  print "\n\n";
Packit 667938
});
Packit 667938

Packit 667938
#foreach my $key (sort(keys %iftomp)) {
Packit 667938
#  print $key, '=', $iftomp{$key}, "\n";
Packit 667938
#}
Packit 667938

Packit 667938

Packit 667938
$session->map_table ([[1,3,6,1,4,1,9,5,1,9,3,1,3]],
Packit 667938

Packit 667938
sub ($@) {
Packit 667938
  my ($rowindex, $vlan_no) = @_;
Packit 667938
  grep (defined $_ && ($_=pretty_print $_),
Packit 667938
        ($vlan_no));
Packit 667938

Packit 667938
  my $ifindex;
Packit 667938
  foreach my $key (keys %iftomp) {
Packit 667938
    if ($iftomp{$key} eq $rowindex) {
Packit 667938
      $ifindex = $key;
Packit 667938
    }
Packit 667938
  }
Packit 667938
  $iftovlan{$ifindex} = $vlan_no;
Packit 667938

Packit 667938
});
Packit 667938

Packit 667938
#foreach my $key (sort(keys %iftovlan)) {   
Packit 667938
#  print $key, '=', $iftovlan{$key}, "\n";
Packit 667938
#}
Packit 667938
} #end if cat5500
Packit 667938

Packit 667938
$session->map_table ([[1,3,6,1,2,1,2,2,1,1], # ifIndex
Packit 667938
		      [1,3,6,1,2,1,2,2,1,2], # ifDescr
Packit 667938
		      [1,3,6,1,2,1,2,2,1,3], # ifType
Packit 667938
		      [1,3,6,1,2,1,2,2,1,5], # ifSpeed
Packit 667938
		      [1,3,6,1,2,1,2,2,1,7], # ifAdminStatus
Packit 667938
		      [1,3,6,1,2,1,2,2,1,8]], # ifOperStatus
Packit 667938
sub ($@) {
Packit 667938
    my ($rowindex,$index,$ifdescr,$iftype,$ifspeed,$ifadminstatus,$ifoperstatus) = @_;
Packit 667938
    grep (defined $_ && ($_=pretty_print $_),
Packit 667938
	  ($index,$ifdescr,$iftype,$ifspeed,$ifadminstatus,$ifoperstatus));
Packit 667938

Packit 667938
  if ($cat5500) {
Packit 667938
    my ($intname, $tmp_vlan_no) = split (' ',$ifdescr);
Packit 667938
    if ( ($intname eq "sc0") || ($intname eq "sl0") ) {
Packit 667938
      return;
Packit 667938
    }
Packit 667938
    if ($intname eq "VLAN") {
Packit 667938
      if ($tmp_vlan_no >= 1000) {
Packit 667938
        return;
Packit 667938
      }
Packit 667938
#The Catalyst software version 4.5 seems to return '0' as the ifSpeed for a
Packit 667938
#VLAN.  We set it to 100Mb because we want to watch aggregate VLAN traffic.
Packit 667938
      if ($ifspeed == 0) {
Packit 667938
        $ifspeed = 100 * 10**6;
Packit 667938
      }
Packit 667938
    }
Packit 667938
    my ($port_num, $vlan_desc);
Packit 667938
    $port_num = $iftomp{$index};
Packit 667938
    $port_num =~ s/\./\//g;
Packit 667938
    if ($iftovlan{$index} != 1) {
Packit 667938
      $vlan_desc = "<font color=\"#8C1717\"> Vlan $iftovlan{$index} </font>";
Packit 667938
    }
Packit 667938
    else {
Packit 667938
      $vlan_desc = "Vlan $iftovlan{$index}";
Packit 667938
    }
Packit 667938
    if ($iftype != 53) {
Packit 667938
      $sifdesc{$index} = "Port $port_num, $vlan_desc, $ifdescr";
Packit 667938
    }
Packit 667938
    else {
Packit 667938
      $sifdesc{$index} = "<font color=\"#6B238E\">  Aggregate Traffic: $ifdescr  </font>";
Packit 667938
      $sifrawdesc{$index} = $ifdescr;
Packit 667938
    }
Packit 667938
  }
Packit 667938
  else {
Packit 667938
    $sifdesc{$index} = $ifdescr;
Packit 667938
  }
Packit 667938
    $siftype{$index} = $iftype;
Packit 667938
    $sifspeed{$index} = $ifspeed;
Packit 667938
    $sifadminstatus{$index} = $ifadminstatus;
Packit 667938
    $sifoperstatus{$index} = $ifoperstatus;
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 = $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("$community\@$router", $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
  my $index;
Packit 667938
  foreach $index ( sort { $a <=> $b } keys %sifdesc) {
Packit 667938
    my $c;
Packit 667938
    my $speed = int($sifspeed{$index} / 8); # bits to byte
Packit 667938
    my $speed_str=&fmi($speed);
Packit 667938
    my $name="$iphost{$index}";
Packit 667938
    $name = "$router.$index" if not $name or $name =~ /\s/;
Packit 667938

Packit 667938

Packit 667938

Packit 667938
  if (($sifadminstatus{$index} != 1)
Packit 667938
# this check added by Josh - don't query E1-stack controllers
Packit 667938
      || ($siftype{$index} == 18)
Packit 667938
	|| ($siftype{$index} == 24)
Packit 667938
	|| ($speed == 0 ) 
Packit 667938
	|| ($speed > 400 * 10**6)  #speeds of 400 MByte/s are not realistic
Packit 667938
	|| ($sifoperstatus{$index} == 3)) {
Packit 667938
    print <
Packit 667938
########
Packit 667938
######## This Interface is one of the following
Packit 667938
######## - administratively not UP
Packit 667938
######## - it is in test mode
Packit 667938
######## - it is a softwareLoopback interface
Packit 667938
######## - has a unrealistic speed setting
Packit 667938
######## It is commented out for this reason.
Packit 667938
########
Packit 667938
ECHO
Packit 667938
  $c="# ";
Packit 667938
  }else {
Packit 667938
    $c = '';
Packit 667938
  }
Packit 667938
    
Packit 667938
  print <
Packit 667938
${c}
Packit 667938
ECHO
Packit 667938

Packit 667938
if ( ($cat5500) && ($siftype{$index} == 53) ) {
Packit 667938
#  print "\n\nhere!! desc:$sifrawdesc{$index}\n\n";
Packit 667938
  my $agg_vlan_no = $sifrawdesc{$index};
Packit 667938
  $agg_vlan_no =~ s/\D//g;
Packit 667938
  my $ctr = 0;
Packit 667938
  foreach my $key (sort(keys %iftovlan)) {
Packit 667938
#	print "key:$key;agg:$agg_vlan_no;index:$index\n\n\n\n";
Packit 667938
    if ($iftovlan{$key} == $agg_vlan_no) {
Packit 667938
#      print "\n\na hit!!\n\n";
Packit 667938
      if ($ctr == 0) {
Packit 667938
	print "${c}Target[$name]: $key:$community\@$router";
Packit 667938
      }
Packit 667938
      else {
Packit 667938
	print " + $key:$community\@$router";
Packit 667938
      }
Packit 667938
      $ctr++;
Packit 667938
    }
Packit 667938
  }
Packit 667938
}
Packit 667938
else {
Packit 667938
  print "${c}Target[$name]: $index:$community\@$router";
Packit 667938
}
Packit 667938

Packit 667938
print <
Packit 667938
${c}
Packit 667938
${c}Directory[$name]:$sysName
Packit 667938
${c}MaxBytes[$name]: $speed
Packit 667938
${c}Title[$name]: $sysName ($iphost{$index}): $sifdesc{$index}
Packit 667938
${c}PageTop[$name]: 

Traffic Analysis for $sifdesc{$index}

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}       $speed_str ($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 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