Powershell script

First of all: vbs and nrpe are functioning, my only problem is with Powershell.

I run 2003 server with NRPE_NT 0.8.0. All works great executing vbs-scripts (integrate and extract info via Openmanage on Dell servers for example)

When I try to launch a powershell script (ps1) check_nrpe reports timeout. Task seem to hang on server. I enabled logging on the host and indeed it is a timeout and process powershell is hung (terminated after 30 sec by default).

from the log:
2007-09-26 15:35:00; 3352; 7;Host is asking for command ‘check_kms’ to be run…
2007-09-26 15:35:00; 3352; 7;Running command: c:\windows\system32\WindowsPowerShell\v1.0\powershell.exe -nologo -command c:\latest-kms.ps1
2007-09-26 15:35:30; 3352; 7;Command completed with return code 5
2007-09-26 15:35:30; 3352; 4;Bad return code for [The check didn’t respond within the timeout period!]: 5

I tried cut & paste the command executed by nrpe according to its log. Works perfectly when run interactively in the host.

Figured unicode might be a problem so I disabled output and just returned exit code. No luck.

Changed nrpe-service to run under administrator, no luck.

Question: how to run Powershell scripts from nrpe_nt? I have seen at least one more thread re this.

/// Sample script ///
$a = Get-EventLog “key management service” -newest 1
$m = [RegEx]::Matches($a.message, ‘0x0,25,(.*?),’)
$a.TimeGenerated.DateTime + " host: " + $m[0].groups[1].value

/// nrpe.cfg ///
command[check_kms]=c:\windows\system32\WindowsPowerShell\v1.0\powershell.exe -nologo -command c:\latest-kms.ps1

I have the same problem with PowerShell and NRPE_NT 0.8b (on Win XP SP2).

My Nagios host runs a NRPE plugin on my Windows machine to reload a service if down. On my Windows machine, the process “powershell.exe” is running (by the NRPE server) but it’s not stopped!

Consequently, my Nagios host recovers a timeout after 10, 20, 30 or XX seconds.

Somebody has a solution? :frowning:

In your nrpe.cfg :

In your call.bat :

And the problem is fixed… :wink:

I followed the post by acharrex, and indeed NRPE_NT does run the batch file and the check_nrpe plugin comes back quickly, but I have a question about plugin output… There is none. ‘start’ runs the powershell in a separate Windows window and none of the output from that window comes back to the calling batch file. The intent of NRPE_NT is to run plugins that result in readable output and an exit code.

Has anyone gotten this to work?