[F10-nsp] code to determine IfIndex
Jo Rhett
jrhett at svcolo.com
Tue Jun 19 05:42:07 EDT 2007
If you build your own internal management tools, you may have found the
following page lacking in useful details:
https://www.force10networks.com/CSPortal20/KnowledgeBase/SNMPFAQ.aspx
Well, using that information and snmpwalk output, I found the following
code to determine the IfIndex.
The only gotcha is that you really need to know the card type to get the
interface index, which I think blows chunks. So to use this script you
may need to modify the cardtype value to match your environment. The
script as published below assumings slot 0-1 contains 24-port SFP cards,
and all other slots contain 48-port copper cards.
#!/usr/local/bin/perl
my $slot = $ARGV[0];
my $port = $ARGV[1];
my $cardtype = 49209; # bits 1-18
if( $slot < 2 ) {
$cardtype = 49208; # sfp cards in slot 0-1
}
my $portmultiply = 262144; # bits 19-25
my $slotmultiply = 33554432; # bits 26-30
my $ifindex = ( ($slot + 1) * $slotmultiply) + ( ($port + 1) *
$portmultiply) + $cardtype;
print "Ifindex for gi${slot}/${port} = $ifindex\n";
exit 0;
--
Jo Rhett
senior geek
Silicon Valley Colocation
More information about the force10-nsp
mailing list