Page 1 of 1

Problem with send_nsca

Posted: Tue May 18, 2010 9:24 am
by niebais
I thought I set up nsca correctly according to the documentation, but when I run send_nsca I get this message: "0 data packet(s) sent to host successfully"

The nagios.log doesn't show anything.

Here's my client setup:

send_it_out:
#!/bin/sh

HOST=localhost
NSCAHOST=xxx.xxx.xxx.xxx

cat ./test | ./send_nsca -H $NSCAHOST -c /home/nagios/send_nsca.cfg

exit 0

send_nsca.cfg:
encryption_method=1
password="mysupersecretpassword"

test file:
localhost TestMessage 2 This is a Test Error

I read through the documentation. Any ideas on what I'm doing wrong?

Re: Problem with send_nsca

Posted: Tue May 18, 2010 10:08 am
by niebais
Maybe this will help a little:
I changed everything from xinetd over to a regular nsca daemon and started it up. Now when I kick off a command I get the following message in the nagios.log file:
May 18 10:10:41 watcher nsca[467]: Handling the connection...
May 18 10:10:41 watcher nsca[467]: End of connection...

However, I don't see the message that it handled. Is there any way to see what it is doing?

Re: Problem with send_nsca

Posted: Tue May 18, 2010 1:34 pm
by mmestnik
strace is the way to see what things are doing.

For your test file it's hard to tell if it's correct. What's the output of "hexdump -C ./test"?
Alternatively using "tr '\t' '%' < ./test" is a good method to view things better.
Also '<' can some times be used instead of cat, for example:

Code: Select all

< ./test ./send_nsca -H $NSCAHOST -c /home/nagios/send_nsca.cfg
# Here are the other commands.
hexdump -C ./test
< ./test tr '\t' '%'

# Strace example, if using nsca as a daemon substitute it for xinetd:
strace -f -p $(pgrep xinetd)

Re: Problem with send_nsca

Posted: Tue May 18, 2010 2:16 pm
by niebais
Ok, I got the test working on the local machine.

#!/bin/bash

FILE="/home/nagios/bin/test_file"
CFG="/home/nagios/bin/send_nsca.cfg"
COMMAND_OUTPUT_FILE="/home/nagios/bin/output_file.txt"

HOST="mysystem"
SERVICE="mysystem /home disk check"
./check_disk -w 10% -c 5% /home > $COMMAND_OUTPUT_FILE
RC=$?

CMD="mysystem;mysystem /home disk check;0;OK: This is a test message"
/bin/echo "$CMD" | ./send_nsca -H XXX.XXX.XXX.XXX -d ";" -c $CFG

I haven't finished the script above, but it works great sending to the local host. However, now I'm getting a timeout issue when I run the same command from a remote host. I'm still trying to debug that.

Re: Problem with send_nsca

Posted: Tue May 18, 2010 4:10 pm
by niebais
Ok, the problem with the timeout is due to a firewall (not the local iptables firewall either). Got everything working!