Question

I am using Nagios to do a check to see if a Windows machine is in "reboot mode", meaning, patches were installed and the server now needs a reboot. I have 2 PowerShell scripts: The starter script and the processing script.

The starter script checks to see if the server is in reboot mode. If it is, it runs the following command, kicking off the processing script:

Write-Host "Reboot Required"
start-process powershell ".\sched_downtime.ps1 --reboot"
exit 1

If it isn't in reboot mode, it kicks off the following:

write-host "Patches Pending Installation"
start-process powershell ".\sched_downtime.ps1 --update"
exit 1

If I manually run this from the Windows server, everything works just fine. If I try to run this from the Nagios server, using the following command:

check_nrpe -H patching-test -p 5666 -c check_wu_update_status -t 120

Only the first script runs. I cannot seem to get script 1 to kick off script 2 using nrpe, not matter what I put in script 2. It can be something very simple, like creating an empty text file. I am running PowerShell 3 on Windows Server 2008, R2.

Était-ce utile?

La solution

Problem solved. I just had to give it the working directory by adding:

-workingdirectory "c:\path\to\scripts"

Apparently relative path does not work, as it does when I run it manually right from the Windows box.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top