Current role of a database

This metric allows you to keep track of the role of a given database within your mirroring set up. The single value returned tells you whether the database is the principal or the mirror.

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 is described in Grant Fritchey’s Custom Metrics for monitoring mirroring article on Simple Talk.

The metric returns the current role of a given database within your mirroring set up. The single value returned tells you whether the database is the principal or the mirror, which is important information if you always want one server to act as the principal.

Important setup information

Before you can start using this metric, you need to:

  1. Run the following Microsoft procedure on the msdb database you’ll use in the custom metric:
    [sql]USE msdb;
    GO
    EXEC sp_dbmmonitoraddmonitoring;
    GO
    [/sql]

    This sets up a SQL Agent job that periodically updates information about the mirrored databases on your server. For more information, see http://msdn.microsoft.com/en-us/library/ms403582.aspx.

  2. Make sure the SQL Agent is configured and running on the server. Then you can retrieve information using the sp_dbmmonitorresults procedure.

Metric definition

Name

Current role of database 'InsertDatabaseNameHere'

Description

This metric returns the current role of this database within your mirroring set up. Roles are represented by the following values:

  • 1 = Principal
  • 2 = Mirror

The T-SQL query that will collect data

Instances to collect from

Select all

Databases to collect from

msdb

Collection frequency

60

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

Database 'InsertDatabaseNameHere' role changed

Description

This alert is raised when the role of the database changes from principal to mirror. The value returned by the metric on which this alert is based is either:
  • 1 = Principal
  • 2 = Mirror

Raise an alert when the metric value goes

Above the defined threshholds

Default threshold values

High:1
Medium:Leave unchecked
Low:Leave unchecked

Raise an alert when the threshold is passed for

1 collection

Alert is

Enabled