Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: nsp: force10

code to determine IfIndex

 

 

nsp force10 RSS feed   Index | Next | Previous | View Threaded


jrhett at svcolo

Jun 19, 2007, 1:42 AM

Post #1 of 3 (3734 views)
Permalink
code to determine IfIndex

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


aaron.glenn at gmail

Aug 1, 2007, 9:46 AM

Post #2 of 3 (3520 views)
Permalink
code to determine IfIndex [In reply to]

On 6/19/07, Jo Rhett <jrhett at svcolo.com> wrote:
> 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.

I apologize if I'm having a major brain fart and just not realizing it
-- but wouldn't one rather work the other way. Meaning, lets
discover/poll the device, get the ifIndexes, and then calculate
everything?

aaron


jrhett at svcolo

Aug 1, 2007, 9:54 AM

Post #3 of 3 (3506 views)
Permalink
code to determine IfIndex [In reply to]

> On 6/19/07, Jo Rhett <jrhett at svcolo.com> wrote:
>> 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.

On Aug 1, 2007, at 10:46 AM, Aaron Glenn wrote:
> I apologize if I'm having a major brain fart and just not realizing it
> -- but wouldn't one rather work the other way. Meaning, lets
> discover/poll the device, get the ifIndexes, and then calculate
> everything?

Yes. Poll the device and get the card types, then adjust the script.

The issue is when you want to do random/ad-hoc queries, you don't
want to do a full discovery every time. In my experience a full pull
of all switch ports takes 20 seconds to finish. This allows you to
determine the right thing to query quickly, when you want an instant
direct query of something on the switch.

--
Jo Rhett
senior geek

Silicon Valley Colocation
Support Phone: 408-400-0550

nsp force10 RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.