Page 1 of 1

Escape characters for NSCA passive check

Posted: Thu Oct 26, 2017 7:02 am
by Dearl1988
I'm running a powershell script to tell Nagios Core about an event using NSCA so it checks passively for the event.

This is the piece of code I'm running on my powershell script.

Code: Select all

nscp client --module NSCAClient host=serverIP port=5667 sender-host="WindowsServer_Name" encryption=XOR command="myService" result=1 message="somePowerShellVariable"
What I basically want is a kind of help on the command option "message"... I want it to accept escape characters such those used in C like \n or in powershell such as `n... I want to do a new line so it displays more information on that block.

Re: Escape characters for NSCA passive check

Posted: Thu Oct 26, 2017 4:33 pm
by npolovenko
Hello, @Dearl1988. As far as I know, Nagios should accept \n newline character in the status information field. Have you tried that? I think it's using PHP for the front end so most characters supported in PHP they should work in Nagios.

Re: Escape characters for NSCA passive check

Posted: Mon Oct 30, 2017 8:02 am
by Dearl1988
It was actually a lot easier than I thought, I asked my boss about it and he said it should accept HTML tags, so guess what?!

It worked with <br>

But, many characters were not acceptable as arguments passing through like \, _, -, |, "

Any guess how I can override this?

Re: Escape characters for NSCA passive check

Posted: Mon Oct 30, 2017 1:47 pm
by npolovenko
@Dearl1988 , Glad that worked for you. Yes, so basically those plugin output fields will accept most of the HTML characters. But I don't think it's possible to make special characters from C be recognized in that context. If your goal is just to be able to pass these characters as a string then you could try to use some standard escape characters like \, you could try wrapping your message in single quotes, etc. Or is there any way to configure your NSCA check to return the output without special characters?