Get an Email Alert on Average CPU Usage

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.

WindowClipping (75)

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.

WindowClipping (74)

WindowClipping (76)

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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s