We are 99% windows and our agents is NSClient++.
The monitoring only provide alerts for high cpu or memory.
Anyone here have good scripts to capture the top 5 or 10 services using the CPU or Memory?
It should capture the service name, pid and the comsumed resrouces in percentage.
Thanks in advance
PS script for top CPU and Memory Usage
Re: PS script for top CPU and Memory Usage
exchange.nagios.org
-
tiffincrane
- Posts: 1
- Joined: Wed Sep 24, 2025 8:26 pm
- Contact:
Re: PS script for top CPU and Memory Usage
oh i want this script too! thanks!
-
AngeloMileto
- Posts: 70
- Joined: Mon Mar 21, 2022 7:53 am
Re: PS script for top CPU and Memory Usage
If you know how to create custom plugins, just make a quick powershell script and call that from XI. Unless there is a way to just execute PowerShell directly from XI.
Anyway, the PowerShell is simple:
This will get you a list of processes with the CPU usage represented in the CookedValue parameter. So then capturing those:
You could then filter out the idle and _total entries and sort/display whatever you want from there. Not sure what value that is in monitoring as it will report all the time even when CPU usage isn't high - unless you code it that way.
This should get you a start.
Anyway, the PowerShell is simple:
Code: Select all
(Get-Counter '\Process(*)\% Processor Time').CounterSamplesCode: Select all
(Get-Counter '\Process(*)\% Processor Time').CounterSamples | Where-Object {$_.CoodedValue -gt 0}This should get you a start.