Page 1 of 1

check_nrpe strange interpretation of output string

Posted: Thu Nov 27, 2014 9:24 am
by habanr
I use Nagios XI 2014R2 on CentOS to monitor Windows server host using NSClient+ 4.1.105. I develop my own diagnostics scripts in PowerShell and I've discovered strange thing...
If my script writes output message:

Code: Select all

Write-Host "Warn:dfdsfd dfsf`n dffd""
then check_nrpe called from the command line returns correct

Code: Select all

Warn:dfdsfd dfsf
 dffd
BUT if my script writes output message that contains pipe symbol ''|' for performance data:

Code: Select all

Write-Host "Warn:dfdsfd | dfsf`n dffd"
then check_nrpe called from the command line returns strange result:

Code: Select all

Warn:dfdsfd |'dfsf
'=0 'dffd'=0
Does anybody knows what is wrong? Thank you for help.

Re: check_nrpe strange interpretation of output string

Posted: Mon Dec 01, 2014 12:24 pm
by tmcdonald
That backtick looks to be interpreted as a backslash. Is that a necessary character in your output? Try removing it and seeing if the output and perfdata are proper.

Re: check_nrpe strange interpretation of output string

Posted: Wed Dec 03, 2014 2:43 am
by habanr
That backtick looks to be interpreted as a backslash
The backtick is escape sequence in the Powershell to enter e.g. new line, tab etc. But the backtick isn't definitely the reason of the problem. The problem appears only if Pipe symbol is part of output string and output is multi-line even without `n but using several Write-Output commands...

Re: check_nrpe strange interpretation of output string

Posted: Wed Dec 03, 2014 10:23 am
by tmcdonald
That actually appears to be technically working even though it isn't doing what you intended. The performance data will be split into new lines just like regular output, so if you replace the `n with a newline, it would break at the end of "dfsf" right before the space and would all be treated as one piece of perfdata.