camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > SNMP
Date Fri, 11 May 2012 06:44:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/2042/9/1/_/styles/combined.css?spaceKey=CAMEL&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/CAMEL/SNMP">SNMP</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~njiang">willem
jiang</a>
    </h4>
        <div id="versionComment">
        <b>Comment:</b>
        CAMEL-5270<br />
    </div>
        <br/>
                         <h4>Changes (1)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >snmp:127.0.0.1:162?protocol=udp&amp;type=TRAP
<br>{code} <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">*From
Camel 2.10.0*,  you can get the community of SNMP TRAP with message header &#39;securityName&#39;,
<br>peer address of the SNMP TRAP with message header &#39;peerAddress&#39;.
<br></td></tr>
            <tr><td class="diff-unchanged" > <br>Routing example in Java:
(converts the SNMP PDU to XML String) <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h2><a name="SNMP-SNMPComponent"></a>SNMP Component</h2>
<p><b>Available as of Camel 2.1</b></p>

<p>The <b>snmp:</b> component gives you the ability to poll SNMP capable
devices or receiving traps.</p>

<p>Maven users will need to add the following dependency to their <tt>pom.xml</tt>
for this component:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;dependency&gt;</span>
    <span class="code-tag">&lt;groupId&gt;</span>org.apache.camel<span
class="code-tag">&lt;/groupId&gt;</span>
    <span class="code-tag">&lt;artifactId&gt;</span>camel-snmp<span
class="code-tag">&lt;/artifactId&gt;</span>
    <span class="code-tag">&lt;version&gt;</span>x.x.x<span class="code-tag">&lt;/version&gt;</span>
    <span class="code-tag"><span class="code-comment">&lt;!-- use the same
version as your Camel core version --&gt;</span></span>
<span class="code-tag">&lt;/dependency&gt;</span>
</pre>
</div></div>

<h3><a name="SNMP-URIformat"></a>URI format</h3>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
snmp:<span class="code-comment">//hostname[:port][?Options]</span>
</pre>
</div></div>
<p>The component supports polling OID values from an SNMP enabled device and receiving
traps.</p>

<p>You can append query options to the URI in the following format, <tt>?option=value&amp;option=value&amp;...</tt></p>

<h3><a name="SNMP-Options"></a>Options</h3>
<div class="confluenceTableSmall"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Default Value </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>type</tt> </td>
<td class='confluenceTd'> none </td>
<td class='confluenceTd'> The type of action you want to perform. Actually you can enter
here <tt>POLL</tt> or <tt>TRAP</tt>. The value <tt>POLL</tt>
will instruct the endpoint to poll a given host for the supplied OID keys. If you put in <tt>TRAP</tt>
you will setup a listener for SNMP Trap Events. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>address</tt> </td>
<td class='confluenceTd'> none </td>
<td class='confluenceTd'> This is the IP address and the port of the host to poll or
where to setup the Trap Receiver. Example: <tt>127.0.0.1:162</tt></td>
</tr>
<tr>
<td class='confluenceTd'> <tt>protocol</tt> </td>
<td class='confluenceTd'> <tt>udp</tt> </td>
<td class='confluenceTd'> Here you can select which protocol to use. You can use either
<tt>udp</tt> or <tt>tcp</tt>. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>retries</tt> </td>
<td class='confluenceTd'> <tt>2</tt> </td>
<td class='confluenceTd'> Defines how often a retry is made before canceling the request.
</td>
</tr>
<tr>
<td class='confluenceTd'> <tt>timeout</tt> </td>
<td class='confluenceTd'> <tt>1500</tt> </td>
<td class='confluenceTd'> Sets the timeout value for the request in millis. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>snmpVersion</tt> </td>
<td class='confluenceTd'> <tt>0</tt> (which means SNMPv1) </td>
<td class='confluenceTd'> Sets the snmp version for the request. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>snmpCommunity</tt> </td>
<td class='confluenceTd'> <tt>public</tt> </td>
<td class='confluenceTd'> Sets the community octet string for the snmp request. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>delay</tt> </td>
<td class='confluenceTd'> <tt>60</tt> seconds </td>
<td class='confluenceTd'> Defines the delay in seconds between to poll cycles. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>oids</tt> </td>
<td class='confluenceTd'> none </td>
<td class='confluenceTd'> Defines which values you are interested in. Please have a
look at the <a href="http://en.wikipedia.org/wiki/Object_identifier" class="external-link"
rel="nofollow">Wikipedia </a> to get a better understanding. 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,1.3.6.1.2.1.25.3.5.1.1.1,1.3.6.1.2.1.43.5.1.1.11.1"
</td>
</tr>
</tbody></table>
</div>
</div>

<h3><a name="SNMP-Theresultofapoll"></a>The result of a poll</h3>

<p>Given the situation, that I poll for the following OIDs:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>OIDs</b></div><div class="codeContent
panelContent">
<pre class="code-java">
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
</pre>
</div></div>

<p>The result will be the following:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>Result of toString conversion</b></div><div
class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;?xml version=<span class="code-quote">"1.0"</span>
encoding=<span class="code-quote">"UTF-8"</span>?&gt;</span>
<span class="code-tag">&lt;snmp&gt;</span>
  <span class="code-tag">&lt;entry&gt;</span>
    <span class="code-tag">&lt;oid&gt;</span>1.3.6.1.2.1.1.3.0<span
class="code-tag">&lt;/oid&gt;</span>
    <span class="code-tag">&lt;value&gt;</span>6 days, 21:14:28.00<span
class="code-tag">&lt;/value&gt;</span>
  <span class="code-tag">&lt;/entry&gt;</span>
  <span class="code-tag">&lt;entry&gt;</span>
    <span class="code-tag">&lt;oid&gt;</span>1.3.6.1.2.1.25.3.2.1.5.1<span
class="code-tag">&lt;/oid&gt;</span>
    <span class="code-tag">&lt;value&gt;</span>2<span class="code-tag">&lt;/value&gt;</span>
  <span class="code-tag">&lt;/entry&gt;</span>
  <span class="code-tag">&lt;entry&gt;</span>
    <span class="code-tag">&lt;oid&gt;</span>1.3.6.1.2.1.25.3.5.1.1.1<span
class="code-tag">&lt;/oid&gt;</span>
    <span class="code-tag">&lt;value&gt;</span>3<span class="code-tag">&lt;/value&gt;</span>
  <span class="code-tag">&lt;/entry&gt;</span>
  <span class="code-tag">&lt;entry&gt;</span>
    <span class="code-tag">&lt;oid&gt;</span>1.3.6.1.2.1.43.5.1.1.11.1<span
class="code-tag">&lt;/oid&gt;</span>
    <span class="code-tag">&lt;value&gt;</span>6<span class="code-tag">&lt;/value&gt;</span>
  <span class="code-tag">&lt;/entry&gt;</span>
  <span class="code-tag">&lt;entry&gt;</span>
    <span class="code-tag">&lt;oid&gt;</span>1.3.6.1.2.1.1.1.0<span
class="code-tag">&lt;/oid&gt;</span>
    <span class="code-tag">&lt;value&gt;</span>My Very Special Printer
Of Brand Unknown<span class="code-tag">&lt;/value&gt;</span>
  <span class="code-tag">&lt;/entry&gt;</span>
<span class="code-tag">&lt;/snmp&gt;</span>
</pre>
</div></div>

<p>As you maybe recognized there is one more result than requested....1.3.6.1.2.1.1.1.0.<br/>
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.</p>


<h3><a name="SNMP-Examples"></a>Examples</h3>

<p>Polling a remote device:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
snmp:192.168.178.23:161?protocol=udp&amp;type=POLL&amp;oids=1.3.6.1.2.1.1.5.0
</pre>
</div></div>

<p>Setting up a trap receiver (<b>Note that no OID info is needed here!</b>):</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
snmp:127.0.0.1:162?protocol=udp&amp;type=TRAP
</pre>
</div></div>
<p><b>From Camel 2.10.0</b>,  you can get the community of SNMP TRAP with
message header 'securityName',<br/>
peer address of the SNMP TRAP with message header 'peerAddress'.</p>

<p>Routing example in Java: (converts the SNMP PDU to XML String)</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"snmp:192.168.178.23:161?protocol=udp&amp;type=POLL&amp;oids=1.3.6.1.2.1.1.5.0"</span>).
convertBodyTo(<span class="code-object">String</span>.class).
to(<span class="code-quote">"activemq:snmp.states"</span>);
</pre>
</div></div>

<h3><a name="SNMP-SeeAlso"></a>See Also</h3>
<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring
Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting
Started</a></li>
</ul>

    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/SNMP">View Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=3474742&revisedVersion=17&originalVersion=16">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/SNMP?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message