This article was written for version 7.3.14 of OP5 Monitor or later.
Articles in the Community-Space are not supported by OP5 Support.
This how-to will guide you to monitor top high cpu processes on Windows using Powershell.
- Working installation of op5 Agent
- Working installation of op5 Monitor
Create Powershell script
This script is intended to be placed on your Windows server and executed over NSClient++. The script that we will use is seen below:
This will be placed in the script folder within the agent installation folder, in this case in: C:\Program Files\op5\NSClient++\scripts\custom
Save the script as top_cpu_processes.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 (or op5.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 saying:
Processes with high CPU: dwm(6.23%) syntpenh(1.56%) svchost(1.56%) svchost(1.56%) chrome(0.78%) msmpeng(0.78%) capiws(0.78%) |'dwm'=6.23% 'syntpenh'=1.56% 'svchost'=1.56% 'svchost'=1.56% 'chrome'=0.78% 'msmpeng'=0.78% 'capiws'=0.78%
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 top_cpu_processes as check_command_args
- Save the configuration.