iResult = GetWMIObjectCollection(IBMSD_NAMESPACE, COMPONENTHEALTH_IBMSD_CALSS, oCollection)
If (iResult > 0) Then
'There is at least one instance of IBMPSG_ComponentHealth showed under the root/ibmsd namespace
For Each oObjectItem in oCollection
If IsStorageDevice(oObjectItem) Then
oDeviceID = STORAGEID
Else
If IsNull(oObjectItem.AlertingManagedElement) Then
oDeviceID = GetDeviceID(oObjectItem.EventID)
Else
oDeviceID = GetDeviceID(oObjectItem.AlertingManagedElement)
End If
End If
if oDeviceID<>"" then
'Got the relative instance in collection
If oObjectItem.PerceivedSeverity >= 5 Then
'Error - Severity's value is 5+
Call LogDebugString(oDeviceID + " Error added into property bag", INFO_LEVEL)
If oDeviceID = STORAGEID Then
oStorageHealth = "Error"
oStorageHealthDes = oStorageHealthDes + oObjectItem.Description & vbCrLf
Else
Call oBag.AddValue(oDeviceID, "Error")
Call oBag.AddValue(oDeviceID + "--Description", oObjectItem.Description)
End If
iComponentHealth = 1
ElseIf oObjectItem.PerceivedSeverity >= 3 Then
'Warning - Severity's value is 3 or 4
Call LogDebugString(oDeviceID + " Warning added into property bag", INFO_LEVEL)
If oDeviceID = STORAGEID Then
If oStorageHealth <> "Error" Then
oStoragehealth = "Warning"
oStorageHealthDes = oStorageHealthDes + oObjectItem.Description & vbCrLf
End If
Else
Call oBag.AddValue(oDeviceID, "Warning")
Call oBag.AddValue(oDeviceID + "--Description", oObjectItem.Description)
End If
iComponentHealth = 1
ElseIf oObjectItem.PerceivedSeverity >= 1 Then
'Healthy - Severity's value is 1 or 2
' - no relative instances exist in the collection
'Dont need to set the health value for storage, just add the desciption
Call LogDebugString(oDeviceID + " Healthy added into property bag", INFO_LEVEL_DETAIL)
If oDeviceID = STORAGEID Then
oStorageHealthDes = oStorageHealthDes + oObjectItem.Description & vbCrLf
Else
Call oBag.AddValue(oDeviceID, "Healthy")
Call oBag.AddValue(oDeviceID + "--Description", oObjectItem.Description)
End If
iComponentHealth = 1
End If
End If
Next
'Add value for storage device
Call oBag.AddValue(STORAGEID, oStorageHealth)
Call oBag.AddValue(STORAGEID + "--Description", oStorageHealthDes)
If iComponentHealth < 0 Then
'Healthy - no relative instances exist in the collection, default value is Healthy
Call LogDebugString(" No instance in component health", WARNING_LEVEL)
iComponentHealth = 1
End If
Else
'No root/ibmsd namespace or instances of IBMPSG_ComponentHealth available
Call LogDebugString("Can not get Component Health instances", WARNING_LEVEL_DEV)
End If
End Function
'@\\KKR004\root\ibmsd:IBMPSG_PhysicalMemory.CreationClassName="IBMPSG_PhysicalMemory",Tag="Physical Memory 2f2801f4601f201f45"
'\\KKR004\root\ibmsd:IBMPSG_PowerSupply.CreationClassName="IBMPSG_PowerSupply",DeviceID="PS 1 Status:3f3201f201f450",SystemCreationClassName="IBMSD_ComputerSystem",SystemName="KKR004"
Function GetDeviceID(oEventID)
Dim iBeginPos, iEndPos, sTemp, searchChar
searchChar = DEVICEID1
iBeginPos = 0
iEndPos = 0
GetDeviceID = ""
iBeginPos = Instr(oEventID, searchChar)
If iBeginPos <> 0 Then
iBeginPos = iBeginPos + Len(searchChar)
searchChar = """"
iEndPos = Instr(iBeginPos, oEventID, searchChar)
If iEndPos <>0 Then
sTemp = Mid(oEventID, iBeginPos, iEndPos-iBeginPos)
If iBeginPos <> 0 Then
iBeginPos = iBeginPos + Len(searchChar)
searchChar = """"
iEndPos = Instr(iBeginPos, oEventID, searchChar)
If iEndPos <>0 Then
sTemp = Mid(oEventID, iBeginPos, iEndPos-iBeginPos)
sTemp = Replace(sTemp, "/", " ")
sTemp = Replace(sTemp, ".", " ")
GetDeviceID = LTrim(RTrim(sTemp))
End If
Else
searchChar = DEVICEID3
iBeginPos = Instr(oEventID, searchChar)
If iBeginPos <> 0 Then
iBeginPos = iBeginPos + Len(searchChar)
searchChar = """"
iEndPos = Instr(iBeginPos, oEventID, searchChar)
If iEndPos <>0 Then
sTemp = Mid(oEventID, iBeginPos, iEndPos-iBeginPos)
sTemp = Replace(sTemp, "/", " ")
sTemp = Replace(sTemp, ".", " ")
GetDeviceID = LTrim(RTrim(sTemp))
End If
Else
searchChar = DEVICEID4
iBeginPos = Instr(oEventID, searchChar)
If iBeginPos <> 0 Then
iBeginPos = iBeginPos + Len(searchChar)
searchChar = """"
iEndPos = Instr(iBeginPos, oEventID, searchChar)
If iEndPos <>0 Then
sTemp = Mid(oEventID, iBeginPos, iEndPos-iBeginPos)
sTemp = Replace(sTemp, "/", " ")
sTemp = Replace(sTemp, ".", " ")
GetDeviceID = LTrim(RTrim(sTemp))
End If
End If
End If
End If
End If
End Function
Function IsStorageDevice(oObjectItem)
'find the key words for the storage device
'We have CIM_DiskDrive, IBMPSG_LogicalDisk, IBMPSG_DiskDrive now
IsStorageDevice = 0
Dim oIndicationString
oIndicationString = Null
oIndicationString = oObjectItem.AlertingManagedElement
If IsNull(oIndicationString) Then
oIndicationString = oObjectItem.EventID
End If
IsStorageDevice = IsStorageDeviceEx(oIndicationString)
End Function
Function IsStorageDeviceEx(oIndicationString)
'find the key words for the storage device
'We have CIM_DiskDrive, IBMPSG_LogicalDisk, IBMPSG_DiskDrive, ADPT_, IBMPSG_Storage, IBMPSG_ServeRAID now
IsStorageDeviceEx = 0
Dim iPos
iPos = Instr(oIndicationString, "CIM_DiskDrive")
If iPos <> 0 Then
IsStorageDeviceEx = 1
Exit Function
Else
iPos = Instr(oIndicationString, "IBMPSG_LogicalDisk")
End If
If iPos <> 0 Then
IsStorageDeviceEx = 1
Exit Function
Else
iPos = Instr(oIndicationString, "IBMPSG_DiskDrive")
End If
If iPos <> 0 Then
IsStorageDeviceEx = 1
Exit Function
Else
iPos = Instr(oIndicationString, "ADPT_")
End If
If iPos <> 0 Then
IsStorageDeviceEx = 1
Exit Function
Else
iPos = Instr(oIndicationString, "IBMPSG_Storage")
End If
If iPos <> 0 Then
IsStorageDeviceEx = 1
Exit Function
Else
iPos = Instr(oIndicationString, "IBMPSG_ServeRAID")
End If
If iPos <> 0 Then
IsStorageDeviceEx = 1
Exit Function
End If