This procedure is unsupported.Articles in the "Unsupported Community Documents" space are not supported by ITRS support.
This article was written for version 7.0 of Monitor, it could work on both lower and higher version if nothing else is stated.
This how-to will show you how to execute a powershell script via the op5 Agent.
- 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
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
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
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
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.