I'm trying to use SNMPget on linux to get information regarding devices on my network. I'm able to successfully use snmpget on the linux terminal but now would like to write a script in perl/python and have it do the work for me.
SNMPget example
snmpgetnext -v 3 -n "" -u USER -a MD5 -A PASSWORD -l authNoPriv 192.168.1.1 sysDescr
I'm trying to do the same thing in perl, but I can't seem to find any good documentation on how to do it. What I found on the internet (but this is not SNMP v3):
$cat snmp
#!/usr/bin/perl
use Net::SNMP;
my $desc = 'sysDescr';
( $session, $error ) = Net::SNMP->session(
-hostname => "192.168.1.1",
-community => "public",
-timeout => "30",
-port => "161"
);
if ( !defined($session) ) {
printf( "ERROR: %s.\n", $error );
exit 1;
}
my $response = $session->get_request($desc);
my %pdesc = %{$response};
my $err = $session->error;
if ($err) {
return 1;
}
print %pdesc;
exit 0;
I tried to modify it to snmp v3 but was unable to. Anybody familiar with this?