Subject: | Calling method "get_request" with inaccessible oid does not report error |
Date: | Fri, 10 Apr 2020 20:29:50 +0200 |
To: | bug-Net-SNMP [...] rt.cpan.org |
From: | "Alejandro S." <alejandroscf [...] gmail.com> |
Hi,
While working in a plugin [0] for Munin monitoring system I found what
looks like a bug.
When you ask for the value of an OID that you know it's not accessible, if
you set the session with version = "v2c" no error is returned when calling
"get_request" . When retrieved with version = v1 an error 'noSuchName(2)'
is thrown.
You can check that with the following script [1] (Usage: snmp_test.pl
[host] [community]).
One of OIDs is uptime and the other is only available in some Mikrotik
routers, so using it against other hardware will show you the error not
being thrown.
Here is a sample output:
Show quoted text
> ################
> version v1
> ################
>
> ERROR: Received noSuchName(2) error-status at error-index 1.
error_status=2
Show quoted text> The sysUpTime for host 'example.com' is 367 days, 04:30:57.99.
error_status=0
Show quoted text>
> ################
> version v2c
> ################
>
> The mikrotikTemp for host 'example.com' is noSuchObject. error_status=0
> The sysUpTime for host 'example.com' is 367 days, 04:30:58.06.
error_status=0
It gets worst if you combine version = "v2c" and translate=0 when setting
the session, because no error is thrown and the response is defined but
equal to an empty string, so you have no way of knowing if the OID has
answered an empty string or that OID is not available.
Here goes the environment information:
Debian 10, amd64,
Perl v5.28.1
libnet-snmp-perl version: 6.0.1-5
[0]: https://github.com/munin-monitoring/contrib/pull/1049
[1]: https://gist.github.com/alejandroscf/01bc0b47895484ffb10e3c5707342697
Best regards,
Alejandro Suárez