check_nrpe strange interpretation of output string

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
habanr
Posts: 3
Joined: Wed Nov 05, 2014 6:52 am

check_nrpe strange interpretation of output string

Post 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.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: check_nrpe strange interpretation of output string

Post 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.
Former Nagios employee
habanr
Posts: 3
Joined: Wed Nov 05, 2014 6:52 am

Re: check_nrpe strange interpretation of output string

Post 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...
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: check_nrpe strange interpretation of output string

Post 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.
Former Nagios employee
Locked