Replica states


Job details

Name: Replica states
Platform: Sqlserver
Category: Cluster and Replication
Description: Checks role state for all alwayson groups.
Long description:
Version: 1.3
Default schedule: 1,6,11,16,21,26,31,36,41,46,51,56 * * *
Requires engine install: Yes
Compatibility tag: .[type=‘instance’ & databasetype=‘sqlserver’]/instance[ maj_version > ‘2005′ & hasengine=‘YES’ & alwayson_active=‘YES’ & engine_edition = ‘Microsoft SQL Server’ & eng_inst_priv = 0]

Parameters

Name Default value Description
ignore groups model List of alwayson groups (separated by comma) which will be ignored. You can use % (percent sign) to represent wild card characters.
status SECONDARY -> PRIMARY 0 Return status value (ALARM – 2, WARNING – 1, or OK – 0) when group status change from SECONDARY to PRIMARY.
status PRIMARY -> SECONDARY 1 Return status value (ALARM – 2, WARNING – 1, or OK – 0) when group status change from PRIMARY to SECONDARY
primary host for all groups If set to “YES“ then the current host machine is preferred primary node for all groups.
status when not preferred primary in use 1 Return status value (ALARM – 2, WARNING – 1, or OK – 0) when preferred primary node (controlled by the “primary host” parameter) is not in use.

dbWatch Control Center Monitoring Job Summary

The monitoring job outlined in the XML data you provided is designed for dbWatch Control Center, focusing on managing and monitoring Microsoft SQL Server instances that employ AlwaysOn availability groups.

Purpose

Why

Manual checking
In order to manually check AlwaysOn states, the following SQL commands can be used:

SELECT ag.name AS AG_Name, replica_server_name, ars.role_desc
   FROM sys.availability_groups AS ag
   JOIN sys.dm_hadr_availability_replica_states AS ars
   ON ag.group_id = ars.group_id
   WHERE ag.name <> 'model' --excluding model database or modify as required

Automated Monitoring

Dependencies and Data Management
The job has self-dependencies on tables and procedures created for monitoring the AlwaysOn states, which includes automated cleanup in case of failures to keep the environment clean:

Output
The SQL job returns monitoring results in a structured format, which can be utilized for alert management systems or included in dashboards for a comprehensive view:

Tables and Presentations

Presentation of results in dbWatch Report:

Replica Server Name _. Group Name _. State _. Date _. Type
--- --- --- --- ---
Server A AG1 PRIMARY 2023-10-01 12:00 current state
Server B AG1 SECONDARY 2023-10-01 12:05 history state

The job setup and details provided denote a comprehensive approach to monitoring the key aspects of SQL Server AlwaysOn availability groups, helping database administrators ensure system reliability and data availability.