Nagios

Table of Contents

URI format
Options
Sending message examples
Using NagiosEventNotifer
See Also

Available as of Camel 2.3

The Nagios component allows you to send passive checks to Nagios.

Maven users will need to add the following dependency to their pom.xml for this component:

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-nagios</artifactId>
    <version>x.x.x</version>
    <!-- use the same version as your Camel core version -->
</dependency>

URI format

nagios://host[:port][?Options]

Camel provides two abilities with the Nagios component. You can send passive check messages by sending a message to its endpoint. Camel also provides a EventNotifer which allows you to send notifications to Nagios.

Options

The Nagios component supports 1 options which are listed below.

{% raw %}

NameJava TypeDescription

configuration

NagiosConfiguration

To use a shared NagiosConfiguration

{% endraw %}

The Nagios component supports 8 endpoint options which are listed below:

{% raw %}

NameGroupDefaultJava TypeDescription

host

producer

 

String

Required This is the address of the Nagios host where checks should be send.

port

producer

 

int

Required The port number of the host.

connectionTimeout

producer

5000

int

Connection timeout in millis.

encryptionMethod

producer

 

NagiosEncryptionMethod

To specify an encryption method.

password

producer

 

String

Password to be authenticated when sending checks to Nagios.

sendSync

producer

true

boolean

Whether or not to use synchronous when sending a passive check. Setting it to false will allow Camel to continue routing the message and the passive check message will be send asynchronously.

timeout

producer

5000

int

Sending timeout in millis.

synchronous

advanced

false

boolean

Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported).

{% endraw %}

Sending message examples

You can send a message to Nagios where the message payload contains the message. By default it will be OK level and use the CamelContext name as the service name. You can overrule these values using headers as shown above.

For example we send the Hello Nagios message to Nagios as follows:

    template.sendBody("direct:start", "Hello Nagios");

    from("direct:start").to("nagios:127.0.0.1:5667?password=secret").to("mock:result");

To send a CRITICAL message you can send the headers such as:

        Map headers = new HashMap();
        headers.put(NagiosConstants.LEVEL, "CRITICAL");
        headers.put(NagiosConstants.HOST_NAME, "myHost");
        headers.put(NagiosConstants.SERVICE_NAME, "myService");
        template.sendBodyAndHeaders("direct:start", "Hello Nagios", headers);

Using NagiosEventNotifer

The Nagios component also provides an EventNotifer which you can use to send events to Nagios. For example we can enable this from Java as follows:

        NagiosEventNotifier notifier = new NagiosEventNotifier();
        notifier.getConfiguration().setHost("localhost");
        notifier.getConfiguration().setPort(5667);
        notifier.getConfiguration().setPassword("password");

        CamelContext context = ...
        context.getManagementStrategy().addEventNotifier(notifier);
        return context;

In Spring XML its just a matter of defining a Spring bean with the type EventNotifier and Camel will pick it up as documented here: Advanced configuration of CamelContext using Spring.

See Also