Dell Client Temperature Sensor Status(Periodic)

Dell.WindowsClient.ClientTemperatureUnitUnitMonitor (UnitMonitor)

Unit Monitor to calculate Dell Client Temperature Sensor Status Periodically.

Knowledge Base article:

Summary

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

Success: If the status is success, the temperature sensor returned to a normal state.

Warning: If the status is warning, the temperature sensor is reporting a warning state.

Critical: If the status is critical, the temperature sensor detected a failure state.

Causes

Warning: The cause for a Warning status may be that a temperature sensor in the specified client system has exceeded its warning threshold.

Critical: The cause for a Critical status may be that a temperature sensor in the specified client system has exceeded its failure threshold or detected an error from which it cannot recover. Additional details are available in the product knowledge of the last modified OMCI / Dell Command | Monitor alert that caused the state change.

Resolutions

Perform the following steps for the Warning and Critical messages:

Warning: A Warning message refers to an event that is not necessarily significant, but may indicate a possible future problem. Plan to proactively change the environment, such as power or cooling, based on the pattern of occurrence; or replace the failed component, based on the impact to operations, if the temperature sensor goes to a critical state.

Critical: A Critical message refers to a significant event that indicates actual or imminent loss of data or loss of function. Change the environment, such as cooling or power, as appropriate; or replace the failed component. Additional details are available in the product knowledge of the last modified OMCI / Dell Command | Monitor alert that caused the state change.

When the issue has been resolved, the status changes to Success.

Element properties:

TargetDell.WindowsClient.Sensors
Parent MonitorSystem.Health.AvailabilityState
CategoryAvailabilityHealth
EnabledTrue
Alert GenerateFalse
Alert Auto ResolveTrue
Monitor TypeMicrosoft.Windows.TimedScript.ThreeStateMonitorType
RemotableTrue
AccessibilityInternal
RunAsDefault

Source Code:

<UnitMonitor ID="Dell.WindowsClient.ClientTemperatureUnitUnitMonitor" Accessibility="Internal" Enabled="onEssentialMonitoring" Target="Dell.WindowsClient.Sensors" ParentMonitorID="SystemHealth!System.Health.AvailabilityState" Remotable="true" Priority="Normal" TypeID="Windows!Microsoft.Windows.TimedScript.ThreeStateMonitorType" ConfirmDelivery="false">
<Category>AvailabilityHealth</Category>
<OperationalStates>
<OperationalState ID="Dell.WindowsClient.ClientTemperatureUnitSuccess" MonitorTypeStateID="Success" HealthState="Success"/>
<OperationalState ID="Dell.WindowsClient.ClientTemperatureUnitWarning" MonitorTypeStateID="Warning" HealthState="Warning"/>
<OperationalState ID="Dell.WindowsClient.ClientTemperatureUnitFailure" MonitorTypeStateID="Error" HealthState="Error"/>
</OperationalStates>
<Configuration>
<IntervalSeconds>3600</IntervalSeconds>
<SyncTime/>
<ScriptName>ClientTemperatureUnit.vbs</ScriptName>
<Arguments>$Config/Computer$</Arguments>
<ScriptBody><Script>
'**********************************************************************************
' Script Name - Dell Client Discovery
' Author: Manoj Kumar Bora
'
' Description:
' Discover Dell Client and components for a Dell Client with OMCI / Dell Command | Monitor
'
' (c) Copyright Dell Inc. 2007-2012 All rights reserved
'**********************************************************************************

Option Explicit
On Error Resume Next
SetLocale("en-us")
Dim oArgs
Set oArgs = WScript.Arguments
if oArgs.Count &lt; 1 Then
Wscript.Quit -1
End If

Dim logMessage, targetComputer, DebugScript, logLevel, objLogTextFile, objLogFSO
targetComputer = oArgs(0)
logLevel = 0
DebugScript = false
' Begin Logheader
If logLevel &lt;&gt; 0 Then
Dim fileSize, strOutFile
Const strFileName = "Monitor_DellWindowsClient_Temparature.log"
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
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
logMessage = "INFO: Script - Dell Client Temperature Monitoring : Start()"
MOMDebugLog 1, logMessage
Err.Clear
End If

Sub MOMDebugLog (ByVal debugLevel, ByVal Message)
On Error Resume Next
DebugOut Message
If (debugLevel &gt; 0) and (debugLevel &lt;= logLevel) Then
objLogTextFile.WriteLine(Now() &amp; " ---- " &amp; Message)
Err.Clear
End If
End Sub
' End of Logheader
Class HealthComputer

Private m_fetcherObj
private m_pairObj
private m_temperatureSensor
private m_omciVersion

Public Default Function Init(pairs, omciVer)
PairObj = pairs
m_omciVersion = omciVer
Set Init = Me
End Function

private Function SanitizeValue(val)
LogMessage ="Val" &amp; val
MOMDebugLog 1, logMessage
SanitizeValue = val
'val = trim(val)
if ((val = "") or isNull(val) ) Then SanitizeValue = "Not Available"
End Function

public Property Get FetcherObj
FetcherObj = m_fetcherObj
End Property
Public Property Let FetcherObj(value)
m_fetcherObj = SanitizeValue(value)
End Property

public Property Get PairObj
PairObj = m_pairObj
End Property
Public Property Let PairObj(value)
m_pairObj = value
End Property

public Property Get TemperatureSensor
Dim temperatureStatus
LogMessage ="TemperatureSensor "
MOMDebugLog 1, logMessage
Dim fetcherObj, errorFlag, warningFlag

Dim b, versionNum
b = split(m_omciVersion, ".")
versionNum = b(0)
Set fetcherObj = New Fetcher
fetcherObj.DCMVersion = versionNum
TemperatureSensor = fetcherObj.GetHealthStatus(m_pairObj(0))


End Property
Public Property Let TemperatureSensor(value)
m_temperatureSensor = SanitizeValue(value)
End Property

End Class

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 = "Err: Unable to retrieve " &amp; objName &amp; vbCrLf &amp;_
" Error number: " &amp; Err.Number &amp; vbCrLf &amp;_
" Error description: '" &amp; Err.Description &amp; vbCrLf
End Select
MOMDebugLog 1, "ERROR: " &amp; logMessage

End If
End Function

' OMCI 7.x Creator

Class AttrNamePair
public WMIObjectName
public WMIObjectAttribute
public WMIServices
public index
End Class

Function CreateAttrNamePair(wmiService, wmiObject, wmiAttribute)
Set CreateAttrNamePair = New AttrNamePair
Set CreateAttrNamePair.WMIServices = wmiService
CreateAttrNamePair.WMIObjectName = wmiObject
CreateAttrNamePair.WMIObjectAttribute = wmiAttribute
End Function

Function CreateArrayAttrNamePair(wmiService, wmiObject, wmiAttribute, index)
Set CreateArrayAttrNamePair = New AttrNamePair
Set CreateArrayAttrNamePair.WMIServices = wmiService
CreateArrayAttrNamePair.WMIObjectName = wmiObject
CreateArrayAttrNamePair.WMIObjectAttribute = wmiAttribute
CreateArrayAttrNamePair.index = index
End Function

Class OMCI7x
private healthComputerObj, wbemServices, cmiV2WbemServices
private m_version
Public Default Function Init(version)
m_version = version
Set Init = Me
End Function

public Function getHealthComputer()

Dim strComputer : strComputer = "."
Err.Clear
Set wbemServices = GetObject("winmgmts:" &amp; "{impersonationLevel=impersonate}!\\" &amp; strComputer &amp; "\root\dellomci")
LogErrorNumber("root\dellomci")
logMessage = "getHealthComputer "
MOMDebugLog 1, logMessage
Dim pairs(1), i
i = -1
i = i + 1: Set pairs(i) = CreateAttrNamePair(wbemServices, "Dell_TemperatureSensor", "Status")

If IsEmpty(wbemServices) Then
logMessage = "Unable to open WMI Namespace root-dellomci. Check to see if the WMI service is enabled and running, and ensure this WMI namespace exists."
MOMDebugLog 1, logMessage
Else
Set healthComputerObj = (new HealthComputer)(pairs, m_version)
Set getHealthComputer = healthComputerObj
End If
End Function
End Class

Class Fetcher
private m_healthComputerObj
private m_DCMVersion
Public Default Function Init( healthComputerObj)
m_healthComputerObj = healthComputerObj
Set Init = Me
End Function
private Function SanitizeValue(val)
SanitizeValue = val
val = trim(val)
if (val = "") Then SanitizeValue = "Not Available"
End Function

public Property Get DCMVersion
DCMVersion = m_DCMVersion
End Property
Public Property Let DCMVersion(value)
m_DCMVersion = SanitizeValue(value)
End Property

Function GetAttribute(ByRef objItem, AttributeName)
If not objItem is nothing Then
Dim STR, arrayAttr
logMessage = "AttributeName " &amp; AttributeName
MOMDebugLog 1, logMessage
GetAttribute = objItem.Properties_.Item("" &amp; AttributeName)
If IsNull(GetAttribute) Then
logMessage = AttributeName &amp; " value is null"
MOMDebugLog 1, logMessage
ElseIf Len(GetAttribute) &lt;= 0 Then
logMessage = AttributeName &amp; " value is empty"
MOMDebugLog 1, logMessage
End If
logMessage = "Returning: " &amp; AttributeName &amp; " = " &amp; GetAttribute
MOMDebugLog 1, logMessage
'logMessage = "" &amp; AttributeName &amp; " " &amp; GetAttribute
End If
end function

public Function GetScalarAttribute(wbemServices, wmiobjectname, wmiattributename)
logMessage = "GetScalarAttribute Called"
MOMDebugLog 1, logMessage
On Error Resume Next
Dim wbemObjectSet,errorFlag
errorFlag = "OK"
Set wbemObjectSet = wbemServices.ExecQuery("Select * from " + wmiobjectname)
If (wbemObjectSet is Nothing) Or (isNull(wbemObjectSet)) Then
logMessage = "Unable to retrieve System Summary information"
MOMDebugLog 1, logMessage
Else
logMessage = "object retrieved successfully "
MOMDebugLog 1, logMessage
End if

On Error Resume Next
Err.Clear
Dim wbemObject
Dim val
For Each wbemObject in wbemObjectSet

If Err.Number &lt;&gt; 0 Then
logMessage = "Invalid Object found"
MOMDebugLog 1, logMessage
ElseIf not wbemObject is nothing Then
val = GetAttribute(wbemObject, wmiattributename)
if(DCMVersion &gt; 7) then
If val = "Lower Non-Critical" OR val = "Upper Non-Critical" AND errorFlag &lt;&gt; "Error" Then
errorFlag = "Warning"
ElseIf val = "Fatal" OR val = "Lower Critical" OR val = "Upper Critical" Then
errorFlag = "Error"
End If
ElseIf (DCMVersion = 7) Then
If val = "2" OR val = "3" OR val = "5" OR val = "6" OR val = "7" OR val = "8" OR val = "9" AND errorFlag &lt;&gt; "Error" Then
errorFlag = "Warning"
ElseIf val = "1" OR val = "4" OR val = "12" Then
errorFlag = "Error"
End If
Else
logMessage = "Err: Dell OMCI / Dell Command | Monitor Not Installed or its older version: Not Supported Client"
MOMDebugLog 1, logMessage
End If

logMessage = "::GetScalarAttribute = " &amp; val
MOMDebugLog 1, logMessage
End If
Next
GetScalarAttribute = errorFlag
End Function


Public Function GetHealthStatus(ByRef component)
logMessage ="GetHealthStatus fetched"
MOMDebugLog 1, logMessage
GetHealthStatus = GetScalarAttribute(component.WMIServices, component.WMIObjectName,component.WMIObjectAttribute)
End Function


End Class

' OMCI Factory
Class OMCIFactory
private m_omciObj
Private m_omciVersion

public Property Get OMCIVersion
OMCIVersion = m_omciVersion
End Property
Public Property Let OMCIVersion(value)
m_omciVersion = SanitizeValue(value)
End Property
Public Function ReadReg(RegPath)
On Error Resume Next

Dim objRegistry, Key
Set objRegistry = CreateObject("Wscript.shell")
Key = objRegistry.RegRead(RegPath)

ReadReg = Key
End Function

Public Function GetOMCI

On Error Resume Next
logMessage = "Determining OMCI / Dell Command | Monitor version ..."
MOMDebugLog 1, logMessage
Dim objItem, OMCIVersion, wbemServices, wbemObjectSet

Set wbemServices = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\dellomci")



If IsEmpty(wbemServices) Then 'If root-dellomci not present go for registery to fetch OMCI / Dell Command | Monitor version
logmessage = "Unable to open WMI Namespace root-dellomci."
MOMDebugLog 1, logMessage
logmessage = "Reading Registery for OMCI / Dell Command | Monitor version"
MOMDebugLog 1, logMessage

m_omciVersion = ReadReg("HKLM\Software\Dell Computer Corporation\OpenManage\Applications\Client\Version")
'Error checking

Else

Set wbemObjectSet = wbemServices.ExecQuery("Select * from Dell_SystemManagementSoftware")
If (wbemObjectSet is Nothing) Or (isNull(wbemObjectSet)) Then

logmessage = "Unable to retrieve System Summary information"
MOMDebugLog 1, logMessage
Else

For Each objItem in wbemObjectSet
'Error checking
If Err.Number &lt;&gt; 0 Then
logmessage = "Number:" &amp; Err.Number &amp; "Description:" &amp; Err.Description
MOMDebugLog 1, logMessage
End If
'Object Retrieval
If not objItem is nothing Then
m_omciVersion = objItem.Version
Else
logmessage = "Object is Nothing"
MOMDebugLog 1, logMessage

End If
Next
End If
End If
Set wbemServices = Nothing
if IsNull(m_omciObj) or (m_omciObj Is Nothing) Then
Dim b, versionNum
b = split(m_omciVersion, ".")
versionNum = b(0)
If (versionNum &gt; 7) Then
logMessage = "OMCI / Dell Command | Monitor Version is above 7: " &amp; m_omciVersion
MOMDebugLog 1, logMessage
Set m_omciObj = (New OMCI8x)(m_omciVersion)
ElseIf (versionNum = 7) Then
logMessage = "OMCI / Dell Command | Monitor Version is unmanaged: " &amp; m_omciVersion
MOMDebugLog 1, logMessage
Set m_omciObj = (New OMCI7x)(m_omciVersion)
Else
logMessage = "Err: Dell OMCI / Dell Command | Monitor Not Installed or its older version: Not Supported Client"
MOMDebugLog 1, logMessage
End If
Else
logMessage = "Reusing OMCI / Dell Command | Monitor object"
MOMDebugLog 1, logMessage
End If
Set GetOMCI = m_omciObj
End Function

Private Sub Class_Initialize
Set m_omciObj = Nothing
End Sub

End Class

' OMCI 8.x Creator
Class OMCI8x
private healthComputerObj, wbemServices, cmiV2WbemServices
private m_version
Public Default Function Init(version)
m_version = version
Set Init = Me
End Function

public Function getHealthComputer()

Dim strComputer : strComputer = "."
Err.Clear
Set wbemServices = GetObject("winmgmts:" &amp; "{impersonationLevel=impersonate}!\\" &amp; strComputer &amp; "\root\DCIM\SYSMAN")
LogErrorNumber("DCIM\SYSMAN")
logMessage = "getHealthComputer"
MOMDebugLog 1, logMessage
Dim pairs(1), i
i = -1
i = i + 1: Set pairs(i) = CreateAttrNamePair(wbemServices, "DCIM_NumericSensor where ElementName like '%Temperature%'", "CurrentState")

If IsEmpty(wbemServices) Then
logMessage = "Unable to open WMI Namespace root-DCIM-SYSMAN. Check to see if the WMI service is enabled and running, and ensure this WMI namespace exists."
MOMDebugLog 1, logMessage
Else
Set healthComputerObj = (new HealthComputer)(pairs, m_version)
Set getHealthComputer = healthComputerObj
End If
End Function
End Class




On Error Resume Next
Dim oBag, TemperatureStatus, oAPI
Dim model
Dim RequiredOMCIVersion, description, health
RequiredOMCIVersion = "8.0"

'description = "Please install OMCI / Dell Command | Monitor 8.0 or above from support.dell.com"
description = "Please install/re-install a supported version of OMCI / Dell Command | Monitor (v8.0 or later)"
Dim omciObj, iomciFactory, Componenthealth
Set iomciFactory = New OMCIFactory
if not iomciFactory is Nothing then
logMessage = "iomci factory Object Created"
MOMDebugLog 1, logMessage
Set omciObj = iomciFactory.GetOMCI()
if not omciObj is Nothing then
logMessage = " Object Created"
MOMDebugLog 1, logMessage
set health = omciObj.getHealthComputer()
TemperatureStatus = health.TemperatureSensor
logMessage = "&lt;&gt;Temperature Health :" &amp; TemperatureStatus
MOMDebugLog 1, logMessage
else
logMessage = " Object not created"
MOMDebugLog 1, logMessage
End if
else
logMessage = "iomci Object not created"
MOMDebugLog 1, logMessage

End if
On Error Goto 0

Set oAPI = CreateMOMScriptAPI()
set oBag = CreatePropertyBag (oAPI)
oInstAddValue oBag, "Status", TemperatureStatus
ReturnData oAPI, oBag

logMessage = "INFO : Script - Dell Client Temperature Monitoring : End()"
MOMDebugLog 1, logMessage
logMessage = "------------------------------------------------------"
MOMDebugLog 1, logMessage

' Close file used for logs
If logLevel &lt;&gt; 0 Then
objLogTextFile.Close
Set objLogTextFile = Nothing
Set objLogFSO = Nothing
End If


'********** SCOM Functions
Function CreateMOMScriptAPI
If DebugScript = False Then
Set CreateMOMScriptAPI = CreateObject("MOM.ScriptAPI")
Else
Set CreateMOMScriptAPI = New RegExp
End If
logMessage = "INFO: New MOM.ScriptAPI"
MOMDebugLog 1, logMessage
End Function

Function CreatePropertyBag(ByRef oAPI)
If DebugScript = False Then
set CreatePropertyBag = oAPI.CreatePropertyBag()
Else
Set CreatePropertyBag = New RegExp
End If
logMessage = "INFO: New Monitor Data"
MOMDebugLog 1, logMessage
End Function

Sub ReturnData (ByRef oAPI, ByRef oBag)
If DebugScript = False Then
Call oAPI.Return(oBag)
End If
logMessage = "INFO: Returning Monitor Data"
MOMDebugLog 1, logMessage
End Sub

Sub oInstAddValue(ByRef oBag, prop, val)
If DebugScript = False Then
Call oBag.AddValue(prop, val)
End If
logMessage = "INFO: Set " &amp; prop &amp; " = " &amp; val
MOMDebugLog 1, logMessage
End Sub

Function CreateClassInstance(ByRef oDiscoveryData, ByRef classid)
If DebugScript = False Then
set CreateClassInstance = oDiscoveryData.CreateClassInstance(classid)
Else
Set CreateClassInstance = New RegExp
End If
logMessage = "INFO: New Class Instance" &amp; classid
MOMDebugLog 1, logMessage
End Function

Sub AddInstanceToDiscoveryData(ByRef oDiscoveryData, ByRef oInst)
If DebugScript = False Then
Call oDiscoveryData.AddInstance(oInst)
End If
logMessage = "INFO: AddInstance to Discovery Data"
MOMDebugLog 1, logMessage
End Sub


Function DebugOut(message)
If DebugScript Then WScript.Echo message

End Function

</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>