Hello, I would like to use asynchronous mode in a perl script to get mac table of several switch.
I followed the tutorial on this page (code below figure 10.1): http://www.unix.org.ua/orelly/perl/sysadmin/ch10_03.htm Which I modified to make it asynchronous. Here it is: " 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 $dot1dBasePortIfIndex= '.1.3.6.1.2.1.17.1.4.1.2'; my $ifName= '.1.3.6.1.2.1.31.1.1.1.1'; my $session = new SNMP::Session(DestHost => "$ip", Community => "$com", UseSprintValue => 1, Version => 1); die "session creation error: $SNMP::Session::ErrorStr" unless (defined $session); # set up the data structure for the getnext command my $vars = new SNMP::VarList(["$dot1dTpFdbAddress"], ["$dot1dTpFdbPort"]); my $res = $session->getnext($vars,[\&call,$session]); die $session->{ErrorStr} if ($session->{ErrorStr}); SNMP::MainLoop(); sub call { 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 ($sess, $vlist) = @_; my $oidmac = $vlist->[0][0]; my $oidport = $vlist->[1][0]; my $mac = $vlist->[0][2]; my $port = $vlist->[1][2]; my $oidmacend = $vlist->[0][1]; my $oidportend = vlist->[1][1]; my $oidmacnext = "$dot1dTpFdbAddress.$oidmacend"; my $oidportnext = "$dot1dTpFdbPort.$oidportend"; if ($oidmac eq 'dot1dTpFdbAddress') { print "port:'$port'\t'$mac'\n"; #print "next mac:'$dot1dTpFdbAddress.$mac'\tnext port:'$dot1dTpFdbPort.$port'\n"; print Dumper($vlist); my $vars = new SNMP::VarList(["$oidmacnext"], ["$oidportnext"]); $sess->getnext($vars,[\&call,$sess]); #SNMP::finish(); } else { SNMP::finish(); } } " I'm geting some data but I don't know how to print the MAC adress returned in a comprehensive way, it'encoded I think. I get somthing like this: "port:'2' 'Ps� $VAR1 = bless( [ bless( [ 'dot1dTpFdbAddress', '0.0.80.6.115.210', 'Ps�, 'OCTETSTR' ], 'SNMP::Varbind' ), bless( [ 'dot1dTpFdbPort', '0.0.80.6.115.210', '2', 'INTEGER' ], 'SNMP::Varbind' ) ], 'SNMP::VarList' ); " However when I do the same thing in a synchronous mode, it prints perfectly: " my ($macaddr,$portnum) = $session->getnext($vars); " it prints the macaddress like XX XX XX XX XX XX I would like to make my request in asynchronous becaause I was told that it could go a lot faster. I have nearly 30 switchs ... (it takes more than half an hour in synchronous mode !) Don't know if my explanations are clear. Can somebody help me ? Thank you, Kenwaz ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Net-snmp-users mailing list Net-snmp-users@lists.sourceforge.net Please see the following page to unsubscribe or change other options: https://lists.sourceforge.net/lists/listinfo/net-snmp-users