Microsoft.SystemCenter.VirtualMachineManager.PRO.VMPressure (UnitMonitorType)

Element properties:

RunAsDefault
AccessibilityInternal
Support Monitor RecalculateFalse

Member Modules:

ID Module Type TypeId RunAs 
DS DataSource Microsoft.SystemCenter.VirtualMachineManager.PRO.TimedPowerShell.PerformanceProvider Default
CD1 ConditionDetection System.Performance.ConsecutiveSamplesCondition Default
CD2 ConditionDetection System.Performance.ConsecutiveSamplesCondition Default
CDInSufficientSamples ConditionDetection System.ExpressionFilter Default
CDSufficientSamples ConditionDetection System.ExpressionFilter Default

Overrideable Parameters:

IDParameterTypeSelector
IntervalSecondsint$Config/IntervalSeconds$
WarningThresholdint$Config/WarningThreshold$
ErrorThresholdint$Config/ErrorThreshold$
ConsecutiveSamplesint$Config/ConsecutiveSamples$

Source Code:

<UnitMonitorType ID="Microsoft.SystemCenter.VirtualMachineManager.PRO.VMPressure" Accessibility="Internal">
<MonitorTypeStates>
<MonitorTypeState ID="ConditionError"/>
<MonitorTypeState ID="ConditionWarn"/>
<MonitorTypeState ID="ConditionSuccess"/>
</MonitorTypeStates>
<Configuration>
<xsd:element name="IntervalSeconds" type="xsd:integer"/>
<xsd:element name="VMNames" type="xsd:string"/>
<xsd:element name="WarningThreshold" type="xsd:integer"/>
<xsd:element name="ErrorThreshold" type="xsd:integer"/>
<xsd:element name="ConsecutiveSamples" type="xsd:integer"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int"/>
<OverrideableParameter ID="WarningThreshold" Selector="$Config/WarningThreshold$" ParameterType="int"/>
<OverrideableParameter ID="ErrorThreshold" Selector="$Config/ErrorThreshold$" ParameterType="int"/>
<OverrideableParameter ID="ConsecutiveSamples" Selector="$Config/ConsecutiveSamples$" ParameterType="int"/>
</OverrideableParameters>
<MonitorImplementation>
<MemberModules>
<DataSource ID="DS" TypeID="Microsoft.SystemCenter.VirtualMachineManager.PRO.TimedPowerShell.PerformanceProvider">
<IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
<ScriptName>PowershellVMPressureCheck</ScriptName>
<ScriptBody><Script>
param($VMNames, $WarningThresholdPercent, $ErrorThresholdPercent)

$evt = New-Object System.Diagnostics.Eventlog("Application");
$evt.Source = "Microsoft.SystemCenter.VirtualMachineManager.PRO";
$infoevent = [System.Diagnostics.EventLogEntryType]::Information;

[int]$CurrentPressure = 0;
$oAPI = New-Object -comObject 'MOM.ScriptAPI'
$pBag = $oAPI.CreatePropertyBag()

[int]$state = 0;

$error.Clear()
$counters = Get-Counter "\Hyper-V Dynamic Memory VM(*)\Current Pressure"
if ($counters -ne $null -and $counters.CounterSamples -ne $null)
{
$counterSamples = $counters.CounterSamples;
foreach ($counter in $counterSamples)
{
if ($counter -ne $null -AND $counter.InstanceName -ne $null)
{
$CurrentPressure = $counter.CookedValue;
$name = $counter.InstanceName
# first check for error threshold
if ($CurrentPressure -gt $ErrorThresholdPercent)
{
$state = 2;
$pBag.AddValue('VM', $name);
$pBag.AddValue('CurrentVMPressure', $CurrentPressure);
$pBag.AddValue('PercentMemoryPressureState', $state)
$pBag
break;
}
}
}

if ($state -ne 2)
{
#check for warning state VMs now
foreach ($counter in $counterSamples)
{
if ($counter -ne $null -AND $counter.InstanceName -ne $null)
{
$CurrentPressure = $counter.CookedValue;
$name = $counter.InstanceName
# first check for error threshold
if ($CurrentPressure -gt $WarningThresholdPercent -AND $CurrentPressure -le $ErrorThresholdPercent)
{
$state = 1;
$pBag.AddValue('VM', $name);
$pBag.AddValue('CurrentVMPressure', $CurrentPressure);
$pBag.AddValue('PercentMemoryPressureState', $state)
$pBag
break;
}
}
}
}
}
else
{
$evt.WriteEntry("Could not enumerate instances of Hyper-V Dynamic Memory counter. All VMs may be turned off. " + $error, $infoevent, 100);
}

if ($state -eq 0)
{
# send a property bag with dummy values to indicate everything's fine
$pBag.AddValue('VM', ' ');
$pBag.AddValue('CurrentVMPressure', 0);
$pBag.AddValue('PercentMemoryPressureState', $state)
$pBag
}

</Script></ScriptBody>
<Parameters>
<Parameter>
<Name>VMNames</Name>
<Value>$Config/VMNames$</Value>
</Parameter>
<Parameter>
<Name>WarningThreshold</Name>
<Value>$Config/WarningThreshold$</Value>
</Parameter>
<Parameter>
<Name>ErrorThreshold</Name>
<Value>$Config/ErrorThreshold$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>300</TimeoutSeconds>
<ObjectName>DynamicMemory</ObjectName>
<CounterName>CurrentPressure</CounterName>
<InstanceName>$Data/Property[@Name='VM']$</InstanceName>
<Value>$Data/Property[@Name='CurrentVMPressure']$</Value>
</DataSource>
<ConditionDetection TypeID="Performance!System.Performance.ConsecutiveSamplesCondition" ID="CD1">
<Threshold>$Config/ErrorThreshold$</Threshold>
<Direction>greater</Direction>
</ConditionDetection>
<ConditionDetection TypeID="Performance!System.Performance.ConsecutiveSamplesCondition" ID="CD2">
<Threshold>$Config/WarningThreshold$</Threshold>
<Direction>greater</Direction>
</ConditionDetection>
<ConditionDetection TypeID="System!System.ExpressionFilter" ID="CDSufficientSamples">
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="Double">Value</XPathQuery>
</ValueExpression>
<Operator>GreaterEqual</Operator>
<ValueExpression>
<Value Type="Double">$Config/ConsecutiveSamples$</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</ConditionDetection>
<ConditionDetection TypeID="System!System.ExpressionFilter" ID="CDInSufficientSamples">
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="Double">Value</XPathQuery>
</ValueExpression>
<Operator>Less</Operator>
<ValueExpression>
<Value Type="Double">$Config/ConsecutiveSamples$</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</ConditionDetection>
</MemberModules>
<RegularDetections>
<RegularDetection MonitorTypeStateID="ConditionError">
<Node ID="CDSufficientSamples">
<Node ID="CD1">
<Node ID="DS"/>
</Node>
</Node>
</RegularDetection>
<RegularDetection MonitorTypeStateID="ConditionWarn">
<Node ID="CDSufficientSamples">
<Node ID="CD2">
<Node ID="DS"/>
</Node>
</Node>
</RegularDetection>
<RegularDetection MonitorTypeStateID="ConditionSuccess">
<Node ID="CDInSufficientSamples">
<Node ID="DS"/>
</Node>
</RegularDetection>
</RegularDetections>
</MonitorImplementation>
</UnitMonitorType>