Thursday, July 21, 2011

Using Apache Camel to Monitor SNMP-enabled devices

I've been working with a hardware manufacturer company this week that wanted to use Apache Camel to get information about SNMP-enabled (http://en.wikipedia.org/wiki/Simple_Network_Management_Protocol) devices.

As you may know, Apache Camel has a SNMP component (http://camel.apache.org/snmp.html) able to poll devices or receive SNMP traps.

Here is a very simple Camel route example that we used to get started with the camel-snmp component:


<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Configures the Camel Context-->
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:camel="http://camel.apache.org/schema/spring" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">

  <camelContext xmlns="http://camel.apache.org/schema/spring">
    <package>com.fusesource.fusebyexample</package>
    <route id="SNMP-Sample-Route">
        <from uri="snmp:1.1.1.12:161?
                   protocol=udp&amp;
                   type=POLL&amp;
                   delay=10&amp;
                   oids=1.3.6.1.2.1.1.3.0"/>
        <log logName="SNMP_LOG" 
             loggingLevel="INFO" 
             message="&gt;&gt;&gt; ${body}"/>
    </route>
</camelContext>

</beans>


So, the snmp-camel component has many configuration options but you basically have to provide the following:


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


Additionally, you have the following options:














On our example, we added the following (additionally to the hostname and port number of the host we wanted to get information from) to test the configuration:

protocol=UDP - You can either use UDP or TCP protocols

type=POLL - You can enter POLL or TRAP to define whether the camel component is going to poll the device for info and create a listener for SNMP trap events

delay=10 - Frequency you want to poll the device for information

oids=1.3.6.1.2.1.1.3.0 - In this particular example, we setup the OID which retrieves the amount of time the device is up (http://www.oid-info.com/get/1.3.6.1.2.1.1.3.0)

The last piece of our Camel route was just a log component because we wanted to see what was coming back from the device. That's all!

We also used the FUSE IDE to rapidly test the scenario we wanted and that was pretty straightforward. The FUSE IDE can be downloaded from (http://fusesource.com/products/fuse-ide-camel/).

Don't forget to include camel-snmp as a dependency in your pom.xml file if you're using Maven which
should be like this:

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-snmp</artifactId>
    <version>${camel-version}</version>
</dependency>


Enjoy the ride!

Setting Up Local Environment for Developing Oracle Intelligent Bots Custom Components

Oh the joy of having a local development environment is priceless. For most cloud based solutions the story repeats itself being hard to tr...