Discover replication backlogs on monitored computer.

Microsoft.Windows.DfsReplication.DFSRBacklogDiscovery (Discovery)

This rule discovers DFS Replication backlogs on a monitored computer.

Knowledge Base article:

Summary

Replication backlogs show how many files still need to replicate before two replication group members are in sync. The backlog count is the number of updates that a replication group member has not processed.

This discovery rule queries the DFS Replication service on a monitored computer and determines the number of replication backlogs on that computer. Monitoring the replication backlog count helps administrators figure out whether the data on members of a replication group is in sync. This discovery rule populates the ‘Backlog Monitoring’ view in the Operations Manager dashboard.

NOTE: This discovery rule is ‘Disabled’ by default. This is because the backlog count is a frequently changing number and will hence generate a lot of churn for discovered objects. In order to monitor replication backlogs, please enable this discovery rule and configure the frequency with which it is executed to a convenient value.

Additional

The “DfsrDiag.exe backlog” command line tool can be used to display the backlog of replication data to send from one replication group member to another replication group member.

Element properties:

TargetMicrosoft.Windows.DfsReplication.Service
EnabledFalse
Frequency14400
RemotableFalse

Object Discovery Details:

Discovered Classes and their attribuets:

Member Modules:

ID Module Type TypeId RunAs 
DS DataSource Microsoft.Windows.TimedScript.DiscoveryProvider Microsoft.Windows.DfsReplication.MonitoringAccount

Source Code:

<Discovery ID="Microsoft.Windows.DfsReplication.DFSRBacklogDiscovery" Enabled="false" Target="Microsoft.Windows.DfsReplication.Service" ConfirmDelivery="false" Remotable="true" Priority="Normal">
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="Microsoft.Windows.DfsReplication.ReplicationConnection">
<Property TypeID="Microsoft.Windows.DfsReplication.ReplicationConnection" PropertyID="ReplicationGroupName"/>
<Property TypeID="Microsoft.Windows.DfsReplication.ReplicationConnection" PropertyID="ReplicatedFolderName"/>
<Property TypeID="Microsoft.Windows.DfsReplication.ReplicationConnection" PropertyID="SendingMemberName"/>
<Property TypeID="Microsoft.Windows.DfsReplication.ReplicationConnection" PropertyID="ReceivingMemberName"/>
<Property TypeID="Microsoft.Windows.DfsReplication.ReplicationConnection" PropertyID="Enabled"/>
<Property TypeID="Microsoft.Windows.DfsReplication.ReplicationConnection" PropertyID="BacklogCount"/>
<Property TypeID="Microsoft.Windows.DfsReplication.ReplicationConnection" PropertyID="ReplicationGroupGUID"/>
<Property TypeID="Microsoft.Windows.DfsReplication.ReplicationConnection" PropertyID="ReplicatedFolderGUID"/>
<Property TypeID="Microsoft.Windows.DfsReplication.ReplicationConnection" PropertyID="ConnectionGUID"/>
<Property TypeID="Microsoft.Windows.DfsReplication.ReplicationConnection" PropertyID="SendingMemberGUID"/>
<Property TypeID="Microsoft.Windows.DfsReplication.ReplicationConnection" PropertyID="ReceivingMemberGUID"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
</DiscoveryTypes>
<DataSource ID="DS" RunAs="Microsoft.Windows.DfsReplication.MonitoringAccount" TypeID="Windows!Microsoft.Windows.TimedScript.DiscoveryProvider">
<IntervalSeconds>14400</IntervalSeconds>
<SyncTime/>
<ScriptName>BacklogDiscovery.vbs</ScriptName>
<Arguments>0 $MPElement$ $Target/Id$ $Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$</Arguments>
<ScriptBody><Script>Option Explicit

On Error Resume Next

Dim SourceType, SourceID, ManagedEntityId, oArgs, oAPI, sDfsrServerName, oReplicationConnections, oDiscData

SetLocale("en-us")

Set oAPI = CreateObject("MOM.ScriptAPI")
Set oArgs = WScript.Arguments

If oArgs.Count &lt; 4 Then
call oAPI.LogScriptEvent("BacklogDiscovery.vbs", 100, 1, "Expected 4 arguments. There were only " &amp; oArgs.Count &amp; " arguments. Exiting script.")
Wscript.Quit -1
End If

SourceType = oArgs(0)
SourceId = oArgs(1)
ManagedEntityId = oArgs(2)
sDfsrServerName = oArgs(3)

set oDiscData = oAPI.CreateDiscoveryData(SourceType, SourceId, ManagedEntityId)

Dim objWMIService, ListOfConnections, objDfsrRfInfo, Connection, objReceivingWmiService, BacklogCount, ListOfReplicatedFolders

Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &amp; sDfsrServerName &amp; "\root\microsoftdfs")
If Err.Number &lt;&gt; 0 then
strErr = "Unable to connect to local WMI provider. Error: 0x" &amp; Hex(Err.Number) &amp; " " &amp; Err.Description
WScript.Echo strErr
Wscript.Quit -1
End If

Set ListOfConnections = objWMIService.ExecQuery("Select PartnerDns, PartnerGuid, PartnerName, ConnectionGuid, MemberGuid, ReplicationGroupGuid, Enabled from DfsrConnectionConfig Where Inbound = false")
If Err.Number &lt;&gt; 0 then
strErr = "Unable to query DfsrConnectionConfig from local WMI provider. Error: 0x" &amp; Hex(Err.Number) &amp; " " &amp; Err.Description
WScript.Echo strErr
Wscript.Quit -1
End If

For Each Connection in ListOfConnections

Set objReceivingWmiService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &amp; Connection.PartnerDns &amp; "\root\microsoftdfs")
If Err.Number &lt;&gt; 0 then
strErr = "Unable to connect to remote WMI provider. Server: " &amp; Connection.PartnerDns &amp; ". Error: 0x" &amp; Hex(Err.Number) &amp; " " &amp; Err.Description
WScript.Echo strErr
Err.Clear
Else
Set ListOfReplicatedFolders = objReceivingWmiService.ExecQuery ("Select ReplicationGroupName, ReplicatedFolderGuid, ReplicatedFolderName from DfsrReplicatedFolderInfo Where MemberGuid ='" &amp; Connection.PartnerGuid &amp; "'")
If Err.Number &lt;&gt; 0 then
strErr = "Unable to query DfsrReplicatedFolderInfo from remote WMI provider. Server: " &amp; Connection.PartnerDns &amp; ". Error: 0x" &amp; Hex(Err.Number) &amp; " " &amp; Err.Description
WScript.Echo strErr
Err.Clear
Else
For Each objDfsrRfInfo In ListOfReplicatedFolders
BacklogCount = 0

BacklogCount = Backlog(objReceivingWmiService, objWMIService, objDfsrRfInfo)

If Err.Number &lt;&gt; 0 then
strErr = "Unable to get backlog information. ReplicatedFolderGuid: "&amp; objDfsrRfInfo.ReplicatedFolderGuid &amp; " Error: 0x" &amp; Hex(Err.Number) &amp; " " &amp; Err.Description
WScript.Echo strErr
Err.Clear
Else
set oReplicationConnections = oDiscData.CreateClassInstance("$MPElement[Name='Microsoft.Windows.DfsReplication.ReplicationConnection']$")

call oReplicationConnections.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", sDfsrServerName)
call oReplicationConnections.AddProperty("$MPElement[Name='Microsoft.Windows.DfsReplication.ReplicationConnection']/ConnectionGUID$", Connection.ConnectionGuid)
call oReplicationConnections.AddProperty("$MPElement[Name='Microsoft.Windows.DfsReplication.ReplicationConnection']/SendingMemberGUID$", Connection.MemberGuid)
call oReplicationConnections.AddProperty("$MPElement[Name='Microsoft.Windows.DfsReplication.ReplicationConnection']/SendingMemberName$", Left(sDfsrServerName, InStr(sDfsrServerName, ".")-1))
call oReplicationConnections.AddProperty("$MPElement[Name='Microsoft.Windows.DfsReplication.ReplicationConnection']/ReceivingMemberGUID$", Connection.PartnerGuid)
call oReplicationConnections.AddProperty("$MPElement[Name='Microsoft.Windows.DfsReplication.ReplicationConnection']/ReceivingMemberName$", Connection.PartnerName)
call oReplicationConnections.AddProperty("$MPElement[Name='Microsoft.Windows.DfsReplication.ReplicationConnection']/ReplicationGroupGUID$", Connection.ReplicationGroupGuid)
call oReplicationConnections.AddProperty("$MPElement[Name='Microsoft.Windows.DfsReplication.ReplicationConnection']/ReplicationGroupName$", objDfsrRfInfo.ReplicationGroupName)
call oReplicationConnections.AddProperty("$MPElement[Name='Microsoft.Windows.DfsReplication.ReplicationConnection']/ReplicatedFolderGUID$", objDfsrRfInfo.ReplicatedFolderGuid)
call oReplicationConnections.AddProperty("$MPElement[Name='Microsoft.Windows.DfsReplication.ReplicationConnection']/ReplicatedFolderName$", objDfsrRfInfo.ReplicatedFolderName)
call oReplicationConnections.AddProperty("$MPElement[Name='Microsoft.Windows.DfsReplication.ReplicationConnection']/Enabled$", Connection.Enabled)
call oReplicationConnections.AddProperty("$MPElement[Name='Microsoft.Windows.DfsReplication.ReplicationConnection']/BacklogCount$", BacklogCount)
call oReplicationConnections.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "'" &amp; Left(sDfsrServerName, InStr(sDfsrServerName, ".")-1) &amp; " -&gt; " &amp; Connection.PartnerName &amp; "'")

call oDiscData.AddInstance(oReplicationConnections)
End If
Next
End If
End If
Next

Call oAPI.Return(oDiscData)

Function Backlog(objReceivingWmiConn, objSendingWmiConn, objReceivingDfsrRfInfo)

Backlog = 0

Dim strVv, strError
Dim strObjPath
Dim objSendingDfsrRfInfo
Dim uintBacklogCount
Dim uintRecordIdx
Dim uintErr


uintErr = objReceivingDfsrRfInfo.GetVersionVector(strVv)

If uintErr &lt;&gt; 0 Then
Backlog = 0
Exit Function
End If

strObjPath = objReceivingDfsrRfInfo.Path_.RelPath

On Error Resume Next
Set objSendingDfsrRfInfo = objSendingWmiConn.Get(strObjPath)

If ( Err &lt;&gt; 0 ) Then
Backlog = 0
Exit Function
End If

uintErr = objSendingDfsrRfInfo.GetOutboundBacklogFileCount(strVv, uintBacklogCount, uintRecordIdx)

If uintErr &lt;&gt; 0 Then
backlog = 0
Exit Function
End If

Backlog = uintBacklogCount

End Function</Script></ScriptBody>
<TimeoutSeconds>300</TimeoutSeconds>
</DataSource>
</Discovery>