Probably the simplest module to work with for getting at arbitrary MIBs is Net::SNMP - the following example (hacked from the code in my Net::SNMP::Interfaces ) walks the ifTable for hosts who's IP are specified in the file ipfile.txt (one per line) and and prints the description of the interface:
use Net::SNMP; use strict; use warnings; + open IPFILE, "ipfile.txt" or die "Can't get IPs - $!\n"; + my $community = 'public'; my $ifIndex = '1.3.6.1.2.1.2.2.1.1'; my $ifDescr = '1.3.6.1.2.1.2.2.1.2'; + while ( my $ip = <IPFILE> ) { chomp $ip; + my ( $session, $error ) = Net::SNMP->session( -hostname => $ip, -community => $community, -port => 161 ); my $response; + if ( defined( $response = $session->get_table($ifIndex) ) ) { foreach my $index ( values %{$response} ) { my $this_desc = "$ifDescr.$index"; my $description; if ( defined( $description = $session->get_request($this_d +esc) ) ) { print values %{$description}, "\n"; } } + } + $session->close(); }
Hope that helps
/J\
In reply to Re: Reading IP from a file and SNMP
by gellyfish
in thread Reading IP from a file and SNMP
by theroninwins
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |