Not able to Run Powershell Script using NRPE
Not able to Run Powershell Script using NRPE
Hi All,
I am not able to run Powershell script using NRPE, i am getting below error :
[root@VM-NAGIOSXI-TEST libexec]# ./check_nrpe -H 172.26.2.13 -c topcpu
The command (topcpu) returned an invalid return code: -196608
[root@VM-NAGIOSXI-TEST libexec]#
I have changed the powershell excution ploicy to remote signed. I am attaching my nsclient configuration file.
I am not able to run Powershell script using NRPE, i am getting below error :
[root@VM-NAGIOSXI-TEST libexec]# ./check_nrpe -H 172.26.2.13 -c topcpu
The command (topcpu) returned an invalid return code: -196608
[root@VM-NAGIOSXI-TEST libexec]#
I have changed the powershell excution ploicy to remote signed. I am attaching my nsclient configuration file.
You do not have the required permissions to view the files attached to this post.
Re: Not able to Run Powershell Script using NRPE
Your command:
Not sure why you're using the echo, and suspicious of the relative path. You're also piping the string "scripts\resourcecheck.ps1" to powershell, not the contents of resourcesheck.ps1. Run this to see:
You'd need to change it to something like to make it work, but even then you're using cmd.exe and PS, which is a turtle all by itself:
Maybe copy your script to the plugins dir and execute from there:
First get the command to run from any dir in a cmd.exe window before attempting to run from nsclient.
I created a test.ps1 that just ad dir in it and it ran as:
I'd associate ps1 w/ powereshell.exe (if not already done):
Code: Select all
topcpu = cmd /c echo scripts\resourcecheck.ps1; | powershell.exe -command Code: Select all
cmd /c echo scripts\resourcecheck.ps1Code: Select all
cmd /c type c:\path\to\scripts\resourcecheck.ps1Code: Select all
topcpu="powershell.exe C:\Program Files\NSClient++\plugins\resourcecheck.ps1"I created a test.ps1 that just ad dir in it and it ran as:
Code: Select all
powershell.exe test.ps1 and simply test.ps1Code: Select all
topcpu="C:\Program Files\NSClient++\plugins\resourcecheck.ps1"Re: Not able to Run Powershell Script using NRPE
Can you run the "resourcecheck.ps1" script locally, on the Windows machine, and show the output? Do you mind showing the actual script?
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Not able to Run Powershell Script using NRPE
i have modified the path, now i am getting below error :gormank wrote:Your command:Not sure why you're using the echo, and suspicious of the relative path. You're also piping the string "scripts\resourcecheck.ps1" to powershell, not the contents of resourcesheck.ps1. Run this to see:Code: Select all
topcpu = cmd /c echo scripts\resourcecheck.ps1; | powershell.exe -command
You'd need to change it to something like to make it work, but even then you're using cmd.exe and PS, which is a turtle all by itself:Code: Select all
cmd /c echo scripts\resourcecheck.ps1
Maybe copy your script to the plugins dir and execute from there:Code: Select all
cmd /c type c:\path\to\scripts\resourcecheck.ps1
First get the command to run from any dir in a cmd.exe window before attempting to run from nsclient.Code: Select all
topcpu="powershell.exe C:\Program Files\NSClient++\plugins\resourcecheck.ps1"
I created a test.ps1 that just ad dir in it and it ran as:I'd associate ps1 w/ powereshell.exe (if not already done):Code: Select all
powershell.exe test.ps1 and simply test.ps1Code: Select all
topcpu="C:\Program Files\NSClient++\plugins\resourcecheck.ps1"
./check_nrpe -H 172.26.2.13 -c topcpu -t 160
CHECK_NRPE: Received 0 bytes from daemon. Check the remote server logs for error messages.
In nsclient logs i can see the below error :
2016-03-23 04:04:02: error:c:\source\nscp\include\socket/connection.hpp:149: Failed to send data: The file handle supplied is not valid
Re: Not able to Run Powershell Script using NRPE
Paste the following into a cmd prompt window on 172.26.2.13 and paste the result. Don't run it from the plugins dir.
Code: Select all
"C:\Program Files\NSClient++\plugins\resourcecheck.ps1"Re: Not able to Run Powershell Script using NRPE
@CloudOps
Can you zip up your "resourcecheck.ps1" script, and upload it on the forum?
Can you zip up your "resourcecheck.ps1" script, and upload it on the forum?
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Not able to Run Powershell Script using NRPE
when i am running the above command its just pop up the complete script in notepad. any idea?gormank wrote:Paste the following into a cmd prompt window on 172.26.2.13 and paste the result. Don't run it from the plugins dir.
Code: Select all
"C:\Program Files\NSClient++\plugins\resourcecheck.ps1"
Re: Not able to Run Powershell Script using NRPE
Please post the powershell file for us to look at.
Former Nagios Employee
Re: Not able to Run Powershell Script using NRPE
In addition to posting the script try running it:
Code: Select all
powershell.exe "C:\Program Files\NSClient++\plugins\resourcecheck.ps1"Re: Not able to Run Powershell Script using NRPE
Hi gormank/rkennedy,gormank wrote:In addition to posting the script try running it:
Code: Select all
powershell.exe "C:\Program Files\NSClient++\plugins\resourcecheck.ps1"
I have attached the error image. also attaching the script.
Thanks,
You do not have the required permissions to view the files attached to this post.