I recently started poking around, trying to figure out how to get emailed whenever the average CPU usage on one of our servers exceeded a certain threshold. I’ve used the Performance Counters in Windows for a variety of things in the past, such as logging historical performance data and sending email alerts for free drive space, so this was the first place I looked.
The only real issue I ran into was just a perceived one. I assumed that, like the value shown in the System Monitor pane, the value measured by the alert would be the current CPU usage, polled at the sample interval. However, after reading a bit more and doing some testing myself, I came to the conclusion that the value reported in the alert is the average over the sample interval. So, if you set the sample interval to one minute (instead of the default five seconds), the alert will be on the average CPU usage over one minute.
For emailing, I use an application called bmail. It’s a free command line SMTP mailer that works great in my experience. I created a batch file that takes a single parameter and calls bmail.exe. In the settings for the alert, I set it to run my batch file, and customize the parameters to send in the measured value.
After setting all that up we’re ready to go. I’ll now be emailed any time the average CPU usage, over an interval, exceeds a value of my choosing.