Este módulo de origen de datos comprueba el estado de las relaciones de servidores de conmutación por error en Windows Server 2012 que tenían habilitada la característica DHCP.
Segundos de intervalo: frecuencia (en segundos) con la que se debe comprobar el valor.
Tiempo de sincronización: tiempo de sincronización para la ejecución del módulo.
Segundos de tiempo de espera: cuánto tiempo (en segundos) se debe esperar a que el módulo finalice la ejecución.
Type | DataSourceModuleType |
Isolation | Any |
Accessibility | Public |
RunAs | Default |
OutputType | System.PropertyBagData |
ID | Module Type | TypeId | RunAs |
---|---|---|---|
Schedule | DataSource | System.SimpleScheduler | Default |
Probe | ProbeAction | Microsoft.Windows.PowerShellPropertyBagTriggerOnlyProbe | Default |
ID | ParameterType | Selector | Display Name | Description |
---|---|---|---|---|
IntervalSeconds | int | $Config/IntervalSeconds$ | Segundos de intervalo | Frecuencia (en segundos) con la que se debe muestrear el valor. |
SyncTime | string | $Config/SyncTime$ | Hora de sincronización | Tiempo de sincronización para la ejecución del módulo. |
TimeoutSeconds | int | $Config/TimeoutSeconds$ | Tiempo de espera en segundos | Tiempo de espera (en segundos) que aguarda el módulo a que finalice la ejecución. |
<DataSourceModuleType ID="Microsoft.Windows.DHCPServer.2012.FailoverServerWatcher.DS" Accessibility="Public" Batching="false">
<Configuration>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="ComputerName" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="IntervalSeconds" type="xsd:integer"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="SyncTime" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="TimeoutSeconds" type="xsd:integer"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int"/>
<OverrideableParameter ID="SyncTime" Selector="$Config/SyncTime$" ParameterType="string"/>
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<DataSource ID="Schedule" TypeID="System!System.SimpleScheduler">
<IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
<SyncTime>$Config/SyncTime$</SyncTime>
</DataSource>
<ProbeAction ID="Probe" TypeID="Windows!Microsoft.Windows.PowerShellPropertyBagTriggerOnlyProbe">
<ScriptName>GetDHCPServer2012FailoverServerWatcher.ps1</ScriptName>
<ScriptBody>
param ([String] $PrincipalName)
$SCRIPT_NAME = "DHCP2012FailoverServerWatcherProbe"
$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
Write-Host "$SCRIPT_NAME - Executing DHCP Failover 2012 Probe Powershell Script"
try
{
$DHCPFailoverWatchers = Get-DhcpServerv4Failover -ComputerName $PrincipalName
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 2012"
exit
}
else
{
if ($FailoverCount -gt 0)
{
$ErrorNumber = 0
$ErrorDesc = ""
for ($itmFO=0; $itmFO -lt $FailoverCount; $itmFO++)
{
if($FailoverCount -eq 1)
{
$FailOvObj = $DHCPFailoverWatchers
}
else
{
$FailOvObj = $DHCPFailoverWatchers.Item($itmFO)
}
switch($FailOvObj.State)
{
"CommunicationInterrupted" {$CurrState = "0"}
"PartnerDown" {$CurrState = "0"}
"Normal" {$CurrState = "1"}
}
$PerformancePropertyBag = $momAPI.CreatePropertyBag()
$PerformancePropertyBag.AddValue("Name",$FailOvObj.Name)
$PerformancePropertyBag.AddValue("LocalServer",$PrincipalName)
$PerformancePropertyBag.AddValue("PartnerServer",$FailOvObj.PartnerServer)
if ($FailOvObj.ScopeId -is [System.Array])
{
$addressList = $FailOvObj.ScopeId -join ', '
}
else
{
$addressList = $FailOvObj.ScopeId.ToString()
}
$PerformancePropertyBag.AddValue("ScopeId",$addressList)
$PerformancePropertyBag.AddValue("State",$FailOvObj.State)
$PerformancePropertyBag.AddValue("StateID",$CurrState)
$PerformancePropertyBag.AddValue("ErrorNumber", $ErrorNumber)
$PerformancePropertyBag.AddValue("ErrorDescription", $ErrorDesc)
$PerformancePropertyBag
Write-Host "$SCRIPT_NAME - DHCP IPV4 Failover State Added to Property Bag"
}
}
}
}
}
catch [System.Exception]
{
$Description = $_.ToString()
$ErrNumber = $_.Exception.ErrorCode
Write-Warning "$SCRIPT_NAME - $Description"
$State = 0
$PerformancePropertyBag = $momAPI.CreatePropertyBag()
$PerformancePropertyBag.AddValue("Name","Any")
$PerformancePropertyBag.AddValue("LocalServer",$PrincipalName)
$PerformancePropertyBag.AddValue("PartnerServer","Any")
$PerformancePropertyBag.AddValue("ScopeId","Any")
$PerformancePropertyBag.AddValue("State","Error")
$PerformancePropertyBag.AddValue("StateID",$State)
$PerformancePropertyBag.AddValue("ErrorNumber", $ErrNumber)
$PerformancePropertyBag.AddValue("ErrorDescription", $Description)
$PerformancePropertyBag
}
finally
{
Write-Host "$SCRIPT_NAME - multiple performance property bag returned"
} </ScriptBody>
<Parameters>
<Parameter>
<Name>PrincipalName</Name>
<Value>$Config/ComputerName$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
</ProbeAction>
</MemberModules>
<Composition>
<Node ID="Probe">
<Node ID="Schedule"/>
</Node>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.PropertyBagData</OutputType>
</DataSourceModuleType>