Tuesday, September 9, 2014

How to Setup Alerts Using Perfmon

Scenario

Say you find that the CPU utilization on your computer or server keeps spiking, but it does so at random times.  If you are looking in task manager, you might be able to identify which process is responsible for the spikes.  Now say you want to be notified when these spikes occur.  You can actually use a built in Microsoft product to send alerts and or log events like this.

Microsoft Performance Monitor.

Using Microsoft's Performance Monitor, you can select counters such as "%Processor Time" or "Handle Count" and then trigger alerts based on these counters. Microsoft has a lot of counters that you can use so that you can monitor computer or server with a high degree of granularity.  Here is an example of the Processor Object containing counters for CPU usage: http://msdn.microsoft.com/en-us/library/ms804036.aspx. You can also monitor memory, disk usage, network usage, etc.

You can set up a data collector set that will allow you to be notified, for example, when a process reaches 60% User Time.  When you do this, you will receive an alert every time this threshold is met.

Unfortunately, while you can setup these alerts to be tripped when a counter reaches a threshold, you can't set it up to alert  you when, say the %Processor reaches X amount for Y duration.


Setup Data Collector Set

1. Go to Start > Run and type perfmon
2. Under Data Collector Sets right click on User Defined and select New > Data Collector Set
3. Name your Data Collector Set and select Create Manually (Advanced) and click Next
4. Select Performance Counter Alert and click Next
5. Click Add and then select the counters you wish to use to generate the alert




6. Set the Alert when and the Limit according to your needs (what is key here is knowing how the counters you selected works, so you will need to read the counter description or look it up online)
7. Select Save and Close and click Finish
8. In the left hand pane under User Defined, select the alert you just created and then in the left hand pane right click on the alert and click Properties



9. Under the Alerts tab, change the sample rate to either 1 or 2 seconds (this is important if you are monitoring CPU activity)
10. Under the Alert Action tab check Log and entry in the application event log and select the data collector set you just created. (logs will be in the event viewer under Applications and Services Logs/Microsoft/Windows/Diagnosis-PLA/Operational



11. Start the data collector set you just created by right clicking on it and selecting Start
12. You should now see the following type of information in your event logs:


Setting up Alerts

1. Right click on one of the events and select Attach Task to this Event
2. Name the Task (and give description) and then click Next
3. Verify that this is the event you want and then click Next
4. You now have options to either Start a Program, Send an email, or Display a message.  Select the one that works best for you.

No comments:

Post a Comment