NCPA Powershell Output

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Post Reply
CameronWP
Posts: 134
Joined: Fri Apr 17, 2015 2:17 pm

NCPA Powershell Output

Post 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!
kg2857
Posts: 490
Joined: Wed Apr 12, 2023 5:48 pm

Re: NCPA Powershell Output

Post 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.
ssunga
Posts: 72
Joined: Wed Aug 09, 2023 10:38 am

Re: NCPA Powershell Output

Post 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!
Post Reply