Alert Based on User Connections

  • Hi

    Has anyone ever created an alert based on connections to a database?

    For example, I want an email sent out via SQL Server when a threshold is breached in terms connections and I'd want the check to run at specific times throughout the day.

    I know I execute an sp_who to get a number of current connections to the database but I would want an alert triggering if a results returned are >= X.

    Thanks.

  • you can query sys.dm_os_performance_counters, looking at user connections and/or logins per second. Based on these values you could send an email.

    I sample these and other metrics every 15 minutes and store them for 30 days. Any alerts are usually based on seeing one of them exceeding a threshold for two consecutive samples, or exceeding an average of multiple samples, depending on what I want to look at.

    The probability of survival is inversely proportional to the angle of arrival.

  • Hey

    You're right, I eventually sussed it.

    For anyone wanting to know:

    IF (SELECT cntr_value FROM sys.dm_os_performance_counters WHERE counter_name='User Connections')>200

    EXECUTE msdb.dbo.sp_notify_operator @name=N'OperatorName',@subject=N'Subject', @body=N'Body blah blah'

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply