tolyan77 has asked for the wisdom of the Perl Monks concerning the following question:

Hi all. I neew you wisdom. I'm using code:
#!/usr/bin/perl -w use strict; use NET::SNMP; my $hostname = '10.10.10.10'; my $password = "public"; my $dot1dTpFdbAddress = ".1.3.6.1.2.1.17.4.3.1.1"; my $dot1dTpFdbPort = ".1.3.6.1.2.1.17.4.3.1.2"; my $dot1dTpFdbStatus = ".1.3.6.1.2.1.17.4.3.1.3"; my $dot1dBasePortIfIndex = ".1.3.6.1.2.1.17.1.4.1.2"; my $ifDescr = ".1.3.6.1.2.1.2.2.1.2"; my ($session, $error) = Net::SNMP->session ( - hostname => shift || '10.0.0.230', - community => shift || 'public', - port => shift || 161, - version => shift || 1, ); if (defined(my $result = $session->get_table(-baseoid => $dot1dTpFdbPo +rt))) { foreach (keys(%{$result})) { my $ifnum = $session->get_request("$dot1dBasePortIfIndex\.".$resul +t->{$_}); my $ifnum2 = $session->get_request("$ifDescr\.".$ifnum->{"$dot1dBa +sePortIfIndex\.".$result->{$_}}); print $ifnum2->{"$ifDescr\.".$ifnum->{"$dot1dBasePortIfIndex\.".$r +esult->{$_}}}; print " - "; print $ifnum->{"$dot1dBasePortIfIndex\.".$result->{$_}}; print " - "; print "$result->{$_}\n"; } } else { printf("ERROR: %s\n\n", $session->error()); } $session->close;
How to make conformity $ifDescr - $dot1dTpFdbAddress?
Thanks in advance!

Replies are listed 'Best First'.
Re: NET::SNMP mac address<->port
by traveler (Parson) on Nov 16, 2006 at 18:05 UTC
    OK. Here is what you need. First, dot1dTpFdbAddress is part of the bridge MIB (BRIDGE-MIB (RFC1493)). I suggest you look at SNMP::Info::Bridge and use it. If you want to do it "by hand" as you did before, the OID is

    .1.3.6.1.2.1.17.4.3.1.1

    HTH, --traveler

Re: NET::SNMP mac address<->port
by traveler (Parson) on Nov 16, 2006 at 17:50 UTC
    I do not have an SNMP bridge device handy. Can you please provide a sample of the output you're getting and and example of what you want?
      Sample of the output for this code
      RMON:10/100 Port 22 on Unit 2 - 222 - 54 RMON:GE Port 25 on Unit 2 - 225 - 57 RMON:10/100 Port 8 on Unit 3 - 308 - 72 RMON:GE Port 25 on Unit 2 - 225 - 57 RMON:10/100 Port 5 on Unit 2 - 205 - 37 RMON:GE Port 25 on Unit 2 - 225 - 57 RMON:GE Port 25 on Unit 2 - 225 - 57 RMON:10/100 Port 5 on Unit 4 - 405 - 101 RMON:GE Port 25 on Unit 3 - 325 - 89 RMON:GE Port 25 on Unit 3 - 325 - 89 RMON:10/100 Port 14 on Unit 4 - 414 - 110 RMON:10/100 Port 19 on Unit 4 - 419 - 115 RMON:10/100 Port 4 on Unit 1 - 104 - 4 RMON:10/100 Port 9 on Unit 3 - 309 - 73 RMON:GE Port 25 on Unit 3 - 325 - 89 RMON:10/100 Port 19 on Unit 1 - 119 - 19 RMON:10/100 Port 7 on Unit 4 - 407 - 103 RMON:10/100 Port 13 on Unit 1 - 113 - 13 RMON:10/100 Port 12 on Unit 1 - 112 - 12 RMON:GE Port 25 on Unit 3 - 325 - 89 RMON:10/100 Port 23 on Unit 3 - 323 - 87 RMON:GE Port 25 on Unit 3 - 325 - 89 RMON:10/100 Port 11 on Unit 4 - 411 - 107 RMON:GE Port 25 on Unit 2 - 225 - 57 RMON:GE Port 25 on Unit 3 - 325 - 89 RMON:10/100 Port 11 on Unit 1 - 111 - 11 RMON:10/100 Port 18 on Unit 2 - 218 - 50 RMON:GE Port 25 on Unit 3 - 325 - 89 RMON:10/100 Port 23 on Unit 4 - 423 - 119 RMON:10/100 Port 3 on Unit 3 - 303 - 67 RMON:10/100 Port 2 on Unit 4 - 402 - 98 RMON:GE Port 25 on Unit 3 - 325 - 89 RMON:10/100 Port 4 on Unit 3 - 304 - 68 RMON:10/100 Port 13 on Unit 4 - 413 - 109 RMON:10/100 Port 12 on Unit 3 - 312 - 76 RMON:10/100 Port 3 on Unit 4 - 403 - 99 RMON:10/100 Port 6 on Unit 2 - 206 - 38 RMON:10/100 Port 18 on Unit 3 - 318 - 82 RMON:GE Port 25 on Unit 3 - 325 - 89 RMON:GE Port 25 on Unit 3 - 325 - 89 RMON:GE Port 25 on Unit 3 - 325 - 89 RMON:10/100 Port 15 on Unit 1 - 115 - 15 RMON:GE Port 25 on Unit 3 - 325 - 89 RMON:GE Port 25 on Unit 2 - 225 - 57 RMON:GE Port 25 on Unit 3 - 325 - 89 RMON:GE Port 25 on Unit 3 - 325 - 89 RMON:GE Port 25 on Unit 3 - 325 - 89 RMON:10/100 Port 2 on Unit 2 - 202 - 34 RMON:10/100 Port 5 on Unit 3 - 305 - 69 RMON:GE Port 25 on Unit 3 - 325 - 89 RMON:GE Port 25 on Unit 2 - 225 - 57 RMON:10/100 Port 15 on Unit 4 - 415 - 111 RMON:GE Port 25 on Unit 3 - 325 - 89 RMON:GE Port 25 on Unit 3 - 325 - 89 RMON:10/100 Port 21 on Unit 3 - 321 - 85 RMON:GE Port 25 on Unit 3 - 325 - 89
      I wish to make, for an example
      0x00e0d80c7621 - RMON:10/100 Port 21 on Unit 3 - 321 - 85