This procedure is unsupported.
Articles in the "Unsupported Community Documents" space are not supported by ITRS support.Version
This article was written for version 7.0 of Monitor, it could work on both lower and higher version if nothing else is stated.
Introduction
This how-to will show you how to execute a powershell script via the op5 Agent.
Prerequisites
- Working installation of op5 Agent
- Working installation of op5 Monitor
Create powerShell script
First we need to create a powershell script or use an existing one. In this example we will use a simple Hello World script.
The script that we will use is
Write-Host "Hello World! `n"
This will be placed in the script folder within the agent installation folder, in this case in: C:\Program Files\op5\NSClient++\scripts\
Save the script as hello.ps1
Add the script to op5 Agent
To make the op5 Agent aware of the script and how it should be executed we need to add a handler for it in the agent configuration.
Open the file custom.ini located in C:\Program Files\op5\NSClient++\ and add the following rows
[NRPE Handlers]hello=cmd /c echo scripts\hello.ps1; exit $LastExitCode | powershell.exe -noprofile -nologo -command -
Set ExecutionPolicy
Due to restrictions in powershell we are not allowed to run this file without changing the execution policy for powershell scripts.
In this example we will change the policy to unrestricted but this is not recommended for normal use. For more information about Execution Policy see http://technet.microsoft.com/library/hh847748.aspx.
Open powershell prompt as administrator and run
PS C:\Windows\system32> Set-ExecutionPolicy unrestricted
Answer Y on the question.
Run script from op5 Monitor console
This step is not necessary, but can be good before continuing just to make sure everything is working before change the configuration.
Log in to op5 Monitor via console or SSH.
Run the following command to test the powershell script
# /opt/plugins/check_nrpe -H 192.168.1.198 -c hello
If everything is working you should get the response "Hello World!"
Adding script to a host
Go to the configuration of a host in op5 Monitor and add a new service.
- Enter a Service Description of you choice
- Select check_nrpe as check_command
- Enter hello as check_command_args
- Save the configuration.
Comments
0 comments
Please sign in to leave a comment.