...
|
The ServiceMix SNMP component provides support for receiving [SNMP|http://en.wikipedia.org/wiki/SNMP] events via the enterprise service bus by using the [SNMP4J|http://www.snmp4j.org] library.
|
{note:title=Availability} Note that this component is only available in releases >= 3.3. {note}
|
h2. Maven Archetype
|
|
h2. Installation
|
You can use Maven servicemix-snmp-service-unit archetype to create a SNMP service unit:
|
|
Installing the servicemix-snmp component can be done in several ways: * drop the installer zip in an hotdeploy directory monitored by ServiceMix * using [ant tasks|Ant Tasks]
|
{code} mvn archetype:create \ -DarchetypeGroupId=org.apache.servicemix.tooling \ -DarchetypeArtifactId=servicemix-snmp-service-unit \ -DarchetypeVersion=2010.01 \ -DgroupId=your.group.id \ -DartifactId=your.artifact.id \ -Dversion=your-version {code}
|
|
Note that when using ant tasks, the component is not started, you will have to start it manually using ant tasks or a console.
|
Once you've customized the service unit, simply install the SU:
|
|
{code} mvn install {code}
|
|
h2. Creation
|
{info}
|
You can use Maven to create a service unit.
|
Remember that to be deployable in ServiceMix, the ServiceUnit has to be embedded in a Service Assembly: only the Service Assembly zip file can be deployed in ServiceMix. To add your SU in a SA, you need to define it in the dependency sets:
|
{code}
|
mvn archetype:create \ -DarchetypeGroupId=org.apache.servicemix.tooling \ -DarchetypeArtifactId=servicemix-snmp-service-unit \ -DgroupId=com.mycompany.myproduct \
|
-DartifactId=mycomponent.artifact <dependency>
|
<groupId>your.group.id</groupId> <artifactId>your.artifact.id</artifactId> <version>your-version</version> </dependency>
|
{code}
|
{info}
|
|
h2. Endpoints Configuration
|
|
h2. Endpoints
|
h3. Poller Endpoint (Consumer)
|
|
{code:lang=xml|title=Polling (consumer) endpoint}
|
The SNMP Poller endpoint periodically poll a SNMP server to get event and generate messages sent to the NMR. {note} The SNMP Poller endpoint will only generate InOnly exchanges. {note} {code:lang=xml|title=Poller (Consumer) Endpoint}
|
<snmp:poller service="test:mySNMPService" endpoint="pollerEndpoint"
|
...
|
{code}
|
{info:title=Poller Endpoint Attributes|borderStyle=solidbgColor='lighblue'} || Name || Type || Description || Default || | oids | OIDList | sets the resource containing all OIDs to poll | null (must be spec'd) | | address | String | the address to use for snmp connection | null (must be spec'd) | | marshaler | class | org.apache.servicemix.snmp.marshaler.SnmpMarshalerSupport | DefaultSnmpMarshaler | | retries | int | the retries for requesting the values via snmp | 2 | | timeout | long | the timeout in millis for a request to be answered | 1500 | | snmpVersion | int | the snmp version to use (see SnmpConstants) | 0 (v1) | | snmpCommunity | String | the snmp community | "public" | {info} h3. Trap Consumer Endpoint The SNMP Trap Consumer endpoint waits for incoming SNMP messages.
|
{code:lang=xml|title=Trap consumer endpoint} <snmp:trap-consumer service="test:mySNMPService"
|
...
|
{code}
|
h2. Consumer Endpoint (Polling) {note:title=Message Exchange Pattern} The poller endpoint will only generate InOnly exchanges. {note} The following table shows the additional configuration possibilities of the endpoint other than the configuration of the default *PollingEndpoint* class.
|
{info:title=Poller endpoint attributes|borderStyle=solidbgColor='lighblue'} || Name || Type || Description || Default ||
|
| oids | OIDList | sets the resource containing all OIDs to poll | null (must be spec'd) |
|
| address | String | the address to use for snmp connection | null (must be spec'd) | | marshaler | class | org.apache.servicemix.snmp.marshaler.SnmpMarshalerSupport | DefaultSnmpMarshaler |
|
| retries | int | the retries for requesting the values via snmp | 2 | | timeout | long | the timeout in millis for a request to be answered | 1500 | | snmpVersion | int | the snmp version to use (see SnmpConstants) | 0 (v1) | | snmpCommunity | String | the snmp community | "public" |
|
{info}
|
|
|
h3. The "oids" list You can specify here a comma separated list of OIDs or just reference to a resource containing a list of OIDs separated by line feeds.
|
...
|
{code}
|
{code:lang=xml|title=Specifying OIDs directly} <snmp:poller service="test:mySNMPService"
|
...
|
{code}
|
h3. The address The address has to be specified in the following way:
|
...
|
{noformat}
|
{info:title=Poller endpoint attributes|borderStyle=solidbgColor='lighblue'} || Name || Description || | protocol | the protocol to use (udp / tcp)| | ip-address | the ip address of the device to poll from| | port | the port number| {info} h2. Trap Consumer Endpoint The trap consumer endpoint waits for incoming SNMP messages. {info:title=Poller endpoint attributes|borderStyle=solidbgColor='lighblue'} || Name || Type || Description || Default || | address | String | the address to use for snmp connection | null (must be spec'd) | | marshaler | class | org.apache.servicemix.snmp.marshaler.SnmpMarshalerSupport | DefaultSnmpMarshaler | {info} h2. Provider Endpoint (Sending) {note:title=Availability} There is no sender endpoint yet. {note} For all xbean file endpoint configuration take a look at [Xml schemas]
|
h2. Marshalers You can write your own marshalers for conversion between snmp and normalized message. To do this you simply need to implement the *org.apache.servicemix.snmp.marshaler.SnmpMarshalerSupport* interface or by creating a subclass of the *DefaultSnmpMarshaler* if you do not want to start from scratch.
|
h3. The SnmpMarshalerSupport interface For providing your own marshaler you only need to implement a single method:
|
h4. convertToJBI(...) This method is responsible for translating a received snmp response into a jbi compliant normalized message ready to be sent to the bus.
|
...
|