Jump to content
Willipmeister

Prolonged CPU usage monitoring

Recommended Posts

I’d like to setup alerting on server performance, such as high CPU/memory usage. I’ve created an internal monitor which does this, but it obviously picks up all spikes. Is there a way of alerting only if the cpu/memory usage is excessive for over 5 minutes? This way avoiding just momentary spikes...

Any ideas would be greatefully received 😊

  • Like 1

Share this post


Link to post
Share on other sites

I have the CPU monitor working ok using a remote monitor for CPU % usage, but I haven't found a way to do it for Memory. Memory doesn't seem to have a % Usage variable, so I am hoping to figure something out there.

Share this post


Link to post
Share on other sites

This is what "smoothing" is meant to address. Unfortunately I have only recently begun exploring this and don't have any specific guidance handy.

Share this post


Link to post
Share on other sites

Darren is the master of the craft so maybe my poorly written monitor could be something improved upon.  I have attached some screenshots and the code below.
My monitor is designed to be reviewed on a HUD where I look to see what application is eating up memory for the customer.  It's not running on all customers as I only deploy it when I am trying to track down what process is using large amounts of memory and allows me an instant view into multiple computers via a dataview/hud.

The monitor does not create any alerts, but rather uses PowerShell to grab the process currently using the most RAM on the system and just spits out the process name and the value in MB.  It's not super smart and does not handle things like 14 Chrome processes each using 250 MB per process but rather whatever single process is using the most RAM.  There's probably a better way to do this but its worked for me in finding customers where I can cross reference another monitor I use that checks for >80% CPU usage over 20 minutes, etc.

Command line for monitor:

%windir%\system32\WindowsPowerShell\v1.0\powershell.exe -executionpolicy BYPASS -command "(Get-Process | where {$_.ProcessName -notmatch 'Memory Compression'} | Sort-Object WorkingSet | Select-Object Name,@{n='Value';e={[Math]::Round($_.WS / 1MB,0)}},@{Name='Mem';Expression={'MB'}} -Last 1 | Format-Table -hidetableheaders | Out-String).trim()"

 

Command if you want to just test on any computer in PowerShell:

Get-Process | where {$_.ProcessName -notmatch 'Memory Compression'} | Sort-Object WorkingSet | Select-Object Name,@{n='Value';e={[Math]::Round($_.WS / 1MB,0)}},@{Name='Mem';Expression={'MB'}} -Last 1 | Format-Table -hidetableheaders

image.png.1a9ade9979b4e0131d38119cf0dae679.png

image.png.5898711a79a08f13727fc4b91d6c143b.png

image.png.997e0a148cd938de8415ee52977c9894.png

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×