Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: snmpwalk problem

by decnartne (Beadle)
on Jun 21, 2005 at 14:52 UTC ( [id://468699]=note: print w/replies, xml ) Need Help??


in reply to snmpwalk problem

I use the following in a script I run to get a list of interfaces from Cisco... (perhaps the leading "." on your varbind is the culprit? - or not...)
... use strict; use Net::SNMP; ... sub get_if_ids { my ( $hostname ) = @_; my %ifs; my $ifEntry = "1.3.6.1.2.1.2.2.1.2"; my ( $session, $error ) = Net::SNMP->session( -hostname => $hostname, -version => 1, -community => "public" ); if ( !defined( $session ) ) { print "ERROR: SNMP - $error\n"; return undef; } my $result = $session->get_next_request( -varbindlist => [$ifEntry +] ); while ( defined( $result ) ) { foreach my $key ( keys %$result ) { if ( $key !~ /^$ifEntry/ ) { $result = undef; last; } # process $result... # Update: $key is 1.3.6.1.2.1.2.2.1.2.n for the nth inte +rface # $result->{$key} is interface name $result = $session->get_next_request( -varbindlist => [$ke +y] ); } } $session->close(); return \%ifs; }

decnartne ~ entranced

Replies are listed 'Best First'.
Re^2: snmpwalk problem
by GS (Acolyte) on Jun 22, 2005 at 19:28 UTC
    Thanks.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://468699]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2025-03-18 02:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When you first encountered Perl, which feature amazed you the most?










    Results (56 votes). Check out past polls.