[SNMP4J] NET-SNMP-EXTEND-MIB

Dan Bach dbach at mc.com
Fri Feb 24 20:47:33 CET 2012


Rodrigues, Rui 1. (NSN - PT/Amadora <rui.1.rodrigues at ...> writes:

> 
> Hello,
> 
> You should use single quotes when using non numeric string.. This
> example is given in the documentation of OID constructor.
> 
> OID a = new OID("1.3.6.2.1.5.'hallo'.1");
> 
> Hope that helps
> 
> Regards,
> RAR
> 
> -----Original Message-----
> From: snmp4j-bounces at ...
> [mailto:snmp4j-bounces at ...] On
> Behalf Of ext Dan Bach
> Sent: Wednesday, January 25, 2012 12:06 AM
> To: snmp4j at ...
> Subject: [SNMP4J] NET-SNMP-EXTEND-MIB
> 
> I am trying to use the NET-SNMP-EXTEND-MIB and create an OID which
> includes a non-numeric string:
> 
>     new VariableBinding(new OID(NET_SNMP_EXTEND_MIB +
> ".3.1.2.\"datecheck\""));
> 
> but I get:
> 
> java.lang.NumberFormatException: For input string: ""datecheck""
> 	at java.lang.NumberFormatException.forInputString(Unknown
> Source)
> 	at java.lang.Long.parseLong(Unknown Source)
> 	at java.lang.Long.parseLong(Unknown Source)
> 	at
> org.snmp4j.util.SimpleOIDTextFormat.parse(SimpleOIDTextFormat.java:101)
> 	at org.snmp4j.smi.OID.parseDottedString(OID.java:141)
> 	at org.snmp4j.smi.OID.<init>(OID.java:79)
> 
> because OID apparently expects only integers separated by '.'.  Is there
> some way around this?
> 
> This works with snmpget:
> 
> # snmpget -v2c -c public <IP addr>
> NET-SNMP-EXTEND-MIB::nsExtendOutputFull.\"datecheck\"
> NET-SNMP-EXTEND-MIB::nsExtendOutputFull."datecheck" = STRING: Tue Jan 24
> 18:54:10 EST 2012
> 
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at ...
> http://lists.agentpp.org/mailman/listinfo/snmp4j
> 

The destination system has the following line in /etc/snmp/snmpd.conf:

  extend datecheck /bin/date

If I use the NET-SNMP-EXTEND-MIB via snmpget, the expected result is returned:

  # snmpget -v2c -c public <IP Addr>
NET-SNMP-EXTEND-MIB::nsExtendOutputFull.\"datecheck\"
  NET-SNMP-EXTEND-MIB::nsExtendOutputFull."datecheck" = STRING: Fri Feb 24
13:16:03 EST 2012

Monitoring of the snmp agent on the target system gives:

  Connection from UDP: [172.20.100.74]:48071
  Received SNMP packet(s) from UDP: [172.20.100.74]:48071
    GET message
      -- NET-SNMP-EXTEND-MIB::nsExtendOutputFull."datecheck"

  Sending 86 bytes to UDP: [172.20.100.74]:48071
  0000: 30 54 02 01  01 04 06 70  75 62 6C 69  63 A2 47 02    0T.....public.G.
  0016: 04 2B 2D 7D  E3 02 01 00  02 01 00 30  39 30 37 06    .+-}.......0907.
  0032: 17 2B 06 01  04 01 BF 08  01 03 02 03  01 02 09 64    .+.............d
  0048: 61 74 65 63  68 65 63 6B  04 1C 46 72  69 20 46 65    atecheck..Fri Fe
  0064: 62 20 32 34  20 31 33 3A  31 36 3A 30  33 20 45 53    b 24 13:16:03 ES
  0080: 54 20 32 30  31 32                                    T 2012

If I try to do the get via snmp4j using single quotes to construct the OID:

  new VariableBinding(new OID(NET_SNMP_EXTEND_MIB + ".3.1.2.\'datecheck\'"));

monitoring of the snmp agent gives:

  Connection from UDP: [172.20.226.90]:58850
  Received SNMP packet(s) from UDP: [172.20.226.90]:58850
    GET message
      -- NET-SNMP-EXTEND-MIB::nsExtendOutputFull.100.97.116.101.99.104.101.99.107

  Sending 57 bytes to UDP: [172.20.226.90]:58850
  0000: 30 37 02 01  01 04 06 70  75 62 6C 69  63 A2 2A 02    07.....public.*.
  0016: 04 76 8A 79  3B 02 01 00  02 01 00 30  1C 30 1A 06    .v.y;......0.0..
  0032: 16 2B 06 01  04 01 BF 08  01 03 02 03  01 02 64 61    .+............da
  0048: 74 65 63 68  65 63 6B 81  00                          techeck..

and the result string that is returned is "noSuchInstance".

Unless I'm missing something, it does not appear that snmp4j handles requests of
the form described above with either double- or single- quoted strings.





More information about the SNMP4J mailing list