3

I am trying to write a unit test of send_nsca using nc but it is failing.

I want to start nc to listen to the nsca port and then use send_ncsa to send a message to that port.

In one terminal I am running:

nc -l 5667 -v

In the other:

echo -e "foo.example.com\ttest\t0\t0" | ./send_nsca -H localhost -p 5667 -c send_nsca.cfg

My send_nsca.cfg file only contains: encryption_method=0.

On the listening terminal I get:

Connection from 10.1.30.23 port 5667 [tcp/*] accepted

But nothing else. On the send_nsca side I get:

Error: Timeout after 10 seconds

Any ideas?

EDIT:

I recompiled the source and enabled DEBUG output:

Connected okay...
Error: Timeout after 10 seconds
Cleaned up encryption routines

From the code I see I am missing the initialization packet containing the IV and timestamp:

#ifdef DEBUG
    printf("Connected okay...\n");
#endif

/* read the initialization packet containing the IV and timestamp */
result=read_init_packet(sd);
if(result!=OK){
    printf("Error: Could not read init packet from server\n");
    close(sd);
    do_exit(STATE_CRITICAL);
        }

#ifdef DEBUG
    printf("Got init packet from server\n");
#endif

Is there any other way to test send_nsca without a full blown nagios installation?

1
  • 3
    Perform a TCPDUMP of a working connection first? I don't know the send_nsca protocol, but are the server just sits there like a dead horse? Does it not have any greetings,salutations, acknowledgements, or other messages the server must send as part of the protocol? If you look at a working capture, you should be able to figure out what you need to make nc do. Your other options is to actually use the source. It should all be very clear in the source code about exactly what send_ncsa is sending and expecting.
    – Zoredache
    Jul 8, 2014 at 18:16

1 Answer 1

1

You don't need a "full blown nagios installation" to test send_nsca...

NSCA is an add-on, and is not part of Nagios core itself. It's packaged as a separate component in Debian/Ubuntu and CentOS (epel or repoforge), for example.

NSCA runs as a daemon or via inetd/xinetd. See the NSCA setup docs for more information about how to run it.

Also, there are several drop-in replacements for NSCA available; NRDP and NSCA-ng may be of interest to you for testing.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .