http://qs321.pair.com?node_id=1202797

jvuman has asked for the wisdom of the Perl Monks concerning the following question:

When I access the hrPrinterDetectedErrorState OID (1.3.6.1.2.1.25.3.5.1.2.1) using the Net-SNMP command line tools, I get a string of two hex digits, like "0A 00". This can be interpreted as a bitmask using instructions in the HOST-RESOURCES mib.

However, when I retrieve this value using Net::SNMP, I always get a pair of ASCII space characters. Data::Dumper confirms this.

Example code:

my $oid = '1.3.6.1.2.1.25.3.5.1.2.1'; my ($snmp,$error) = Net::SNMP->session(...); my $result = $snmp->get_request(-varbindlist => [ $oid ]; print $result->{$oid},"\n";

Am I missing something? I get the same results on ActiveState Perl 5.24 on Windows and Perl 5.16 on Linux. Thank you for any suggestions!

Replies are listed 'Best First'.
Re: Net::SNMP, hrPrinterDetectedErrorStatus
by Corion (Patriarch) on Nov 06, 2017 at 08:35 UTC

    How far can you trust the output of the Net-SNMP command line tools? Maybe they are just printing the data in hexdump format because the SNMP OID isn't known a string, or the data doesn't look like a string?

    Without knowing anything about SNMP, it seems that at least snmpwalk.pl from the examples will use the snmp_type_ntop function to convert things to something printable. I don't know if the data you receive already is supposed to be the decoded value or maybe is still in ASN.1 format.

      The "snmpget" binary returns a value consistent with the printer's real observed status.

      Did try snmp_type_ntop, but it did not help. Thanks though!