camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > Nagios
Date Thu, 28 Jan 2010 03:08:00 GMT
<html>
<head>
    <base href="http://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1519/1/1/_/styles/combined.css?spaceKey=CAMEL&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background-color: white" bgcolor="white">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="http://cwiki.apache.org/confluence/display/CAMEL/Nagios">Nagios</a></h2>
    <h4>Page  <b>added</b> by             <a href="http://cwiki.apache.org/confluence/display/~davsclaus">Claus
Ibsen</a>
    </h4>
         <br/>
    <div class="notificationGreySide">
         <h2><a name="Nagios-Nagios"></a>Nagios</h2>
<p><b>Available as of Camel 2.2</b></p>

<p>The <a href="/confluence/display/CAMEL/Nagios" title="Nagios">Nagios</a>
component allows you to send passive checks to <a href="http://nagios.org" rel="nofollow">Nagios</a>.</p>


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

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
nagios:<span class="code-comment">//host[:port][?Options]</span>
</pre>
</div></div>

<p>Camel provides two abilities with the <a href="/confluence/display/CAMEL/Nagios"
title="Nagios">Nagios</a> component. You can send passive check messages by sending
a message to its endpoint.<br/>
Camel also provides a <a href="/confluence/display/CAMEL/Camel+JMX" title="Camel JMX">EventNotifer</a>
which allows you to send notifications to Nagios.</p>

<h3><a name="Nagios-Options"></a>Options</h3>
<div class="confluenceTableSmall"><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>host</tt> </td>
<td class='confluenceTd'> none </td>
<td class='confluenceTd'> This is the address of the <a href="/confluence/display/CAMEL/Nagios"
title="Nagios">Nagios</a> host where checks should be send. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>port</tt> </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> The port number of the host. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>password</tt> </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> Password to be authenticated when sending checks to Nagios.
</td>
</tr>
<tr>
<td class='confluenceTd'> <tt>connectionTimeout</tt> </td>
<td class='confluenceTd'> 5000 </td>
<td class='confluenceTd'> Connection timeout in millis. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>timeout</tt> </td>
<td class='confluenceTd'> 5000 </td>
<td class='confluenceTd'> Sending timeout in millis. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>nagiosSettings</tt> </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> To use an already configured <tt>com.googlecode.jsendnsca.core.NagiosSettings</tt>
object. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>sendSync</tt> </td>
<td class='confluenceTd'> <tt>true</tt> </td>
<td class='confluenceTd'> Whether or not to use synchronous when sending a passive check.
Setting it to <tt>false</tt> will allow Camel to continue routing the message
and the passive check message will be send asynchronously. </td>
</tr>
</tbody></table></div>

<h3><a name="Nagios-Headers"></a>Headers</h3>
<div class="confluenceTableSmall"><table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelNagiosHostName</tt> </td>
<td class='confluenceTd'> This is the address of the <a href="/confluence/display/CAMEL/Nagios"
title="Nagios">Nagios</a> host where checks should be send. This header will override
any existing hostname configured on the endpoint. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelNagiosLevel</tt> </td>
<td class='confluenceTd'> This is the severity level. You can use values <tt>CRITICAL,
WARNING, OK</tt>. Camel will by default use <tt>OK</tt>. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelNagiosServiceName</tt> </td>
<td class='confluenceTd'> The servie name. Will default use the <a href="/confluence/display/CAMEL/CamelContext"
title="CamelContext">CamelContext</a> name. </td>
</tr>
</tbody></table></div>


<h3><a name="Nagios-Sendingmessageexamples"></a>Sending message examples</h3>
<p>You can send a message to Nagios where the message payload contains the message.
By default it will be <tt>OK</tt> level and use the <a href="/confluence/display/CAMEL/CamelContext"
title="CamelContext">CamelContext</a> name as the service name. You can overrule
these values using headers as shown above.</p>

<p>For example we send the <tt>Hello Nagios</tt> message to Nagios as follows:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
    template.sendBody(<span class="code-quote">"direct:start"</span>, <span
class="code-quote">"Hello Nagios"</span>);

    from(<span class="code-quote">"direct:start"</span>).to(<span class="code-quote">"nagios:127.0.0.1:5667?password=secret"</span>).to(<span
class="code-quote">"mock:result"</span>);
</pre>
</div></div>

<p>To send a <tt>CRITICAL</tt> message you can send the headers such as:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
        Map headers = <span class="code-keyword">new</span> HashMap();
        headers.put(NagiosConstants.LEVEL, <span class="code-quote">"CRITICAL"</span>);
        headers.put(NagiosConstants.HOST_NAME, <span class="code-quote">"myHost"</span>);
        headers.put(NagiosConstants.SERVICE_NAME, <span class="code-quote">"myService"</span>);
        template.sendBodyAndHeaders(<span class="code-quote">"direct:start"</span>,
<span class="code-quote">"Hello Nagios"</span>, headers);
</pre>
</div></div>

<h3><a name="Nagios-Using%7B%7BNagiosEventNotifer%7D%7D"></a>Using <tt>NagiosEventNotifer</tt></h3>
<p>The <a href="/confluence/display/CAMEL/Nagios" title="Nagios">Nagios</a>
component also provides an <a href="/confluence/display/CAMEL/Camel+JMX" title="Camel JMX">EventNotifer</a>
which you can use to send events to Nagios. For example we can enable this from Java as follows:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
        NagiosEventNotifier notifier = <span class="code-keyword">new</span> NagiosEventNotifier();
        notifier.getConfiguration().setHost(<span class="code-quote">"localhost"</span>);
        notifier.getConfiguration().setPort(5667);
        notifier.getConfiguration().setPassword(<span class="code-quote">"password"</span>);

        CamelContext context = ... 
        context.getManagementStrategy().addEventNotifier(notifier);
        <span class="code-keyword">return</span> context;
</pre>
</div></div>

<p>In Spring XML its just a matter of defining a Spring bean with the type <tt>EventNotifier</tt>
and Camel will pick it up as documented here: <a href="/confluence/display/CAMEL/Advanced+configuration+of+CamelContext+using+Spring"
title="Advanced configuration of CamelContext using Spring">Advanced configuration of CamelContext
using Spring</a>.</p>

<h3><a name="Nagios-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="http://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
       </div>
       <a href="http://cwiki.apache.org/confluence/display/CAMEL/Nagios">View Online</a>
              |
       <a href="http://cwiki.apache.org/confluence/display/CAMEL/Nagios?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
           </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message