Search code examples
linuxperlsnmpnet-snmp

Why do I get the error "Received usmStatsUnknownUserNames.0 Report-PDU with value 1" when I try to connect to my device using Net::SNMP?


I am trying to write a Perl script to do an SNMP get. It should work like the following command:

snmpget -v 3 -l authNoPriv -a MD5 -u V3User -A V3Password 10.0.1.203 sysUpTime.0

Returns:

SNMPv2-MIB::sysUpTime.0 = Timeticks: (492505406) 57 days, 0:04:14.06

But my Perl script returns the following:

ERROR: Received usmStatsUnknownUserNames.0 Report-PDU with value 1 during synchronization.

Last but not least, here is the Perl script:

use strict;
use warnings;

use Net::SNMP;

my $desc = 'sysUpTime.0';

my ($session, $error) = Net::SNMP->session(
   -hostname     => '10.0.1.202',
   -version      => 'snmpv3',
   -username     => 'V3User',
   -authprotocol => 'md5',
   -authpassword => 'V3Password'
);

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 called the Perl script and snmpget on the same (Linux) machine. What could be causing this and how can I fix it?


Solution

  • Looking at your script I noticed that hostname value has 10.0.1.202

    but the snmpget command you're using has 10.0.1.203

    wrong IP by any chance?