This monitor checks if database mirror is synchronized.
This monitor checks the status of the database mirroring session as reported by Microsoft® SQL Server™. This is performed by running a query against the master database of the SQL Server instance and returning the state of the database mirroring session. If you receive an alert from this monitor, an action is required in order to bring the database mirroring session back to an operational state.
Unhealthy state indicates that the SQL Server™ database mirroring session is not in operational state. The possible states are detailed below:
Mirroring Partners State | Description | MOM Health State |
IN_SYNC | This is normal operational state. Mirroring Partners are synchronized and mirroring is performing normally. | HEALTHY |
OUT_OF_SYNC | Mirroring Partners are out of sync. | CRITICAL |
To resolve the issue try the following:
Make sure mirroring configuration is complete and mirroring process is up and running.
Check physical link between Mirroring Partners.
Configure firewall rules on both Mirroring Partners according to endpoints configuration.
Name | Description | Default Value |
Alert Priority | Defines Alert Priority. | Normal |
Alert Severity | Defines Alert Severity. | Error |
Enabled | Enables or disables the workflow. | Yes |
Generates Alerts | Defines whether the workflow generates an Alert. | Yes |
Interval (seconds) | The recurring interval of time in seconds in which to run the workflow. | 900 |
Synchronization Time | The synchronization time specified by using a 24-hour format. May be omitted. |
|
Timeout (seconds) | Specifies the time the workflow is allowed to run before being closed and marked as failed. | 300 |
Target | Microsoft.SQLServer.2008.Mirroring.Witness | ||
Parent Monitor | System.Health.AvailabilityState | ||
Category | AvailabilityHealth | ||
Enabled | True | ||
Alert Generate | True | ||
Alert Severity | Error | ||
Alert Priority | Normal | ||
Alert Auto Resolve | True | ||
Monitor Type | Microsoft.SQLServer.2008.Mirroring.ScriptedTwoStateType | ||
Remotable | True | ||
Accessibility | Public | ||
Alert Message |
| ||
RunAs | Microsoft.SQLServer.SQLProbeAccount |
<UnitMonitor ID="Microsoft.SQLServer.2008.Mirroring.PartnersStateMonitor" Accessibility="Public" Enabled="true" Target="SQL2008Mirroring!Microsoft.SQLServer.2008.Mirroring.Witness" ParentMonitorID="Health!System.Health.AvailabilityState" TypeID="Microsoft.SQLServer.2008.Mirroring.ScriptedTwoStateType" Remotable="true" Priority="Normal" ConfirmDelivery="false" RunAs="SQL!Microsoft.SQLServer.SQLProbeAccount">
<Category>AvailabilityHealth</Category>
<AlertSettings AlertMessage="Microsoft.SQLServer.2008.Mirroring.PartnersStateMonitor.AlertMessage">
<AlertOnState>Error</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>Error</AlertSeverity>
<AlertParameters>
<AlertParameter1>$Target/Property[Type="SQL2008Mirroring!Microsoft.SQLServer.2008.Mirroring.Witness"]/DatabaseName$</AlertParameter1>
<AlertParameter2>$Target/Property[Type="SQL2008Mirroring!Microsoft.SQLServer.2008.Mirroring.Witness"]/Principal$</AlertParameter2>
<AlertParameter3>$Target/Property[Type="SQL2008Mirroring!Microsoft.SQLServer.2008.Mirroring.Witness"]/Mirror$</AlertParameter3>
</AlertParameters>
</AlertSettings>
<OperationalStates>
<OperationalState ID="Good" MonitorTypeStateID="Good" HealthState="Success"/>
<OperationalState ID="Bad" MonitorTypeStateID="Bad" HealthState="Error"/>
</OperationalStates>
<Configuration>
<ScriptName>GetSQL2008MirroringPartnersState.vbs</ScriptName>
<ScriptBody> '#Include File:GetSQL2008MirroringPartnersState.vbs
'Copyright (c) Microsoft Corporation. All rights reserved.
' This script takes a single parameter
' Param 0: The SQL connection string to connect to
Const SQL_MONITORING_CONNECT_FAILURE = -1
Const SQL_MONITORING_QUERY_FAILURE = -2
Const SQL_MONITORING_SUCCESS = 0
Const SCRIPT_EVENT_ID = 4001
Dim GetPartnersStatusQuery
GetPartnersStatusQuery = "SELECT " &_
" mirroring_guid, " &_
" partner_sync_state_desc " &_
" FROM sys.database_mirroring_witnesses "
Call GetPartnersStatus()
Sub GetPartnersStatus()
If WScript.Arguments.Count = 4 Then
Dim oBag
Set oBag = oAPI.CreatePropertyBag()
Dim state, serviceName
serviceName = GetSQLServiceName(WScript.Arguments(2))
state = GetServiceState(WScript.Arguments(1), serviceName)
if (state <> "Running") And (state <> "Unknown") Then
Call oAPI.Return(oBag)
WScript.Quit()
End If
Dim nResult
nResult = PartnersStatus(WScript.Arguments(0), oBag, WScript.Arguments(1), WScript.Arguments(2), WScript.Arguments(3))
On Error Resume Next
Call GlobalErrorListToEventLog()
Call oAPI.Return(oBag)
Else
On Error Resume Next
Call GlobalErrorListToEventLog()
Wscript.Quit()
End If
End Sub
Function PartnersStatus(ByVal sSQLConnectionString, ByRef oBag, ByVal sComputerName, ByVal sInstanceName, ByVal sTcpPort)
Dim e
Set e = New Error
Dim cnADOConnection
Set cnADOConnection = SmartConnectWithoutSQLADODB(sSQLConnectionString, sTcpPort, sComputerName, sInstanceName, "master")
if cnADOConnection Is Nothing Then
PartnersStatus = SQL_MONITORING_CONNECT_FAILURE
Exit Function
End If
Dim oResults
e.Clear
On Error Resume Next
Set oResults = cnADOConnection.Execute(GetPartnersStatusQuery)
e.Save
On Error Goto 0
If e.Number <> 0 Then
PartnersStatus = SQL_MONITORING_QUERY_FAILURE
ThrowScriptErrorNoAbort "Query execution failed for '" & sSQLConnectionString & "' SQL Server", e
If (oResults <> null) Then oResults.Close
cnADOConnection.Close
Exit Function
End If
Do While Not oResults.EOF
Call oBag.AddValue(oResults(0), CStr(oResults(1)))
oResults.MoveNext
Loop
cnADOConnection.Close
PartnersStatus = SQL_MONITORING_SUCCESS
End Function
</ScriptBody>
<IntervalSeconds>900</IntervalSeconds>
<SyncTime/>
<TimeoutSeconds>300</TimeoutSeconds>
<ConnectionString>$Target/Host/Host/Property[Type="SQL!Microsoft.SQLServer.DBEngine"]/ConnectionString$</ConnectionString>
<GoodExpression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Property[@Name='$Target/Property[Type="SQL2008Mirroring!Microsoft.SQLServer.2008.Mirroring.Witness"]/MirroringGUID$']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">IN_SYNC</Value>
</ValueExpression>
</SimpleExpression>
</GoodExpression>
<BadExpression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Property[@Name='$Target/Property[Type="SQL2008Mirroring!Microsoft.SQLServer.2008.Mirroring.Witness"]/MirroringGUID$']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">OUT_OF_SYNC</Value>
</ValueExpression>
</SimpleExpression>
</BadExpression>
</Configuration>
</UnitMonitor>