Performance Alerts

Today, I am going to talk about setting up performance alerts so that you can notified when a server has issues. Basically, there are two types of performance alerts, SQL Server and WMI.

I am going to use the sp_add_category system procedure to define a peformance category.

The sp_add_alert stored procedure is used to create the alert and the sp_add_notification stored procedure is used to associate the alert with an operator. This process is used below to show examples of both SQL and WMI performance alerts.

The first type of performance alert is based upon SQL Server objects and counters that the database tracks. To set up the alert, you need to specify the object, counter, database instance, and condition to be meet for the alert to be triggered. The alert below notifies the operator when the log file on the adventure works database exceeds 50%. It will send out a email with a description of the event to the operator.

The second type of performance alert is based upon WMI queries which came out with windows scripting in the year 2000. The example below looks for overall CPU usage every 60 seconds and triggers the alert if it is greater than 75%.

To remove the previous alert, calls to the sp_delete_notification and sp_delete_alert procedures need to be executed. The operator to alert mapping is stored in the msdb.dbo.sysnotifications table.

Something I forgot last time to mentions is that standard error messages can be retrieved from the msdb.sys.messages view. These messages can be added to by the end user using the standard sp_addmessage and sp_drop_message system procedures. The sp_altermessage procedure actual logs the message as if it was raised by code. The code snipet below demonstrates these techniques.

In conclusion, SQL Server out of the box gives you the tools to create alerts for both standard errors and performance issues. It is up to you to use these tools to build your own custom performance monitoring strategy. Next time, I will introduce two test scripts that can be used to test two alerts we previously defined.

Related posts

2 Thoughts to “Performance Alerts”

  1. Really like the modern look. I loved the information. Thank you for a quality article.

  2. But wanna comment on few general things, The website design is perfect, the articles is real good : D.

Leave a Comment