Link to home
Start Free TrialLog in
Avatar of Albert Widjaja
Albert WidjajaFlag for Australia

asked on

Email alert when CPU runs on 100%

Hi,

Can anyone please let me know by using any means necessary (Powershell scripting or any 3rd party application) when my server reach 100% CPU to send out email to myself with the top 3 process ?

As at the moment when my Windows Server 2008 VM runs on 100% CPU, I cannot do remote Desktop into the affected server, so I can only reset it from the VMware vSphere console.
Avatar of Patrick Bogers
Patrick Bogers
Flag of Netherlands image

Hi,

There is Microsoft SCOM2012 which can monitor all your servers, processes, disk space and so on and so on.

Downside is it is tricky to configure.
SOLUTION
Avatar of jimmithakkar
jimmithakkar
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi,

How many servers are you looking to monitor? What is your budget? SCOM2012 might be too expensive for you.

You can configure event forward and collector and configure this rules for notification.

http://msdn.microsoft.com/en-us/library/windows/desktop/bb427443(v=vs.85).aspx

Regards
Avatar of Albert Widjaja

ASKER

Well, SCOM 2012 is too overkill and expensive for me, this is just for one particular server and possible some more incidental only.
Hi,

We use SCOM from our MAPS subscription so this is very low cost.
Overkill is a good argument, maybe Servers Alive is more your tool. We use it for our local HQ network.
Try this code and see if it works for you...
$Threshold = 95
$sleep = 60
$Computer = "ServerA" 
While ($true){
 $cpu = (gwmi -class Win32_Processor -ComputerName $Computer).LoadPercentage
 Write-host "CPU utilization is Currently at $cpu`%"
 If($cpu -ge $Threshold) {
 Write-host "CPU utilization is over threshold at $cpu`%"
 Send-MailMessage –From From@domain.com –To To@domain.com –Subject "CPU Utilization is more than $Threshold`% for $Computer" –Body "CPU Utilization is more than $Threshold`% $Computer : Utilization $cpu`%" –SmtpServer smtp.domain.com
 Sleep $sleep
 }
 Else{
 Write-host "CPU utilization is below threshold”
 Sleep $sleep
 }
}

Open in new window

PS : The script is set for an infinite loop, so it will run until you terminate it manually..
Avatar of compdigit44
compdigit44

Are you using vCenter? If so, you could create an alert for this specific VM when the vCPU usage is very high.
Thanks for the reply Subsun, how can I get the process ID and the service name in the email body ?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial