Hello,

I'm having an issue with Net:SNMP and retreiving values listed as Hex-STRING. Here's a unix snmpwalk which looks OK:

snmpwalk -v 2c -c COMM 10.1.1.1 1.3.6.1.4.1.9.9.273.1.2.1.1.16
SNMPv2-SMI::enterprises.9.9.273.1.2.1.1.16.1.11.97.108.105.97.110.116.95.119.105.102.105.0.19.206.233.215.61 = Hex-STRING: 0A 40 12 81
SNMPv2-SMI::enterprises.9.9.273.1.2.1.1.16.1.11.97.108.105.97.110.116.95.119.105.102.105.0.144.75.10.176.166 = Hex-STRING: 0A 40 12 45
SNMPv2-SMI::enterprises.9.9.273.1.2.1.1.16.1.11.97.108.105.97.110.116.95.119.105.102.105.0.144.150.180.214.183 = Hex-STRING: 0A 40 12 96
SNMPv2-SMI::enterprises.9.9.273.1.2.1.1.16.1.11.97.108.105.97.110.116.95.119.105.102.105.0.144.150.182.172.193 = Hex-STRING: 0A 40 12 87

Here's the same walk with perl:

perl walktest.pl (walking 1.3.6.1.4.1.9.9.273.1.2.1.1.16)
Trying 'snmpwalk' on 10.1.1.1
1.11.97.108.105.97.110.116.95.119.105.102.105.0.19.206.233.215.61:
@
1.11.97.108.105.97.110.116.95.119.105.102.105.0.144.75.10.176.166:
@E
1.11.97.108.105.97.110.116.95.119.105.102.105.0.144.150.180.214.183:
@
1.11.97.108.105.97.110.116.95.119.105.102.105.0.144.150.182.172.193:
@

I get similar weird results if I do an snmpget with perl on 1 OID:

perl test.pl
1.3.6.1.4.1.9.9.273.1.2.1.1.2.1.11.97.108.105.97.110.116.95.119.105.102.105.0.19.206.233.215.61 = bÚZ`

Either way, the “Hex-STRING” data is never returned correctly. This happens with any OID holding a “Hex-STRING”. I don't have a problem with other OID types. At first I thought it was just a formatting issue so I played with printing the output using “hex” but it didn’t help. There also aren't enough chars sent back to be a formatting issue. I wonder if Net::SNMP can’t handle an OID value with a space in it?

The perl code I'm using looks like this:

use strict; use Net::SNMP; use BER; use SNMP_Session; use SNMP_util; #variable declaration and assigment omitted... print "Trying 'snmpwalk' on $host\n"; @ret = &snmpwalk("$community\@$host\:\:\:\:\:$version", $oid ); foreach (@ret) { print "$_\n"; }

As you can see I've been trying various SNMP modules. I've always get the same problem regardless of which way I query to OID.

Any help you can provide would be appreciated.

Thanks,
Serge


In reply to Net::SNMP not retreiving Hex-STRING correctly by serge123

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.