SNMP

SNMP Component

The snmp: component gives you the ability to poll SNMP capable devices or receiving traps.

URI format

snmp://hostname[:port][?Options]

The component supports polling OID values from an SNMP enabled device and receiving traps.

You can append query options to the URI in the following format, ?option=value&option=value&...

Options

Table 69 lists the SNMP uri options:

Table 69. URI options

Name Default Description
type none

Specifies the type of action you want to perform. Enter POLL or TRAP.

POLL instructs the endpoint to poll a given host for the supplied OID keys.

TRAP sets up a listener for SNMP Trap Events.

address none

Specifies the IP address and port of the host to poll, or where to setup the Trap Receiver.

Example: 127.0.0.1:162

protocol udp Selects which protocol to use. The default is udp, but you can also use tcp.
retries 2 Defines how often a retry is made before canceling the request.
timeout 1500 Sets the timeout value for the request in milliseconds.
snmpVersion 0

Sets the snmp version for the request.

The default selects SNMPv1.

snmpCommunity public Sets the community octet string for the snmp request.
delay 60 seconds Defines the delay in seconds between to poll cycles.
oids none

Defines which values you are interested in. For more background information, see Wikipedia.

You may provide a single OID or a coma-separated list of OIDs.

Example: oids="1.3.6.1.2.1.1.3.0,1.3.6.1.2.1.25.3.2.1.5.1"


The result of a poll

Given the situation, that I poll for the following OIDs:

1.3.6.1.2.1.1.3.0
1.3.6.1.2.1.25.3.2.1.5.1
1.3.6.1.2.1.25.3.5.1.1.1
1.3.6.1.2.1.43.5.1.1.11.1

The result will be the following:

<?xml version="1.0" encoding="UTF-8"?>
<snmp>
  <entry>
    <oid>1.3.6.1.2.1.1.3.0</oid>
    <value>6 days, 21:14:28.00</value>
  </entry>
  <entry>
    <oid>1.3.6.1.2.1.25.3.2.1.5.1</oid>
    <value>2</value>
  </entry>
  <entry>
    <oid>1.3.6.1.2.1.25.3.5.1.1.1</oid>
    <value>3</value>
  </entry>
  <entry>
    <oid>1.3.6.1.2.1.43.5.1.1.11.1</oid>
    <value>6</value>
  </entry>
  <entry>
    <oid>1.3.6.1.2.1.1.1.0</oid>
    <value>My Very Special Printer Of Brand Unknown</value>
  </entry>
</snmp>

As you maybe recognized there is one more result than requested....1.3.6.1.2.1.1.1.0. This one is filled in by the device automatically in this special case. So it may absolutely happen, that you receive more than you requested...be prepared.

Examples

Polling a remote device:

snmp:192.168.178.23:161?protocol=udp&type=POLL&oids=1.3.6.1.2.1.1.5.0

Setting up a trap receiver (no OID info is needed here!):

snmp:127.0.0.1:162?protocol=udp&type=TRAP

Routing example in Java (converts the SNMP PDU to XML String):

from("snmp:192.168.178.23:161?protocol=udp&type=POLL&oids=1.3.6.1.2.1.1.5.0").
convertBodyTo(String.class).
to("activemq:snmp.states");