Windows Memory Available MBytes Utilization Monitor Type

Microsoft.Windows.Server.10.0.MemoryAvailableMBytes.Monitortype (UnitMonitorType)

Element properties:

RunAsDefault
AccessibilityInternal
Support Monitor RecalculateFalse

Member Modules:

ID Module Type TypeId RunAs 
ScriptDS DataSource Microsoft.Windows.Server.10.0.MemoryAvailableMBytes.ModuleType Default
ProbeActionDS ProbeAction Microsoft.Windows.Server.10.0.PowerShellPropertyBagProbe Default
FilterNotOK ConditionDetection System.ExpressionFilter Default
FilterOK ConditionDetection System.ExpressionFilter Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
IntervalSecondsint$Config/IntervalSeconds$Interval secondsHow frequently (in seconds) the value should be sampled.
TimeoutSecondsint$Config/TimeoutSeconds$Timeout Seconds
MemoryThresholddouble$Config/MemoryThreshold$Available Memory Threshold (MBytes)
NumSamplesint$Config/NumSamples$Number of Samples

Source Code:

<UnitMonitorType ID="Microsoft.Windows.Server.10.0.MemoryAvailableMBytes.Monitortype" Accessibility="Internal">
<MonitorTypeStates>
<MonitorTypeState ID="MemoryAvailableMBytesNormal"/>
<MonitorTypeState ID="MemoryAvailableMBytesLow"/>
</MonitorTypeStates>
<Configuration>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="IntervalSeconds" type="xsd:int"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="TimeoutSeconds" type="xsd:integer"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="TargetComputerName" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="MemoryThreshold" type="xsd:double"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="NumSamples" type="xsd:int"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="CounterName" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="ObjectName" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="InstanceName" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="AllInstances" type="xsd:boolean"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int"/>
<OverrideableParameter ID="TimeoutSeconds" ParameterType="int" Selector="$Config/TimeoutSeconds$"/>
<OverrideableParameter ID="MemoryThreshold" Selector="$Config/MemoryThreshold$" ParameterType="double"/>
<OverrideableParameter ID="NumSamples" Selector="$Config/NumSamples$" ParameterType="int"/>
</OverrideableParameters>
<MonitorImplementation>
<MemberModules>
<DataSource ID="ScriptDS" TypeID="Microsoft.Windows.Server.10.0.MemoryAvailableMBytes.ModuleType">
<IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
<TargetComputerName>$Config/TargetComputerName$</TargetComputerName>
<NumSamples>$Config/NumSamples$</NumSamples>
<CounterName>$Config/CounterName$</CounterName>
<ObjectName>$Config/ObjectName$</ObjectName>
<InstanceName>$Config/InstanceName$</InstanceName>
<AllInstances>$Config/AllInstances$</AllInstances>
</DataSource>
<ProbeAction ID="ProbeActionDS" TypeID="Microsoft.Windows.Server.10.0.PowerShellPropertyBagProbe">
<ScriptName>MemoryUtilization.ps1</ScriptName>
<PSparam>param ($MEMORY_THRESHOLD, $TargetComputer, $AvailableMBytes)</PSparam>
<ScriptBody><Script>
# ##### Scripts\PowerShell\MemoryUtilization.ps1
#Copyright (c) Microsoft Corporation. All rights reserved.

# Parameters that should be passed to this script
# 0 MEMORY_THRESHOLD
# 1 Computer (FQDN) that the Mount Point will be hosted on

Function Main()
{
$ErrorActionPreference = "SilentlyContinue"
$oBag = $momAPI.CreatePropertyBag()
$ERROR_KEY_NOT_FOUND = 2

Load-CimModules
try
{
$cimSessionOption = New-CimSessionOption -Protocol DCOM
$cimsession = New-CimSession -ComputerName $TargetComputer -SessionOption $cimSessionOption
$ret = Invoke-CimMethod -CimSession $cimsession -ClassName StdRegProv -NameSpace root/default -MethodName GetStringValue -Arguments @{sSubKeyName="SYSTEM\CurrentControlSet\Services\MSExchangeSA";sValueName=""}
}
Finally
{
Get-CimSession | Remove-CimSession
$cimsession =$null
$cimSessionOption = $null
}
if ($ret.ReturnValue -eq $ERROR_KEY_NOT_FOUND)
{
if ([double]$AvailableMBytes -ge [double]$MEMORY_THRESHOLD)
{
$oBag.AddValue("State", "GOOD")
$oBag.AddValue("AvailableMBytes", $AvailableMBytes + "")
$oBag
}
else
{
$oBag.AddValue("State", "BAD")
$oBag.AddValue("AvailableMBytes", $AvailableMBytes + "")
$oBag
}
}
else
{
# FIXME Should We have to generate the event?
$oBag.AddValue("State", "GOOD")
$oBag.AddValue("AvailableMBytes", $AvailableMBytes + "")
$oBag
}

Unload-Module -ModuleName "CimCmdlets"
}
Function Load-CimModules
{
$error.Clear()

$CimModule = Get-Module CimCmdlets

if ($null -eq $CimModule)
{
Import-Module CimCmdlets
$error.Clear()
}
}
Main</Script></ScriptBody>
<Parameters>
<Parameter>
<Name>MEMORY_THRESHOLD</Name>
<Value>$Config/MemoryThreshold$</Value>
</Parameter>
<Parameter>
<Name>TargetComputer</Name>
<Value>$Config/TargetComputerName$</Value>
</Parameter>
<Parameter>
<Name>AvailableMBytes</Name>
<Value>$Data/Value$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
</ProbeAction>
<ConditionDetection ID="FilterOK" TypeID="System!System.ExpressionFilter">
<Expression>
<RegExExpression>
<ValueExpression>
<XPathQuery>Property[@Name='State']</XPathQuery>
</ValueExpression>
<Operator>ContainsSubstring</Operator>
<Pattern>GOOD</Pattern>
</RegExExpression>
</Expression>
</ConditionDetection>
<ConditionDetection ID="FilterNotOK" TypeID="System!System.ExpressionFilter">
<Expression>
<RegExExpression>
<ValueExpression>
<XPathQuery>Property[@Name='State']</XPathQuery>
</ValueExpression>
<Operator>ContainsSubstring</Operator>
<Pattern>BAD</Pattern>
</RegExExpression>
</Expression>
</ConditionDetection>
</MemberModules>
<RegularDetections>
<RegularDetection MonitorTypeStateID="MemoryAvailableMBytesNormal">
<Node ID="FilterOK">
<Node ID="ProbeActionDS">
<Node ID="ScriptDS"/>
</Node>
</Node>
</RegularDetection>
<RegularDetection MonitorTypeStateID="MemoryAvailableMBytesLow">
<Node ID="FilterNotOK">
<Node ID="ProbeActionDS">
<Node ID="ScriptDS"/>
</Node>
</Node>
</RegularDetection>
</RegularDetections>
</MonitorImplementation>
</UnitMonitorType>