Asked by:
How can i get email alert when IIS used more than 80% CPU

Question
-
User-2031064791 posted
How can i get email alert when IIS used more than 80% CPU
Wednesday, January 30, 2013 8:09 AM
All replies
-
User-1499466209 posted
Hi,
for a larger scope you can get this things (and many other) with a monitoring system.
If you want an alert ONLY when your worker process (or the sum for all of them if not only one) use more than 80% of CPU, it could be done pretty simply with a scheduled powershell script processing some WMI measures. But to be efficient, you should proceed with averages. Because if you send an email as soon as the CPU usage is up that 80%, you will receive a lot of emails... A peak can occure often.
If this solution suits your needs, I can help you by giving some leads to write the script. If you need.
Wednesday, January 30, 2013 9:23 AM -
User-2031064791 posted
yes thanks for your reply.Please send me the scripts for both senarios please
Tuesday, February 5, 2013 1:10 AM -
User-2031064791 posted
how to get cpu usage for particular service.
Tuesday, February 5, 2013 1:12 AM -
User-1499466209 posted
Please send me the scripts for both senarios pleaseHi, that's not exactly what I've suggested: I said I can help you giving you some leads. And, here you are:to get CPU usage for a particular worker process:
$pid=dir IIS:\AppPools\MyAppPool\WorkerProcesses\ | Select-Object -ExpandProperty processId $cpu=Get-WmiObject -Class Win32_PerfFormattedData_PerfProc_Process -ComputerName localhost | ? { $_.idprocess -eq $pid } | Select-Object -ExpandProperty PercentProcessorTime
But maybe you'll have to affine the first line ($pid) if you have many worker processes.
Then, my advise is to run this x times during x seconds and put these values in a array.
$array=@() $array+=$cpu
Then, you can get the average value of the array
$array | Measure-Object -average
Finally, check if your average is above or below the threshold:if (($array | Measure-Object -average) -gt $threshold) { #Send the email alert! }
By writting these lines, I've changed my mind! I will write the script... Have a look during the day at http://www.zerrouki.com, I'll post on it.Tuesday, February 5, 2013 4:29 AM -
User990644438 posted
1. go to Settings - Users
2. create a new User or modify a existing
3. configure the email of the User
4. In the User View go to Alerting Rules
5. Add Alerting Rule
6. Modify the Rule (for example where production state is prod and event class is CPU)
Hope this helps a bit,
Thanks :)
Tuesday, February 5, 2013 5:47 AM -
User-1499466209 posted
By writting these lines, I've changed my mind! I will write the script... Have a look during the day at http://www.zerrouki.com, I'll post on it.Here we are: http://www.zerrouki.com/monitorwp/Tuesday, February 5, 2013 6:38 AM