NSCA Win32 Client - echo problem

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
drocha
Posts: 3
Joined: Thu Jan 16, 2014 11:24 am

NSCA Win32 Client - echo problem

Post by drocha »

I apologize beforehand if this is not the right place to put this.
I am developping an application in Windows with C++ and I want to send the changes from specific hosts to
a remote RedHat machine (system with nagios) through the "NSCA Win32 Client - send_nsca.exe" plugin.
In nagios system, I have passive services associated with the specific hosts.

If I put the information (with send_nsca syntax) in a file and if I make, for example:

Code: Select all

system("send_nsca.exe -H <host_NAGIOS_IP> -c send_nsca.cfg < file.txt");
This works fine. But, if I make:

Code: Select all

char send_nsca[512];
std::string my_string = std::string("<monitoring_hostIP>\t<passive_service>\t0\tOK - Value Received: 1|val=1");
sprintf(send_nsca, "echo %s | send_nsca.exe -H <host_NAGIOS_IP> -c send_nsca.cfg", my_string.c_str());
system((char *)send_nsca);
It gives me the following error:
'val' is not recognized as an internal or external command
If I take away the "|val=1" everything works fine.
The problem is that the echo is processing the '|' character as a 'pipe' and Windows cannot find a 'val' command.

Can you guys please help me with this question?
Thanks.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: NSCA Win32 Client - echo problem

Post by tmcdonald »

Former Nagios employee
drocha
Posts: 3
Joined: Thu Jan 16, 2014 11:24 am

Re: NSCA Win32 Client - echo problem

Post by drocha »

Thanks for replying. I already tried that, but it gives me the following message:
0 data packet(s) sent to host successfully.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: NSCA Win32 Client - echo problem

Post by tmcdonald »

You need to track down the code that outputs the message and add some debugging output to see why the value is not what it should be.
Former Nagios employee
drocha
Posts: 3
Joined: Thu Jan 16, 2014 11:24 am

Re: NSCA Win32 Client - echo problem

Post by drocha »

Thanks for everything. I already found a way. Basically, I open send_nsca.exe with a pipe in write mode and I write the message through the pipe (with the send_nsca syntax).

http://bytes.com/topic/c/answers/646015 ... din-stdout

http://stackoverflow.com/questions/3348 ... -is-closed
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: NSCA Win32 Client - echo problem

Post by sreinhardt »

Interesting way of doing this, but cool. I will lock it up for now.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
Locked