我已经实施了JSend NSCA,将被动检查发送到Nagios,如下所示:
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();
}
}
但我有以下错误:
java.net.ConnectException:连接被拒绝 at java.net.PlainSocketImpl.socketConnect(Native Method) 在java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351) 在java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213) 在java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200) 在java.net.SocksSocketImpl.connect(SocksSocketImpl.java:432) 在java.net.Socket.connect(Socket.java:529) 在com.googlecode.jsendnsca.core.NagiosPassiveCheckSender.send(NagiosPassiveCheckSender.java:69) 在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) 在java.lang.reflect.Method.invoke(Method.java:597) 在com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Nagios用户名和密码为:nagiosadmin / nagiosadmin。
nagios的IPserver是192.168.1.20。
谢谢。
答案 0 :(得分:1)
您可以尝试快速的telnet测试
从命令行运行
telnet 192.168.1.20 5666
如果回复是
连接到192.168.1.20 ...无法打开与主机的连接,在端口5666上:连接失败
然后NSCA守护进程
https://code.google.com/p/jsendnsca/issues/list
并创建问题