Page 1 of 1

NCPA Powershell Output

Posted: Mon Nov 06, 2023 3:56 pm
by CameronWP
Hi:

I wrote a Powershell script to check AD Connect Sync results and the script works fine on the server. I want the script to return multiple lines but I can only get it to return one. My output is here:

write-host "There were errors in the last export"
$objects |out-string | % {write-host $_ }

So, if working it would return the first line and then a small table below it. I can't for the life of me get it to return the table, only that first line. What am I missing here?

Thanks!

Re: NCPA Powershell Output

Posted: Tue Nov 07, 2023 12:58 am
by kg2857
The nagios documentation if you read it says plugins should produce a single line of output. If running the plugin from the shell produces the output you desire, but running it from ncpa via the nagios server doesn't it seems that ncpa is enforcing the nagios requirements.
BTW nrpe will happily produce multi-line output which is displayed in the nxi gui. That doesn't mean that ncpa is misbehaving.

Re: NCPA Powershell Output

Posted: Fri Dec 08, 2023 7:01 pm
by ssunga
Hey,

It sounds like there's an issue with how `$objects` is being handled. Try this modified version of your script:

Code: Select all

write-host "There were errors in the last export"
$objects | ForEach-Object {write-host $_}
This should output each element of `$objects` on a new line. If it still doesn’t work, the problem might be with how `$objects` is being populated. Keep us updated!