Detailed Memory Unit Monitor

Dell.WindowsServer.Detailed.MemoryUnitUnitMonitor (UnitMonitor)

Knowledge Base article:

Summary

This Health Monitor fetches the State of the Dell Memory Sensor. The status can be one of the following three types:

Success: If the status is success, the memory device status has returned to a normal value.

Warning: If the status is warning, the memory device status is noncritical.

Critical: If the status is critical, the memory device status is critical.

Causes

Warning: The cause for a Warning status may be that a memory device correction rate has exceeded an acceptable value.

Critical: The cause for a Critical status may be that a memory device correction rate exceeded an acceptable value, a memory spare bank was activated, or a multibit ECC error has occurred.

Resolutions

Replace the memory module identified in the message during the system's next scheduled maintenance. Clear the memory error or the multibit ECC error.

When the issue has been resolved, the status changes to Success in the next polling cycle.

Element properties:

TargetDell.WindowsServer.Detailed.MemoryUnit
Parent MonitorSystem.Health.AvailabilityState
CategoryCustom
EnabledTrue
Alert GenerateFalse
Alert Auto ResolveFalse
Monitor TypeMicrosoft.Windows.TimedScript.ThreeStateMonitorType
RemotableTrue
AccessibilityPublic
RunAsDefault

Source Code:

<UnitMonitor ID="Dell.WindowsServer.Detailed.MemoryUnitUnitMonitor" Accessibility="Public" Enabled="true" Target="Dell.WindowsServer.Detailed.MemoryUnit" ParentMonitorID="SystemHealth!System.Health.AvailabilityState" Remotable="true" Priority="Normal" TypeID="Windows!Microsoft.Windows.TimedScript.ThreeStateMonitorType" ConfirmDelivery="false">
<Category>Custom</Category>
<OperationalStates>
<OperationalState ID="Dell.WindowsServer.Detailed.MemoryUnitSuccess" MonitorTypeStateID="Success" HealthState="Success"/>
<OperationalState ID="Dell.WindowsServer.Detailed.MemoryUnitWarning" MonitorTypeStateID="Warning" HealthState="Warning"/>
<OperationalState ID="Dell.WindowsServer.Detailed.MemoryUnitFailure" MonitorTypeStateID="Error" HealthState="Error"/>
</OperationalStates>
<Configuration>
<IntervalSeconds>3600</IntervalSeconds>
<SyncTime/>
<ScriptName>MemoryUnit.vbs</ScriptName>
<Arguments>$MPElement$ $Target/Id$ $Config/Computer$ $Target/Property[Type="Dell.WindowsServer.Detailed.MemoryUnit"]/Tag$</Arguments>
<ScriptBody><Script>
Option Explicit
On Error Resume Next
SetLocale("en-us")

Dim oArgs
Set oArgs = WScript.Arguments
if oArgs.Count &lt; 4 Then
Wscript.Quit -1
End If

Dim strComputer, objDellConnection, logMessage, sQuery, colItems, objItemMemory, MemoryStatus, TargetComputer, prmDeviceID
TargetComputer = oArgs(2)
prmDeviceID = oArgs(3)
strComputer = "."

set objDellConnection = GetObject("winmgmts:" &amp; "{impersonationLevel=impersonate}!\\" &amp; strComputer &amp; "\root\cimv2\Dell")
If Err.Number &lt;&gt; 0 Then
logMessage = "WMI Cimv2Dell Error Number : " &amp; Err.Number &amp; ". Description :" &amp; Err.Description
Err.Clear
Else
If IsEmpty(objDellConnection) Then
logMessage = "Unable to open WMI Namespace root-cimv2-dell. Check to see if the WMI service is enabled and running, and Install/Re-Install ServerAdministrator to ensure this WMI namespace exists. " &amp; Err
Else
sQuery = "Select * from CIM_PhysicalMemory WHERE Tag = '" &amp; prmDeviceID &amp; "'"
Set colItems = GetObjectSet(objDellConnection, sQuery, "Name", "CIM_PhysicalMemory")
If Err.Number &lt;&gt; 0 Then
logMessage = sQuery &amp; " Error Number:" &amp; Err.Number &amp; "Description:" &amp; Err.Description
If Err.Number = -2147023169 Then
logMessage = "RPC Failure occurred for namespace root-cimv2-dell"
End If
Err.Clear
End If
If colItems is Nothing Then
logMessage = "Unable to retrieve CIM_PhysicalMemory object"
Else
logMessage = "CIM_PhysicalMemory object retrieved"
For Each objItemMemory in colItems
If Err.Number &lt;&gt; 0 Then
If Err.Number = -2147023169 Then
logMessage = "RPC Failure occurred for cimv2\dell - bmc info : " &amp; Err.Number
ElseIf Err.Number = -2147217389 Then
logMessage = "If PWS present, Please Install/Re-Install ServerAdministrator on Dell Server : " &amp; Err.Number
Else
logMessage = "Object RetrievalLoop Error Number:" &amp; Err.Number &amp; "Description:" &amp; Err.Description
End If
Err.Clear
End If
If Not objItemMemory is Nothing Then
MemoryStatus = objItemMemory.Status
End If
Next
End If 'colItems is nothing
Set colItems = Nothing
End If 'dellconnection is noting
On Error GoTo 0
End If

If MemoryStatus = "Stressed" OR MemoryStatus = "Degraded" Then
MemoryStatus = "Warning"
ElseIf MemoryStatus = "Non-recover" Then
MemoryStatus = "Error"
End If

Dim oAPI, oBag
Set oAPI = CreateObject("MOM.ScriptAPI")
Set oBag = oAPI.CreatePropertyBag()
Call oBag.AddValue("Status",MemoryStatus)
Call oAPI.Return(oBag)

' *** Add double query fix

' Function to retrieve the object

Function GetObjectSet(ByRef objDellConnection, SelectQuery, Attribute, objName)
Dim retry, retryFlag
Dim objItem, arrURL, logMessage

On Error Resume Next
RetryFlag = False
For retry = 0 To 1
MOMDebugLog 1, "Retrying for " &amp; retry &amp; " time..."
Set GetObjectSet = objDellConnection.ExecQuery(SelectQuery)
LogErrorNumber(objName)
If (GetObjectSet is Nothing) Or (IsNull(GetObjectSet)) Then
logMessage = "INFO: Unable to retrieve " &amp; objName &amp; " Attributes"
MOMDebugLog 1, logMessage
WScript.Sleep(1000)
RetryFlag = True
Else
logMessage= "INFO: " &amp; objName &amp; " attributes retrieved successfully"
MOMDebugLog 1, logMessage
If Attribute = "__COUNT__" Then
Exit For
End If
For Each objItem in GetObjectSet
If LogErrorNumber(objName) = 0 Then
If Not objItem is nothing Then
Dim attrVal : attrVal = objItem.Properties_.Item(Attribute)
If IsNull(attrVal) Or Len(attrVal) &lt;= 0 Then
MOMDebugLog 1, Attribute &amp; " value is null or empty"
RetryFlag = True
WScript.Sleep(500)
Exit For
Else
Exit Function
End If
End If
End If
Next
If RetryFlag = False Then
Exit For
End If
End If
Next
End Function

Function LogErrorNumber(objName)
Dim logMessage
LogErrorNumber = Err.Number
If Err.Number &lt;&gt; 0 Then
Select Case Err.Number
Case -2147749904
logMessage = "CIM Object not found"
Case -2147749902
logMessage = "Dell CIM object not found"
Case -2147023169
logMessage = "RPC Failure occurred for namespace root-cimv2-dell"
Case -2147217389
logMessage = "Please Install/Re-Install ServerAdministrator on Dell Server!"
Case -2147217394 '0x8004100E
logMessage = "Not able to find Dell CIM object"
Case -2147217392 '0x8004100C
logMessage = "Not able to find the collection"
Case -2147749890
logMessage = "Object cannot be found"
Case -2147749892
logMessage = "Object cannot be found"
Case Else
logMessage = "Unable to retrieve " &amp; objName
logMessage = logMessage &amp; " Err Number:" &amp; Err.Number
logMessage = logMessage &amp; " Err Descr:" &amp; Err.Description
End Select
MOMDebugLog 1, "ERROR: " &amp; logMessage
End If
End Function
'*** Add MOMDebug
Const DEBUG_LOG_FILENAME = "MemoryUnit.log"
Dim loginited: loginited = False
Dim objLogTextFile, objLogFSO

Sub InitLog(strFileName)
' Begin Logheader
If logLevel &lt;&gt; 0 And loginited = False Then
Dim fileSize, strOutFile
Const ForAppending = 8
Const ForWriting = 2
Const MaxFileSize = 524288 'File Size is limited to 512 KB

dim wsShell : Set wsShell = Createobject("WScript.Shell")
dim wshSysEnv : Set wshSysEnv = wsShell.Environment
dim tFolder : tFolder = wshSysEnv("TEMP")
dim wshPrcEnv : Set wshPrcEnv = wsShell.Environment("Process")
tFolder = Replace(tFolder, "%SystemRoot%", wshPrcEnv("SYSTEMROOT"), 1, -1, vbTextCompare)

Set objLogFSO = CreateObject("Scripting.FileSystemObject")
If Not objLogFSO.FolderExists(tFolder) Then
objLogFSO.CreateFolder(tFolder)
End If
strOutFile = tFolder &amp; "\"&amp; strFileName
WScript.Echo strOutFile
If Not objLogFSO.FileExists(strOutFile) Then
Set objLogTextFile = objLogFSO.CreateTextFile(strOutFile)
objLogTextFile.Close()
End If
fileSize = objLogFSO.GetFile(strOutFile).Size
If (fileSize &gt; MaxFileSize) Then
Set objLogTextFile = objLogFSO.OpentextFile(strOutFile, ForWriting, True)
Else
Set objLogTextFile = objLogFSO.OpentextFile(strOutFile, ForAppending, True)
End If
loginited = True
MOMDebugLog 1, "------------------------------------------------------"
MOMDebugLog 1, "INFO: Script - " &amp; strFileName &amp; ": Start()"
Err.Clear
End If
End Sub

Sub MOMDebugLog (ByVal debugLevel, ByVal Message)
'On Error Resume Next
If (debugLevel &gt; 0) and (debugLevel &lt;= logLevel) Then
If loginited = False Then
InitLog DEBUG_LOG_FILENAME
End If
objLogTextFile.WriteLine(Now() &amp; " ---- " &amp; Message)
Err.Clear
End If
End Sub

Sub CloseLog
' Begin Logheader
If loginited = True Then
objLogTextFile.Close
End If
End Sub

CloseLog
</Script></ScriptBody>
<TimeoutSeconds>300</TimeoutSeconds>
<ErrorExpression>
<SimpleExpression>
<ValueExpression>
<XPathQuery>Property[@Name='Status']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">Error</Value>
</ValueExpression>
</SimpleExpression>
</ErrorExpression>
<WarningExpression>
<SimpleExpression>
<ValueExpression>
<XPathQuery>Property[@Name='Status']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">Warning</Value>
</ValueExpression>
</SimpleExpression>
</WarningExpression>
<SuccessExpression>
<SimpleExpression>
<ValueExpression>
<XPathQuery>Property[@Name='Status']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">OK</Value>
</ValueExpression>
</SimpleExpression>
</SuccessExpression>
</Configuration>
</UnitMonitor>