in reply to snmpwalk problem

I always test the returned varbind to ensure the OID hasn't incremented past the branch that I want. (getnext always gets the next OID regardless of what the initial OID was). (OID = object identifier, it's the .1.3.6.1... thing)

my $baseoid = ".1.3.6.1.2.1.2.2"; # ifTable my $thisoid = $baseoid; while ( 1 ) { $val = $sess->getnext($thisoid); last if ( $thisoid !~ m/^$baseoid\./ ); last if ( $sess->{ErrorNum} ); print( "@{$thisoid}\n" ); }

Update: I always use Net::SNMP, too. Why? Because it's pure Perl, unlike SNMP which relies on the UCD tools. The latest Net::SNMP, however, does some tricky SNMPv3 stuff that requires a recent version of Perl, making it not that useful for running on old installations of 5.005.. in which case getting an older copy of Net::SNMP isn't a bad idea.

Replies are listed 'Best First'.
Re^2: snmpwalk problem
by Anonymous Monk on Jun 20, 2005 at 14:20 UTC
    Monarch,
    Tried the following and it didn't like the OID, see the output below.
    rgds.
    my $baseoid = ".1.3.6.1.2.1.2.2"; # ifTable my $thisoid = $baseoid; while ( 1 ) { $val = $sess->getnext($thisoid); print "$val \n"; last if ( $thisoid !~ m/^$baseoid\./ ); last if ( $sess->{ErrorNum} ); print( "@{$thisoid}\n" ); Cisco Internetwork Operating System Software IOS (tm) 3600 Software (C3640-JS-M), Version 12.1(5)T8, RELEASE SOFTW +ARE (fc1) TAC Support: http://www.cisco.com/cgi-bin/ibld/view.pl?i=support Copyright (c) 1986-2001 by cisco Systems, Inc. Compiled Tue
    A reply falls below the community's threshold of quality. You may see it by logging in.