• May 22, 2012, 10:40:09 PM
Welcome, Guest. Please login or register. Registration is free.
Did you miss your activation email?

Author Topic: ifIndex  (Read 677 times)

0 Members and 1 Guest are viewing this topic.

Offline saturnin55

  • Rookie
  • **
  • Posts: 22
ifIndex
« on: March 03, 2011, 07:46:04 AM »
An easy one, I understand the formula to convert an ifIndex to slot/port has different parameters for many nortel/avaya devices.

On my 8600 slot 1/1 is ifIndex 64 and slot 2/1 is ifIndex 128
On a 5530 slot 1/1 is ifInfex 1 and slot 2/1 is ifIndex 129
On a 4550 or 470 slot 1/1 is ifIndex 1 and slot 2/1 is ifIndex 65

The factor is 64 or 128, and sometimes there's an offset or not.

Is there OIDs to get those values on the device I'm working on or if I have to manually test the chassis type and adjust the formula consequently ?

Thanks


Offline Flintstone

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 584
Re: ifIndex
« Reply #1 on: March 03, 2011, 08:56:31 AM »
Hi,

A while back I had the same question for Nortel/Avaya and was told it depended on the equipment you were using whether 64 or 128 offset is required, so it therefore makes sense to query the chassis type and then utilise the relevant offset for the ifIndex?

Good luck

Offline Michael McNamara

  • Administrator
  • Hero Member
  • *****
  • Posts: 2517
    • Michael McNamara
Re: ifIndex
« Reply #2 on: March 03, 2011, 10:12:20 AM »
Here's the Perl code I currently use (you'll obviously need to adapt it to your situation).

Code: [Select]
############################################################################
# Subroutine get_cardport
#
# Purpose: return card/port from ifIndex value based on sysObjectID
############################################################################
sub get_cardport
{
   # Declare Local Variables
   my $xifnum = $_[0];  # ifIndex value passed to subroutine`
   #my $msg = $_[1];

   my $xcard;           # Local variable for card assignment
   my $xport;           # Local variable for port assignment


   if ( ($sysObjectID eq "rcA8610") ||
        ($sysObjectID eq "rcA8606") ||
        ($sysObjectID eq "rcA1648") ) {
      $xcard = int($xifnum/64);
      $xport = ($xifnum - ($xcard * 64) + 1);

   } elsif ( ($sysObjectID eq "sreg-BayStack470-48T-ethSwitchNMM") ||
             ($sysObjectID eq "sreg-BayStack470-24T-ethSwitchNMM") ) {
      $xcard = int($xifnum/64);
      $xport = ($xifnum - ($xcard * 64) );
      $xcard++;

   } elsif ( ($sysObjectID eq "sreg-BayStack5510-48T-ethSwitchNMM") ||
             ($sysObjectID eq "sreg-BayStack5510-24T-ethSwitchNMM") ||
             ($sysObjectID eq "sreg-EthernetRoutingSwitch5530-24TFD") ||
             ($sysObjectID eq "sreg-BayStack5520-48T-PWR") ) {
      if ($sysSoftware =~ "6.1" ) {
         $xcard = (int($xifnum/128) + 1);
         if ($xcard > 1) {
            $xport = ($xifnum - (($xcard - 1)* 128) );
         } else { $xport = $xifnum }
      } else {
         $xcard = int($xifnum/64);
         $xport = ($xifnum - ($xcard * 64) );
         $xcard++;
      }
   } elsif ( ($sysObjectID eq "BPS2000-24T-ethSwitchNMM") ||
             ($sysObjectID eq "sreg-BPS2000-24T-ethSwitchNMM") ||
             ($sysObjectID eq "sreg-BayStack460-24T-PWR-ethSwitchNMM") ||
             ($sysObjectID eq "sreg-BayStack450-ethSwitchNMM" ) ||
             ($sysObjectID eq "sreg-BayStack350-24T-ethSwitchNMM") ) {
      $xcard = int($xifnum / 32);
      $xport = ( $xifnum - ($xcard * 32) );
      $xcard++;
   } elsif ( $sysObjectID eq "hpProLiant-p-GbE2-InterconnectSwitch") {
      $xcard = 1;
      ##$xport = $xifnum - 256;
      $xport = $xifnum;
   } elsif ( ( $sysObjectID eq "catalyst295024G") ||
             ( $sysObjectID eq "catalyst295048G") ||
             ( $sysObjectID eq "workgroup.44") ){
      $xcard = 0;
      $xport = $xifnum;
   } else {
      die "ERROR: unable to determine ifIndex conversion from $snmphost($sysObjectID)\n";

   } #end if

   return ($xcard, $xport);

} #end sub
[code]

Good Luck!

We've been helping network engineers, system administrators and technology professionals since June 2009.
If you've found this site useful or helpful, please help me spread the word. Link to us in your blog or homepage - Thanks!