0

I've implemented JSend NSCA to send passive checks to Nagios like below:

 public static void main(String[] args) {
    NagiosSettings nagiosSettings = new NagiosSettingsBuilder()
            .withNagiosHost("192.168.1.20")
            .withPassword("nagiosadmin")
            .withPort(5666)
            .withConnectionTimeout(5000)
            .withResponseTimeout(15000)
            .create();
    NagiosPassiveCheckSender sender = new NagiosPassiveCheckSender(
            nagiosSettings);

    MessagePayload payload = new MessagePayloadBuilder()
            .withHostname("localhost")
            .withLevel(Level.CRITICAL)
            .withServiceName("Test Service Name")
            .withMessage("Test Message")
            .create();

    try {
        sender.send(payload);
    } catch (NagiosException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

But I had the following errors:

java.net.ConnectException: Connection refused at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351) at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:432) at java.net.Socket.connect(Socket.java:529) at com.googlecode.jsendnsca.core.NagiosPassiveCheckSender.send(NagiosPassiveCheckSender.java:69) at app.QuickStart.main(QuickStart.java:29) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

Nagios Username and password are: nagiosadmin/nagiosadmin.

The IPserver for nagios is 192.168.1.20.

Thank you.

1 Answers1

1

Can you try a quick telnet test

From your command line run

telnet 192.168.1.20 5666

If the response is

Connecting To 192.168.1.20...Could not open connection to the host, on port 5666: Connect failed

Then the NSCA daemon is either

  • not running
  • running on a different port other than 5666

BTW, Im the project lead for jsendnsca. In future, you can post questions like this at

https://code.google.com/p/jsendnsca/issues/list

and create an issue

Raj Patel
  • 11
  • 1