Tipo de monitor de firewall de Réplica

Microsoft.Windows.HyperV.ReplicaFirewallMonitorType (UnitMonitorType)

Tipo de monitor de firewall de Réplica.

Element properties:

RunAsDefault
AccessibilityPublic
Support Monitor RecalculateFalse

Member Modules:

ID Module Type TypeId RunAs 
DS DataSource Microsoft.Windows.HyperV.PowershellDataSourceType Default
CDOnCritical ConditionDetection System.ExpressionFilter Default
CDOnhealthy ConditionDetection System.ExpressionFilter Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
IntervalSecondsint$Config/IntervalSeconds$Intervalo (segundos)Intervalo (segundos)
TimeoutSecondsint$Config/TimeoutSeconds$Tiempo de espera en segundosTiempo de espera en segundos

Source Code:

<UnitMonitorType ID="Microsoft.Windows.HyperV.ReplicaFirewallMonitorType" Accessibility="Public">
<MonitorTypeStates>
<MonitorTypeState ID="HostHealthy" NoDetection="false"/>
<MonitorTypeState ID="HostCritical" NoDetection="false"/>
</MonitorTypeStates>
<Configuration>
<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="TimeoutSeconds" type="xsd:integer"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int"/>
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int"/>
</OverrideableParameters>
<MonitorImplementation>
<MemberModules>
<DataSource ID="DS" TypeID="Microsoft.Windows.HyperV.PowershellDataSourceType">
<Parameters/>
<ScriptBody><Script>

$oAPI = New-Object -comObject 'MOM.ScriptAPI'
$pBag = $oAPI.CreatePropertyBag()

$evdId = 1000
$evtSource = "Microsoft.Windows.HyperV.ReplicaFirewallMonitor";
$infoevent = 0;
$errevent = 2;


$error.Clear();

$replicaHttpRules = netsh advfirewall firewall show rule name="Hyper-V Replica HTTP Listener (TCP-In)"
$replicaHttpsRules = netsh advfirewall firewall show rule name="Hyper-V Replica HTTPS Listener (TCP-In)"
$eventMessage = $replicaHttpRules + "`n" + $replicaHttpsRules
$oAPI.LogScriptEvent($evtSource, $evdId, $infoevent, $eventMessage);
$httpRuleFound = $false
$httpsRuleFound = $false

$ruleEnabled = $false
if ($replicaHttpRules -ne $null)
{
foreach($line in $replicaHttpRules)
{
if ($line -match 'Enabled' -and $line -match 'Yes' )
{
$ruleEnabled = $true
}
if ($line -match 'Enabled' -and $line -match 'No' )
{
$ruleEnabled = $false
}

#rule must be enabled and allow traffic
if ($ruleEnabled -eq $true)
{
if ($line -match 'Action' -and $line -match 'Allow')
{
$httpRuleFound = $true
break;
}
}
}
}
$ruleEnabled = $false
if ($replicaHttpsRules -ne $null)
{
foreach($line in $replicaHttpsRules)
{
if ($line -match 'Enabled' -and $line -match 'Yes' )
{
$ruleEnabled = $true
}
if ($line -match 'Enabled' -and $line -match 'No' )
{
$ruleEnabled = $false
}

#rule must be enabled and allow traffic
if ($ruleEnabled -eq $true)
{
if ($line -match 'Action' -and $line -match 'Allow')
{
$httpsRuleFound = $true
break;
}
}
}
}

if ($httpRuleFound -eq $true -or $httpsRuleFound -eq $true)
{
$pBag.AddValue("ReplicaFirewallRules", "Present")
}
else
{
$pBag.AddValue("ReplicaFirewallRules", "Absent")
}

$pBag
</Script></ScriptBody>
<IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
</DataSource>
<ConditionDetection ID="CDOnhealthy" TypeID="System!System.ExpressionFilter">
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Property[@Name='ReplicaFirewallRules']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">Present</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</ConditionDetection>
<ConditionDetection ID="CDOnCritical" TypeID="System!System.ExpressionFilter">
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Property[@Name='ReplicaFirewallRules']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">Absent</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</ConditionDetection>
</MemberModules>
<RegularDetections>
<RegularDetection MonitorTypeStateID="HostHealthy">
<Node ID="CDOnhealthy">
<Node ID="DS"/>
</Node>
</RegularDetection>
<RegularDetection MonitorTypeStateID="HostCritical">
<Node ID="CDOnCritical">
<Node ID="DS"/>
</Node>
</RegularDetection>
</RegularDetections>
</MonitorImplementation>
</UnitMonitorType>