2

I have a AgentX sub-agent working with net-snmp master agent. I want to convert an unsigned int value to the snmp type and print it using the snmpget command. I have used the following function:

snmp_set_var_typed_value(var,
                         ASN_UNSIGNED,
                         (u_char *)&runnableEntry_tbl[major-1].runnableObjectCounters.counters[counter_index-1].value,
                         sizeof(unsigned int));

(where runnableEntry_tbl[major-1].runnableObjectCounters.counters[counter_index-1].value is an unsigned value).

The problem is the value is getting transmitted as a Gauge32 (as per wireshark), also the display of the value with snmpget is something like:

runnableObjectCounters.1.1 = Gauge32: 4294967294

Can the Gauge32 be removed somehow? Or is there some other type for Unsigned32 as per ASN, please help me.

I am working on Linux.

lostriebo
  • 1,483
  • 1
  • 16
  • 25
dashdeep13
  • 21
  • 3
  • From what i have found out the asn type to be used is ASN_UNSIGNED and the receiving MIB variable is Unsigned32. I have used these , still i am getting the value as Gauge32 – dashdeep13 Feb 10 '14 at 10:03

2 Answers2

1

According to the RFCs (1902 and 2578) Gauge32 and Unsigned32 are interchangeable. A relevant section from the RFC 2578:

-- this doesn't wrap
Gauge32 ::=
    [APPLICATION 2]
        IMPLICIT INTEGER (0..4294967295)

-- an unsigned 32-bit quantity
-- indistinguishable from Gauge32
Unsigned32 ::=
    [APPLICATION 2]
        IMPLICIT INTEGER (0..4294967295)

As far as the standard is concerned, an Unsigned32 and a Gauge32 will be indistinguishable from one another on the wire.

See this other Stack Overflow question for a little more discussion about Unsigned32 and Gauge32 within the SNMP specification.

If you're trying to get snmpget to display the expected type, you may have some luck if you make sure the MIB for your sub-agent is loaded in the path. Several ways to accomplish this are described on the Net-SNMP wiki page, Using and Loading MIBS.

One of the easier ways is to put the MIB in one of the directories that get loaded by Net-SNMP, $HOME/.snmp/mibs or /usr/local/share/snmp/mibs (this directory varies by linux distribution, you can call net-snmp-config --default-mibdirs to get a list of directories searched by Net-SNMP).

Once your MIB is in the correct location, you should be able to call snmpget with the -m option,

snmpget -m +YOUR-SPECIFIC-MIB <other-snmp-options>

where YOUR-SPECIFIC-MIB is replaced with the name of the MIB you care about.

Mark Amery
  • 143,130
  • 81
  • 406
  • 459
lostriebo
  • 1,483
  • 1
  • 16
  • 25
  • Thanks lostriebo for that information. i am using the mib in the snmpget command and my OIDs are getting mapped properly as per the mib as mentioned below: runnableObjectCounters.1.1 = Gauge32: 4294967294 This item has been defined as Unsigned32 and is getting mapped properly via the MIB. MY concern now is that is there any way i can remove the Gauge32: prefix present before the value? Or i can get something like "Unsigned32:" prefixed before the value so that i can confidently say that yes the value is "Unsigned32" and not Gauge32, even though both are same. :) Thanks in advance. – dashdeep13 Feb 11 '14 at 04:39
0

I also came across things like ASN_UINTEGER, but i guess it is outdated. As per the mentioned post, ASN_UNSIGNED32 is not supported in UNIX. So we are left with ASN_UNSIGNED only. But again the display is confusing even though Gauge32 and Unsigned32 is same :)

dashdeep13
  • 21
  • 3