Category Archives: Management Pack Downloads

The question of how to manage the logical disk free space monitor comes up time and time again. Just about every customer I’ve worked with, and all over the forums, people express their disdain for and frustration of managing overrides related to this monitor – and for good reason. It’s one of those monitors that touch every type of logical disk on every computer in the environment, and of course there are going to be different threshold requirements that require overrides – even the out-of-box flexibility of using both types of thresholds (mb and %) usually isn’t enough for us to “set it and forget it”.

This a great opportunity to reduce administrative overhead by enabling local administrators to change monitoring thresholds directly on the local machine, without having to login to the console and create overrides.

Because this is such a popular request, I’ve extended the Logical Disk Free Space monitor and added it to the Windows Monitoring (Extended) community pack.

NOTE 1 – There are overrides defined in the pack that disable the vendor Logical Disk Free Space unit monitor. Once this pack is installed, that monitor will be replaced by this monitor. If you have overrides applied to the vendor monitors that you want to keep, those will need to be applied to this new unit monitor.

NOTE 2 – The unit monitor works out of the box exactly the same say as the original Logical Disk Free Space unit monitor. It will only behave differently if you implement the extended features of the unit monitor.

NOTE 3 – I chose to target Microsoft.Windows.LogicalDisk because the script data source, according to library documentation, should run fine against all versions of Windows. This reduces it from three monitors to just one.

Product knowledge has also been extended to include usage instructions:

An alert generated by this monitor will look like this:

A state change event (health explorer) for this monitor will look like this:

I’ve seen this in the forums quite a bit, so I felt I should write a pack that monitor for Windows % memory used. I basically just took the script from the Windows packs, that claims (in the script comments) to work across all base Windows OS’s, and plugged it into a data source. Then I created a monitor type and a unit monitor.

I will post the xml here, but you can also download the management pack at the end of the post. I have only tested this on Windows 2008 and Windows 2012. As the base OS script says, it’s compatible with all versions. The default target of the unit monitor is Windows Server Operating System, so keep that in mind. The unit monitor is enabled by default. Because it target Windows Server Operating System, the Source of the alert will be just that; it will not be the computer name.

By default, it runs every 15 minutes and has a threshold of 90%. It will alert after 2 intervals over threshold. You can override interval, threshold, and match count. MatchCount is the number of intervals over threshold before generating an alert. You choose how you want to implement it 🙂

'************************************************************************* ' $ScriptName: "Microsoft.Windows.Server.Common"$ ' ' Purpose: To have one place for common stuff across various BaseOS VBScripts ' ' $File: Microsoft.Windows.Server.Common.vbs$ '*************************************************************************

For i = 0 To i &lt; N On Error Resume Next Set oInstance = oWMI.InstancesOf(sInstance) e.Save On Error Goto 0 If IsEmpty(oInstance) Or e.Number &lt;&gt; 0 Then If i = N - 1 Then ThrowScriptError "The class name '" &amp; sInstance &amp; "' returned no instances. Please check to see if this is a valid WMI class name.", e End If Else On Error Resume Next nInstanceCount = oInstance.Count e.Save On Error Goto 0 If e.Number &lt;&gt; 0 Then If i = N - 1 Then ThrowScriptError "The class name '" &amp; sInstance &amp; "' did not return any valid instances. Please check to see if this is a valid WMI class name.", e End If Else Exit For End If End If WScript.Sleep(1000) Next

On Error Resume Next Set oInstance = oWMI.InstancesOf(sInstance) e.Save On Error Goto 0 If IsEmpty(oInstance) Or e.Number &lt;&gt; 0 Then ThrowScriptError "The class name '" &amp; sInstance &amp; "' returned no instances. Please check to see if this is a valid WMI class name.", e End If

'Determine if we queried a valid WMI class - Count will return 0 or empty On Error Resume Next nInstanceCount = oInstance.Count e.Save On Error Goto 0 If e.Number &lt;&gt; 0 Then ThrowScriptError "The class name '" &amp; sInstance &amp; "' did not return any valid instances. Please check to see if this is a valid WMI class name.", e End If

Set WMIGetInstanceEx = oInstance End Function

'--------------------------------------------------------------------------- ' Connect to WMI. '--------------------------------------------------------------------------- Function WMIConnect(ByVal sNamespace) Dim oWMI Dim e Set e = New Error On Error Resume Next Set oWMI = GetObject(sNamespace) e.Save On Error Goto 0 If IsEmpty(oWMI) Then ThrowScriptError "Unable to open WMI Namespace '" &amp; sNamespace &amp; "'. Check to see if the WMI service is enabled and running, and ensure this WMI namespace exists.", e End If Set WMIConnect = oWMI End Function

On Error Resume Next Set oWMI = GetObject(sNamespace) If Not IsEmpty(oWMI) Then Set oInstance = oWMI.InstancesOf(sInstance) If Not IsEmpty(oInstance) And Err.Number = 0 Then 'Determine if we queried a valid WMI class - Count will return 0 or empty nInstanceCount = oInstance.Count If Err.Number = 0 Then Set WMIGetInstanceNoAbort = oInstance On Error Goto 0 Exit Function End If End If End If

On Error Goto 0 Set WMIGetInstanceNoAbort = Nothing End Function

'--------------------------------------------------------------------------- ' Executes the WMI query and returns the result set. '--------------------------------------------------------------------------- Function WMIExecQuery(ByVal sNamespace, ByVal sQuery) Dim oWMI, oQuery, nInstanceCount Dim e Set e = New Error On Error Resume Next Set oWMI = GetObject(sNamespace) e.Save On Error Goto 0 If IsEmpty(oWMI) Then ThrowScriptError "Unable to open WMI Namespace '" &amp; sNamespace &amp; "'. Check to see if the WMI service is enabled and running, and ensure this WMI namespace exists.", e End If

On Error Resume Next Set oQuery = oWMI.ExecQuery(sQuery) e.Save On Error Goto 0 If IsEmpty(oQuery) Or e.Number &lt;&gt; 0 Then ThrowScriptError "The Query '" &amp; sQuery &amp; "' returned an invalid result set. Please check to see if this is a valid WMI Query.", e End If

'Determine if we queried a valid WMI class - Count will return 0 or empty On Error Resume Next nInstanceCount = oQuery.Count e.Save On Error Goto 0 If e.Number &lt;&gt; 0 Then ThrowScriptError "The Query '" &amp; sQuery &amp; "' did not return any valid instances. Please check to see if this is a valid WMI Query.", e End If

' Check that object is valid. If Not IsValidObject(oWmi) Then If (ErrAction And ErrAction_ThrowError) = ErrAction_ThrowError Then _ ThrowScriptErrorNoAbort "Accessing property on invalid WMI object.", oError If (ErrAction And ErrAction_Abort) = ErrAction_Abort Then _ Quit()

'--------------------------------------------------------------------------- ' Checks whether oObject is valid. '--------------------------------------------------------------------------- Function IsValidObject(ByVal oObject) IsValidObject = False If IsObject(oObject) Then If Not oObject Is Nothing Then IsValidObject = True End If End If End Function

With oBag .AddValue "PerfCounter", sCounterName .AddValue "PerfValue", nResult End With

oAPI.AddItem oBag

oAPI.ReturnItems

End If

End Sub</ScriptBody><TimeoutSeconds>300</TimeoutSeconds></ProbeAction><ConditionDetectionID="PerfMapper"TypeID="Perf!System.Performance.DataGenericMapper"><ObjectName>Memory</ObjectName><CounterName>$Data/Property[@Name='PerfCounter']$</CounterName><InstanceName/><Value>$Data/Property[@Name='PerfValue']$</Value></ConditionDetection><ConditionDetectionID="IsNullCD"TypeID="System!System.ExpressionFilter"><Expression><SimpleExpression><ValueExpression><XPathQueryType="String">/DataItem/IsNull</XPathQuery></ValueExpression><Operator>Equal</Operator><ValueExpression><ValueType="String">false</Value></ValueExpression></SimpleExpression></Expression></ConditionDetection></MemberModules><Composition><NodeID="PerfMapper"><NodeID="ScriptDS"><NodeID="IsNullCD"><NodeID="PerfDS"/></Node></Node></Node></Composition></Composite></ModuleImplementation><OutputType>Perf!System.Performance.Data</OutputType></DataSourceModuleType></ModuleTypes><MonitorTypes><UnitMonitorTypeID="Windows.Monitoring.Extended.MonitorType.PercentMemoryUsed"Accessibility="Public"><MonitorTypeStates><MonitorTypeStateID="MTS_Over"/><MonitorTypeStateID="MTS_Under"/></MonitorTypeStates><Configuration><xsd:elementminOccurs="1"name="PhysicalMemory"type="xsd:double"xmlns:xsd="http://www.w3.org/2001/XMLSchema"/><xsd:elementminOccurs="1"name="IntervalSeconds"type="xsd:integer"xmlns:xsd="http://www.w3.org/2001/XMLSchema"/><xsd:elementminOccurs="1"name="Threshold"type="xsd:double"xmlns:xsd="http://www.w3.org/2001/XMLSchema"/><xsd:elementminOccurs="1"name="MatchCount"type="xsd:integer"xmlns:xsd="http://www.w3.org/2001/XMLSchema"/></Configuration><OverrideableParameters><OverrideableParameterID="IntervalSeconds"Selector="$Config/IntervalSeconds$"ParameterType="int"/><OverrideableParameterID="Threshold"Selector="$Config/Threshold$"ParameterType="double"/><OverrideableParameterID="MatchCount"Selector="$Config/MatchCount$"ParameterType="int"/></OverrideableParameters><MonitorImplementation><MemberModules><DataSourceID="Script"TypeID="Windows.Monitoring.Extended.DataSource.PercentMemoryUsed"><PhysicalMemory>$Config/PhysicalMemory$</PhysicalMemory><IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds></DataSource><ConditionDetectionID="CD_Under"TypeID="System!System.ExpressionFilter"><Expression><SimpleExpression><ValueExpression><XPathQueryType="Double">Value</XPathQuery></ValueExpression><Operator>Less</Operator><ValueExpression><ValueType="Double">$Config/Threshold$</Value></ValueExpression></SimpleExpression></Expression></ConditionDetection><ConditionDetectionID="CD_Over"TypeID="System!System.ExpressionFilter"><Expression><SimpleExpression><ValueExpression><XPathQueryType="Double">Value</XPathQuery></ValueExpression><Operator>GreaterEqual</Operator><ValueExpression><ValueType="Double">$Config/Threshold$</Value></ValueExpression></SimpleExpression></Expression><SuppressionSettings><MatchCount>$Config/MatchCount$</MatchCount></SuppressionSettings></ConditionDetection></MemberModules><RegularDetections><RegularDetectionMonitorTypeStateID="MTS_Under"><NodeID="CD_Under"><NodeID="Script"/></Node></RegularDetection><RegularDetectionMonitorTypeStateID="MTS_Over"><NodeID="CD_Over"><NodeID="Script"/></Node></RegularDetection></RegularDetections></MonitorImplementation></UnitMonitorType></MonitorTypes></TypeDefinitions><Monitoring><Monitors><UnitMonitorID="Windows.Monitoring.Extended.Monitor.PercentMemoryUsed"Accessibility="Public"Enabled="true"ParentMonitorID="Health!System.Health.PerformanceState"Priority="Normal"Target="Windows!Microsoft.Windows.Server.OperatingSystem"TypeID="Windows.Monitoring.Extended.MonitorType.PercentMemoryUsed"><Category>PerformanceHealth</Category><AlertSettingsAlertMessage="Windows.Monitoring.Extended.AlertMessage.PercentMemoryUsed"><AlertOnState>Error</AlertOnState><AutoResolve>true</AutoResolve><AlertPriority>Normal</AlertPriority><AlertSeverity>Error</AlertSeverity><AlertParameters><AlertParameter1>$Data/Context/Value$</AlertParameter1></AlertParameters></AlertSettings><OperationalStates><OperationalStateID="OpState_Healthy"HealthState="Success"MonitorTypeStateID="MTS_Under"/><OperationalStateID="OpState_Unhealty"HealthState="Error"MonitorTypeStateID="MTS_Over"/></OperationalStates><Configuration><PhysicalMemory>$Target/Property[Type="Windows!Microsoft.Windows.OperatingSystem"]/PhysicalMemory$</PhysicalMemory><IntervalSeconds>900</IntervalSeconds><Threshold>90</Threshold><MatchCount>2</MatchCount></Configuration></UnitMonitor></Monitors></Monitoring><Presentation><StringResources><StringResourceID="Windows.Monitoring.Extended.AlertMessage.PercentMemoryUsed"/></StringResources></Presentation><LanguagePacks><LanguagePackID="ENU"IsDefault="true"><DisplayStrings><DisplayStringElementID="Windows.Monitoring.Extended.Monitor.PercentMemoryUsed"><Name>Windows Percent Memory Used Monitor</Name></DisplayString><DisplayStringElementID="Windows.Monitoring.Extended.AlertMessage.PercentMemoryUsed"><Name>Windows Memory Over Threshold</Name><Description>Windows memory is currently at 0: {0}%</Description></DisplayString></DisplayStrings><KnowledgeArticles></KnowledgeArticles></LanguagePack></LanguagePacks></ManagementPack>