kafelez / jsendnsca

Automatically exported from code.google.com/p/jsendnsca
0 stars 0 forks source link

Getting java.net.SocketTimeoutException: connect timed out while connecting to Nagios #41

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,

I'm Getting java.net.SocketTimeoutException: connect timed out while connecting 
to Nagios

The version i'm using is 2.0.1

Here is the code 

import java.io.IOException;

import main.java.com.googlecode.jsendnsca.Level;
import main.java.com.googlecode.jsendnsca.MessagePayload;
import main.java.com.googlecode.jsendnsca.NagiosException;
import main.java.com.googlecode.jsendnsca.NagiosPassiveCheckSender;
import main.java.com.googlecode.jsendnsca.NagiosSettings;
import main.java.com.googlecode.jsendnsca.builders.MessagePayloadBuilder;
import main.java.com.googlecode.jsendnsca.builders.NagiosSettingsBuilder;
import main.java.com.googlecode.jsendnsca.encryption.Encryption;

/**
 * Quick start example code used in documentation
 */
public class QuickStart {

    /**
     * Creates {@link NagiosSettings}, {@link MessagePayload} using builders and sends
     * using {@link NagiosPassiveCheckSender}
     * @param args
     */
    public static void main(String[] args) {

        NagiosSettings settings = new NagiosSettingsBuilder()
            .withNagiosHost("10.0.200.236")
            .withPort(5667) // you don't really need to set this as 5667 is default
            .withEncryption(Encryption.XOR)
            .create();

        MessagePayload payload = new MessagePayloadBuilder()
            // you can use .withLocalHostname() or withCanonicalHostname to determine
            // your short and fully qualified domain name respectively for you instead of .withHostname

            .withHostname("SPICITY700")
            .withLevel(Level.OK)
            .withServiceName("httpd")
            .withMessage("should work if everything set up OK")
            .create();

        NagiosPassiveCheckSender sender = new NagiosPassiveCheckSender(settings);

        try {
            sender.send(payload);
        } catch (NagiosException e) {
            System.out.println("Exception "+e);
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Original issue reported on code.google.com by raghuram...@gmail.com on 31 Oct 2012 at 12:13

GoogleCodeExporter commented 8 years ago
Can you see my suggestions on 
http://code.google.com/p/jsendnsca/issues/detail?id=40

Original comment by rajneeshpatel on 31 Oct 2012 at 8:05

GoogleCodeExporter commented 8 years ago
Hi Rajneesh,

I had gone through your comment.. I am trying to set up the NSCA and facing 
some issues..

Firstly i have my Nagios running at ip 10.0.200.236
My local ip is 10.0.200.16.
I did all the steps that are mentioned in the setup manual (pdf file)  that is 
i have configured the server_address to 10.0.200.236 ..i wanted to know 
wheather this is correct or not.

one more thing is,
 when i try to telnet 10.0.200.236 it tells..
Trying 127.0.0.1... 
Connected to localhost. 
Escape character is '^]'.
Connection closed by a foreign host...
What may be the issue

Original comment by raghuram...@gmail.com on 5 Nov 2012 at 5:55

GoogleCodeExporter commented 8 years ago
Couple of things 

Did you try "telnet 10.0.200.236 5667" (assuming you have nsca daemon running 
on 5667)

Only your last comment says "telnet 10.0.200.236" and without the port, it 
defaults to port 23

Another thing is do you have a systems administrator who can help you out. 

Reason is that more often or not, a firewall is in place and is blocking port 
5667

Unfortunately, Im unable to provide help further with network issues as really 
need access to machines to help out with that. Again, reach out to a systems 
admin or infrastructure expert who should be able to sort these issues out for 
you pretty quickly

Best of luck

Original comment by rajneeshpatel on 5 Nov 2012 at 10:22

GoogleCodeExporter commented 8 years ago

Original comment by rajneeshpatel on 6 Nov 2012 at 4:36