Hello,
I have installed Nagios and NSCS, I managed to send a notification using the send_nscs command and I can see the message arriving on the logs
/var/log/nagios/nagios.log
also, I can see it on the web console.
however, when I try to run an example using the NagiosAppender to send a message to the Nagios, the program seems to block and never exits. so I found a patch on this site that adds a socket timeout and now it doesn't seem to block but I never see anything in the nagios log file or the webconsole.
here is my log4j.properties, I can see the messages goes to the console so the log4j.properties file is being picked up fine
log4j.rootLogger=debug,CONSOLE,NAGIOS
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%d [%t] %-5p (%F:%L) - %m%n
log4j.appender.NAGIOS=org.apache.log4j.nagios.NagiosAppender
log4j.appender.NAGIOS.MaxBufferSize=1000
log4j.appender.NAGIOS.Host=localhost
log4j.appender.NAGIOS.Port=5667
log4j.appender.NAGIOS.Timeout=5000
log4j.appender.NAGIOS.layout.ConversionPattern=%X{nagios_canonical_hostname}: %-5p [%c{1}] %m%n
log4j.appender.NAGIOS.ConfigFile=/home/user/nsca_appender_src/src/conf/nsca_send_xor.cfg
log4j.appender.NAGIOS.ServiceNameDefault=TestMessage
log4j.appender.NAGIOS.useShortHostName=true
log4j.appender.NAGIOS.useMDCHostName=false
log4j.appender.NAGIOS.MDCHostNameKey=nagios_host_name
log4j.appender.NAGIOS.InitializeMDCHostNameValue=csx
log4j.appender.NAGIOS.Log4j_Level_WARN=NAGIOS_WARN
log4j.appender.NAGIOS.Log4j_Level_ERROR=NAGIOS_CRITICAL
log4j.appender.NAGIOS.Log4j_Level_FATAL=NAGIOS_CRITICAL
log4j.appender.NAGIOS.SendStartupMessageOK=Application Starting
log4j.appender.NAGIOS.MDCCanonicalHostNameKey=nagios_canonical_hostname
log4j.appender.NAGIOS.layout=org.apache.log4j.PatternLayout
I have used another library called jsendnsca on googlecode and seems to work fine when I run the following
NagiosSettings settings = new NagiosSettingsBuilder()
.withNagiosHost("localhost")
.withPort(5667)
.withEncryption(Encryption.XOR)
.create();
MessagePayload payload = new MessagePayloadBuilder() .withHostname("localhost") .withLevel(Level.OK) .withServiceName("TestMessage") .withMessage("issue happened") .create(); NagiosPassiveCheckSender sender = new NagiosPassiveCheckSender(settings); try { sender.send(payload); System.out.println("Done!"); } catch (NagiosException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }