PS script for top CPU and Memory Usage

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Post Reply
11abbidoa
Posts: 21
Joined: Wed May 08, 2024 2:03 am

PS script for top CPU and Memory Usage

Post by 11abbidoa »

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
kg2857
Posts: 490
Joined: Wed Apr 12, 2023 5:48 pm

Re: PS script for top CPU and Memory Usage

Post by kg2857 »

exchange.nagios.org
tiffincrane
Posts: 1
Joined: Wed Sep 24, 2025 8:26 pm
Contact:

Re: PS script for top CPU and Memory Usage

Post by tiffincrane »

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

Post by AngeloMileto »

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:

Code: Select all

(Get-Counter '\Process(*)\% Processor Time').CounterSamples
This will get you a list of processes with the CPU usage represented in the CookedValue parameter. So then capturing those:

Code: Select all

(Get-Counter '\Process(*)\% Processor Time').CounterSamples | Where-Object {$_.CoodedValue -gt 0}
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.
Post Reply