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");
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);
If I take away the "|val=1" everything works fine.'val' is not recognized as an internal or external command
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.