Deteção de Registo de Tarefas Pendentes da Replicação DFS

Microsoft.Windows.FileServer.DFSR.BacklogDiscovery (Discovery)

Quando ativada, esta regra deteta quantos ficheiros aguardam replicação utilizando a Replicação DFS (o registo de tarefas pendentes da replicação).

Knowledge Base article:

Resumo

Quando ativada, esta regra deteta quantos ficheiros aguardam replicação utilizando a Replicação DFS (o registo de tarefas pendentes da replicação). Esta regra de deteção preenche a vista Registo de Tarefas Pendentes da Replicação na consola Operações.

Configuração

Por predefinição, esta regra de deteção encontra-se desativada porque a contagem de registos de tarefas pendentes pode ser alterada com frequência, muitas vezes sempre que o Operations Manager executa a regra de deteção. Para monitorizar os registos de tarefas pendentes da replicação, ative esta regra de deteção e configure a frequência para o valor menos frequente que lhe fornece informações suficientemente atualizadas sobre a contagem de registos de tarefas pendentes. Para minimizar a carga do servidor e o tráfego de rede, recomendamos que defina a frequência para uma hora ou mais.

Adicional

Pode utilizar o comando Dfsrdiag backlog num servidor com a Replicação DFS ou com as ferramentas da linha de comandos instaladas para apresentar de imediato o registo de tarefas pendentes da replicação.

Element properties:

TargetMicrosoft.Windows.FileServer.DFSR.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.FileServer.DFSR.MonitoringAccount

Source Code:

<Discovery ID="Microsoft.Windows.FileServer.DFSR.BacklogDiscovery" Enabled="false" Target="Microsoft.Windows.FileServer.DFSR.Service" ConfirmDelivery="false" Remotable="true" Priority="Normal">
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="Microsoft.Windows.FileServer.DFSR.ReplicationConnection">
<Property TypeID="Microsoft.Windows.FileServer.DFSR.ReplicationConnection" PropertyID="ReplicationGroupName"/>
<Property TypeID="Microsoft.Windows.FileServer.DFSR.ReplicationConnection" PropertyID="ReplicatedFolderName"/>
<Property TypeID="Microsoft.Windows.FileServer.DFSR.ReplicationConnection" PropertyID="SendingMemberName"/>
<Property TypeID="Microsoft.Windows.FileServer.DFSR.ReplicationConnection" PropertyID="ReceivingMemberName"/>
<Property TypeID="Microsoft.Windows.FileServer.DFSR.ReplicationConnection" PropertyID="Enabled"/>
<Property TypeID="Microsoft.Windows.FileServer.DFSR.ReplicationConnection" PropertyID="BacklogCount"/>
<Property TypeID="Microsoft.Windows.FileServer.DFSR.ReplicationConnection" PropertyID="ReplicationGroupGUID"/>
<Property TypeID="Microsoft.Windows.FileServer.DFSR.ReplicationConnection" PropertyID="ReplicatedFolderGUID"/>
<Property TypeID="Microsoft.Windows.FileServer.DFSR.ReplicationConnection" PropertyID="ConnectionGUID"/>
<Property TypeID="Microsoft.Windows.FileServer.DFSR.ReplicationConnection" PropertyID="SendingMemberGUID"/>
<Property TypeID="Microsoft.Windows.FileServer.DFSR.ReplicationConnection" PropertyID="ReceivingMemberGUID"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
</DiscoveryTypes>
<DataSource ID="DS" RunAs="Microsoft.Windows.FileServer.DFSR.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, MemberInfoList, MemberInformation, MemberInfo

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 MemberInfoList = objWMIService.ExecQuery("select MemberGuid from DfsrLocalMemberConfig where MemberName='" &amp; Left(sDfsrServerName, InStr(sDfsrServerName, ".")-1) &amp; "'")
If Err.Number &lt;&gt; 0 then
strErr = "Unable to query DfsrLocalMemberConfig from local WMI provider. Error: 0x" &amp; Hex(Err.Number) &amp; " " &amp; Err.Description
WScript.Echo strErr
Wscript.Quit -1
End If

For Each MemberInfo in MemberInfoList
Set ListOfConnections = objWMIService.ExecQuery("Select PartnerDns, PartnerGuid, PartnerName, ConnectionGuid, MemberGuid, ReplicationGroupGuid, Enabled from DfsrConnectionConfig Where Inbound = false and MemberGuid='" &amp; MemberInfo.MemberGuid &amp; "'")
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
oDiscData.IsSnapshot = false
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
oDiscData.IsSnapshot = false
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
oDiscData.IsSnapshot = false
Else
set oReplicationConnections = oDiscData.CreateClassInstance("$MPElement[Name='Microsoft.Windows.FileServer.DFSR.ReplicationConnection']$")

call oReplicationConnections.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", sDfsrServerName)
call oReplicationConnections.AddProperty("$MPElement[Name='Microsoft.Windows.FileServer.DFSR.ReplicationConnection']/ConnectionGUID$", Connection.ConnectionGuid)
call oReplicationConnections.AddProperty("$MPElement[Name='Microsoft.Windows.FileServer.DFSR.ReplicationConnection']/SendingMemberGUID$", Connection.MemberGuid)
call oReplicationConnections.AddProperty("$MPElement[Name='Microsoft.Windows.FileServer.DFSR.ReplicationConnection']/SendingMemberName$", Left(sDfsrServerName, InStr(sDfsrServerName, ".")-1))
call oReplicationConnections.AddProperty("$MPElement[Name='Microsoft.Windows.FileServer.DFSR.ReplicationConnection']/ReceivingMemberGUID$", Connection.PartnerGuid)
call oReplicationConnections.AddProperty("$MPElement[Name='Microsoft.Windows.FileServer.DFSR.ReplicationConnection']/ReceivingMemberName$", Connection.PartnerName)
call oReplicationConnections.AddProperty("$MPElement[Name='Microsoft.Windows.FileServer.DFSR.ReplicationConnection']/ReplicationGroupGUID$", Connection.ReplicationGroupGuid)
call oReplicationConnections.AddProperty("$MPElement[Name='Microsoft.Windows.FileServer.DFSR.ReplicationConnection']/ReplicationGroupName$", objDfsrRfInfo.ReplicationGroupName)
call oReplicationConnections.AddProperty("$MPElement[Name='Microsoft.Windows.FileServer.DFSR.ReplicationConnection']/ReplicatedFolderGUID$", objDfsrRfInfo.ReplicatedFolderGuid)
call oReplicationConnections.AddProperty("$MPElement[Name='Microsoft.Windows.FileServer.DFSR.ReplicationConnection']/ReplicatedFolderName$", objDfsrRfInfo.ReplicatedFolderName)
call oReplicationConnections.AddProperty("$MPElement[Name='Microsoft.Windows.FileServer.DFSR.ReplicationConnection']/Enabled$", Connection.Enabled)
call oReplicationConnections.AddProperty("$MPElement[Name='Microsoft.Windows.FileServer.DFSR.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
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>