Server principals with default database offline

This metric monitors whether a server principal's default database is offline. When you create a SQL Server server principal (formerly referred to as a server login) it has a default database setting that is used to assist in a connection request when no database is specified.

Install metric...

Metrics install automatically if you have Redgate Monitor installed.

If you are using Redgate’s SQL Server monitoring tool, Redgate Monitor, you can instantly install and run this metric on your servers.

This metric monitors whether a server principal’s default database is offline. When you create a SQL Server server principal (formerly referred to as a server login) it has a default database setting that is used to assist in a connection request when no database is specified. For example, this means that the Accounts users can connect to the Accounts database by default. However, if that database goes offline and a connection is attempted, an error is presented to the user. Some users can cope with this, but others such as an unattended service account may have trouble.

Metric definition

Name

Server principals with default database offline

Description

The metric cross-checks sys.server_principals with the sys.databases and returns a count of the server principals that have their default database offline. Check the results of this and resolve the issues: SELECT [sp].[name] AS [server principle] , [sp].[default_database_name] , [sp].[principal_id] , [sp].[sid] , [sp].[type] , [sp].[type_desc] , [sp].[is_disabled] FROM [sys].[server_principals] AS sp INNER JOIN sys.databases AS d ON [sp].[default_database_name] = d.[name] WHERE [d].[state_desc] <> 'online' ORDER BY [sp].[default_database_name] , [sp].[name];

The T-SQL query that will collect data

Instances to collect from

all of the instances that you want to monitor for this condition

Databases to collect from

master

Collection frequency

1800

Use collected or calculated values

Leave the Use a calculated rate of change between collections check box unchecked

Metric collection

Enabled

Alert definition

Alert name

Server principals with default database offline

Description

There are server principals that will get a connection error when not specifying a database in a connection string. Set the default database to a database that is online.

Raise an alert when the metric value goes

Above the defined threshholds

Default threshold values

High:Turn off check box
Medium:1
Low:Turn off check box

Note: These thresholds are intended as guideline values. If they seem too high or too low for your environment, replace them with values more suited to your server performance.

Raise an alert when the threshold is passed for

1 collection

Alert is

Enabled