DHCP 2012 R2 장애 조치 서버 관계 검색 데이터 원본
Microsoft.Windows.DHCPServer.2012.R2.FailoverServerWatcher.Discovery (Discovery)
이 검색 규칙은 DHCP 2012 R2 장애 조치 서버 관계 인스턴스를 채웁니다.
Knowledge Base article:
Element properties:
Object Discovery Details:
Member Modules:
Source Code:
<Discovery ID="Microsoft.Windows.DHCPServer.2012.R2.FailoverServerWatcher.Discovery" Enabled="true" Target="Microsoft.Windows.DHCPServer.2012.R2.Server" ConfirmDelivery="true" Remotable="true" Priority="Normal">
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="Microsoft.Windows.DHCPServer.2012.R2.FailoverServerWatcher">
<Property TypeID="DHCP2012!Microsoft.Windows.DHCPServer.2012.FailoverServerWatcher" PropertyID="Name"/>
<Property TypeID="DHCP2012!Microsoft.Windows.DHCPServer.2012.FailoverServerWatcher" PropertyID="LocalServer"/>
<Property TypeID="DHCP2012!Microsoft.Windows.DHCPServer.2012.FailoverServerWatcher" PropertyID="PartnerServer"/>
<Property TypeID="DHCP2012!Microsoft.Windows.DHCPServer.2012.FailoverServerWatcher" PropertyID="ScopeId"/>
<Property TypeID="DHCP2012!Microsoft.Windows.DHCPServer.2012.FailoverServerWatcher" PropertyID="Mode"/>
<Property TypeID="DHCP2012!Microsoft.Windows.DHCPServer.2012.FailoverServerWatcher" PropertyID="LoadBalancePercent"/>
<Property TypeID="DHCP2012!Microsoft.Windows.DHCPServer.2012.FailoverServerWatcher" PropertyID="ServerRole"/>
<Property TypeID="DHCP2012!Microsoft.Windows.DHCPServer.2012.FailoverServerWatcher" PropertyID="ReservePercent"/>
<Property TypeID="DHCP2012!Microsoft.Windows.DHCPServer.2012.FailoverServerWatcher" PropertyID="MaxClientLeadTime"/>
<Property TypeID="DHCP2012!Microsoft.Windows.DHCPServer.2012.FailoverServerWatcher" PropertyID="StateSwitchInterval"/>
<Property TypeID="DHCP2012!Microsoft.Windows.DHCPServer.2012.FailoverServerWatcher" PropertyID="AutoStateTransition"/>
<Property TypeID="DHCP2012!Microsoft.Windows.DHCPServer.2012.FailoverServerWatcher" PropertyID="EnableAuth"/>
<Property TypeID="DHCP2012!Microsoft.Windows.DHCPServer.2012.FailoverServerWatcher" PropertyID="OSCurrentVersion"/>
</DiscoveryClass>
<DiscoveryRelationship TypeID="DHCP2012!Microsoft.Windows.DHCPServer.2012.References.FailoverServerWatcher"/>
</DiscoveryTypes>
<DataSource ID="DS4" RunAs="System!System.PrivilegedMonitoringAccount" TypeID="Windows!Microsoft.Windows.TimedPowerShell.DiscoveryProvider">
<IntervalSeconds>86400</IntervalSeconds>
<SyncTime/>
<ScriptName>DiscoverDHCPFailoverServerWatcher2012</ScriptName>
<ScriptBody><Script>
param ([String] $ElementID, [String] $TargetID, [String] $PrincipalName)
$SCRIPT_NAME = "DiscoverDHCPFailoverServerWatcher2012R2"
$ErrorActionPreference = "Stop"
# Event type constants
$EVENT_TYPE_LOG = 0
$EVENT_TYPE_ERROR = 1
$EVENT_TYPE_WARNING = 2
$EVENT_TYPE_INFORMATION = 4
# Typed property bag constants
$PROPERTY_TYPE_ALERT = 0
$PROPERTY_TYPE_EVENT = 1
$PROPERTY_TYPE_PERFORMANCE = 2
$PROPERTY_TYPE_STATE = 3
# State type constants
$STATE_SUCCESS = "Success"
$STATE_WARNING = "Warning"
$STATE_ERROR = "Error"
$momAPI = new-object -comObject MOM.ScriptAPI
$TargetOSVersion = "6.3"
$ComputerName = "$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$"
$SourceServerClass = "$MPElement[Name='Microsoft.Windows.DHCPServer.2012.R2.FailoverServerWatcher']$"
$TargetServerClass = "$MPElement[Name='Microsoft.Windows.DHCPServer.2012.R2.Server']$"
$RelationshipClass = "$MPElement[Name='DHCP2012!Microsoft.Windows.DHCPServer.2012.References.FailoverServerWatcher']$"
$Name = "$MPElement[Name='DHCP2012!Microsoft.Windows.DHCPServer.2012.FailoverServerWatcher']/Name$"
$DisplayName = "$MPElement[Name='System!System.Entity']/DisplayName$"
$LocalServer = "$MPElement[Name='DHCP2012!Microsoft.Windows.DHCPServer.2012.FailoverServerWatcher']/LocalServer$"
$PartnerServer = "$MPElement[Name='DHCP2012!Microsoft.Windows.DHCPServer.2012.FailoverServerWatcher']/PartnerServer$"
$ScopeId = "$MPElement[Name='DHCP2012!Microsoft.Windows.DHCPServer.2012.FailoverServerWatcher']/ScopeId$"
$Mode = "$MPElement[Name='DHCP2012!Microsoft.Windows.DHCPServer.2012.FailoverServerWatcher']/Mode$"
$LoadBalancePercent = "$MPElement[Name='DHCP2012!Microsoft.Windows.DHCPServer.2012.FailoverServerWatcher']/LoadBalancePercent$"
$ServerRole = "$MPElement[Name='DHCP2012!Microsoft.Windows.DHCPServer.2012.FailoverServerWatcher']/ServerRole$"
$ReservePercent = "$MPElement[Name='DHCP2012!Microsoft.Windows.DHCPServer.2012.FailoverServerWatcher']/ReservePercent$"
$MaxClientLeadTime = "$MPElement[Name='DHCP2012!Microsoft.Windows.DHCPServer.2012.FailoverServerWatcher']/MaxClientLeadTime$"
$StateSwitchInterval = "$MPElement[Name='DHCP2012!Microsoft.Windows.DHCPServer.2012.FailoverServerWatcher']/StateSwitchInterval$"
$AutoStateTransition = "$MPElement[Name='DHCP2012!Microsoft.Windows.DHCPServer.2012.FailoverServerWatcher']/AutoStateTransition$"
$EnableAuth = "$MPElement[Name='DHCP2012!Microsoft.Windows.DHCPServer.2012.FailoverServerWatcher']/EnableAuth$"
$OSCurrentVersion = "$MPElement[Name='DHCP2012!Microsoft.Windows.DHCPServer.2012.FailoverServerWatcher']/OSCurrentVersion$"
$ComputerKey = "$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$"
$ComputerName = "$MPElement[Name='DHCP!Microsoft.Windows.DHCPServer.Library.Server']/Name$"
Write-Host "$SCRIPT_NAME - Executing DHCP Failover Server Watcher Discovery Powershell Script"
$discoveryData = $momAPI.CreateDiscoveryData(0, $ElementID, $TargetID)
$CurrOS = Get-WmiObject -Namespace "root\cimv2" -Query "select Version from Win32_OperatingSystem"
$OSVer = $CurrOS.Version
$CurrVer = $OSVer.Split(".")
$OS = $CurrVer.Item(0) + "." + $CurrVer.Item(1)
if ($OS -ne $TargetOSVersion)
{
Write-Host "$SCRIPT_NAME - No Target Operating System"
$discoveryData
exit
}
else
{
Write-Host "$SCRIPT_NAME - Target Server"
$DHCPFailoverWatchers = Get-DhcpServerv4Failover -ComputerName $PrincipalName
$DHCPFailoverWatcher = $null
$ObjDHCPFailoverWatcher = $null
$FailoverWatcherRelationship = $null
$TargetServer = $null
if ($DHCPFailoverWatchers -ne $null)
{
if($DHCPFailoverWatchers.Count -eq $null)
{
$FailoverCount = 1
}
else
{
$FailoverCount = $DHCPFailoverWatchers.Count
}
if ($FailoverCount -eq 0)
{
Write-Host "$SCRIPT_NAME - No DHCP Failover configured in this DHCP Server"
$discoveryData
exit
}
else
{
if ($FailoverCount -gt 0)
{
for ($itmFO=0; $itmFO -lt $FailoverCount; $itmFO++)
{
if($FailoverCount -eq 1)
{
$FailOvObj = $DHCPFailoverWatchers
}
else
{
$FailOvObj = $DHCPFailoverWatchers.Item($itmFO)
}
$ObjDHCPFailoverWatcher = $discoveryData.CreateClassInstance($SourceServerClass)
$ObjDHCPFailoverWatcher.AddProperty($Name, $FailOvObj.Name)
$ObjDHCPFailoverWatcher.AddProperty($DisplayName, $FailOvObj.Name)
$ObjDHCPFailoverWatcher.AddProperty($LocalServer, $PrincipalName)
$ObjDHCPFailoverWatcher.AddProperty($PartnerServer, $FailOvObj.PartnerServer)
$ObjDHCPFailoverWatcher.AddProperty($Mode, $FailOvObj.Mode)
$ObjDHCPFailoverWatcher.AddProperty($LoadBalancePercent, $FailOvObj.LoadBalancePercent)
$ObjDHCPFailoverWatcher.AddProperty($ServerRole, $FailOvObj.ServerRole)
$ObjDHCPFailoverWatcher.AddProperty($ReservePercent, $FailOvObj.ReservePercent)
$ObjDHCPFailoverWatcher.AddProperty($MaxClientLeadTime, $FailOvObj.MaxClientLeadTime.ToString())
if($FailOvObj.StateSwitchInterval -eq $null)
{
$StateSI = ""
}
else
{
$StateSI = $FailOvObj.StateSwitchInterval.ToString()
}
$ObjDHCPFailoverWatcher.AddProperty($StateSwitchInterval, $StateSI)
if ($FailOvObj.ScopeId -is [System.Array])
{
$addressList = $FailOvObj.ScopeId -join ', '
}
else
{
$addressList = $FailOvObj.ScopeId.ToString()
}
$ObjDHCPFailoverWatcher.AddProperty($ScopeId, $addressList)
$ObjDHCPFailoverWatcher.AddProperty($AutoStateTransition, $FailOvObj.AutoStateTransition)
$ObjDHCPFailoverWatcher.AddProperty($EnableAuth, $FailOvObj.EnableAuth)
$ObjDHCPFailoverWatcher.AddProperty($OSCurrentVersion, $OSVer)
$discoveryData.AddInstance($ObjDHCPFailoverWatcher)
$TargetServer = $discoveryData.CreateClassInstance($TargetServerClass)
$TargetServer.AddProperty($ComputerKey, $FailOvObj.PartnerServer)
$TargetServer.AddProperty($ComputerName, $FailOvObj.PartnerServer)
$FailoverWatcherRelationship = $discoveryData.CreateRelationshipInstance($RelationshipClass)
$FailoverWatcherRelationship.Source = $ObjDHCPFailoverWatcher
$FailoverWatcherRelationship.Target = $TargetServer
$discoveryData.AddInstance($FailoverWatcherRelationship)
Write-Host "$SCRIPT_NAME - DHCP IPV4 Failover Watcher Added to Discovery data"
}
}
}
}
$discoveryData
Write-Host "$SCRIPT_NAME - Discovery data returned"
}</Script></ScriptBody>
<Parameters>
<Parameter>
<Name>ElementID</Name>
<Value>$MPElement$</Value>
</Parameter>
<Parameter>
<Name>TargetID</Name>
<Value>$Target/Id$</Value>
</Parameter>
<Parameter>
<Name>PrincipalName</Name>
<Value>$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>300</TimeoutSeconds>
</DataSource>
</Discovery>