Lenovo HwComponents HealthProvider Probe

IBM.HwComponents.HealthProvider.Probe (ProbeActionModuleType)

Element properties:

TypeProbeActionModuleType
IsolationAny
AccessibilityPublic
RunAsDefault
OutputTypeSystem.PropertyBagData

Member Modules:

ID Module Type TypeId RunAs 
PassThrough ProbeAction System.PassThroughProbe Default
Script ProbeAction Microsoft.Windows.ScriptPropertyBagProbe Default

Source Code:

<ProbeActionModuleType ID="IBM.HwComponents.HealthProvider.Probe" Accessibility="Public" Batching="false" PassThrough="false">
<Configuration>
<xsd:element name="TimeoutSeconds" type="xsd:integer"/>
<xsd:element name="ModuleType" type="xsd:string"/>
<xsd:element name="IPAddress" type="xsd:string"/>
<xsd:element name="CommunityString" type="xsd:string"/>
</Configuration>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<ProbeAction ID="PassThrough" TypeID="System!System.PassThroughProbe"/>
<ProbeAction ID="Script" TypeID="Windows!Microsoft.Windows.ScriptPropertyBagProbe">
<ScriptName>IBMBladeCenterComponentsHealthCheck.vbs</ScriptName>
<Arguments>"$Config/ModuleType$" "$Config/IPAddress$" "$Config/CommunityString$"</Arguments>
<ScriptBody><Script>
Dim oArgs
Set oArgs = WScript.Arguments
WScript.Echo oArgs.Count
if oArgs.Count &lt; 3 Then
'Wscript.Quit -1
End If

'Debug Log Definition
Const HKEY_LOCAL_MACHINE = &amp;H80000002
Const DEBUG_INFO_KEY = "SOFTWARE\Lenovo\Lenovo SCOM MP\Debug"
Const DEBUG_LEVEL_NAME = "Level"
Const ERROR_LEVEL = 1
Const WARNING_LEVEL = 2
Const WARNING_LEVEL_DEV = 3
Const INFO_LEVEL = 4
Const INFO_LEVEL_FUNCTION = 5
Const INFO_LEVEL_DETAIL = 6

Dim moduleType, ipaddress, CommunityString
moduleType = oArgs.Item(0)
ipaddress = oArgs.Item(1)
CommunityString = oArgs.Item(2)
'CommunityString = Chr2Unicode(fDecode(CommunityString))

Dim Regdebug, oAPI, oBag, swFlag, bladeChassis
SetLocale("en-us")
Call GetComponentHealthStatus()

Sub GetComponentHealthStatus()

Regdebug = -1
Call GetDebugLevel()
Set oAPI = SCOMCreateObject("MOM.ScriptAPI")
Set oBag = oAPI.CreatePropertyBag()
Set bladeChassis = WScript.CreateObject("Lenovo.SystemsManagement.MMClassLibrary.BladeChassis")
Call AddComponentHealthBag(ipaddress, bladeChassis, oBag)
Call LogDebugString("Ending GetComponentHealthStatus", INFO_LEVEL_DETAIL)
Call oAPI.Return(oBag)

End Sub

Function AddComponentHealthBag(ipaddress, bladeChassis, ByRef oBag)
Dim init
init = -1
init = bladeChassis.InitializeSocketConnection(ipaddress, CommunityString, 0,"V1")

Call LogDebugString("IP Address = " &amp; ipaddress, INFO_LEVEL_FUNCTION)
Call LogDebugString("init = " &amp; init, INFO_LEVEL_DETAIL)

If (init = 0) then
Dim ret
ret = bladeChassis.GetComponentSupportedAndInstalled()
If (ret &lt;&gt; 0) then
Call LogDebugString("Error - Could not get components count and which has been installed on " + ipaddress, WARNING_LEVEL_DEV)
Else
If moduleType = "BladeCenter" Then
Call AddChassisModuleHealthBag(bladeChassis.GetChassisHealthState(), oBag)
ElseIf moduleType = "Module" Then
Call AddBladeModuleHealthBag(bladeChassis, oBag)
Call AddManagementModuleHealthBag(bladeChassis, oBag)
Call AddPowerModuleHealthBag(bladeChassis, oBag)
Call AddCoolingModuleHealthBag(bladeChassis, oBag)
Call AddIOModuleHealthBag(bladeChassis, oBag)
Call AddStorageModuleHealthBag(bladeChassis, oBag)
Call AddMediaTrayModuleHealthBag(bladeChassis, oBag)
End If
End If
bladeChassis.CloseSocketConnection()
Else
Call LogDebugString("Warning - Could not connect to management module by SNMP, please check the target IP has been set in Web Console of management module.", WARNING_LEVEL)
End If
End Function

Function AddChassisModuleHealthBag(chassis, ByRef oBag)
If (IsNull(chassis) or chassis is nothing or chassis.State = "") then
Call LogDebugString("Cannot get BladeCenter health state on " + ipaddress, WARNING_LEVEL_DEV)
Else
If chassis.State = "Critial" then
oBag.AddValue ipaddress, "Error"
oBag.AddValue ipaddress + " -- Description", chassis.State
ElseIf chassis.State = "Normal" then
oBag.AddValue ipaddress, "Healthy"
oBag.AddValue ipaddress + " -- Description", chassis.State
Else
oBag.AddValue ipaddress, "Warning"
oBag.AddValue ipaddress + " -- Description", chassis.State
End If
End If
End Function

Function AddBladeModuleHealthBag(bladeChassis, ByRef oBag)
Dim bladesCount
Dim bladesInstalled
bladesCount = bladeChassis.GetBladeModuleCount()
Call LogDebugString("Add Blade module health: bladesCount " &amp; bladesCount, INFO_LEVEL_DETAIL)
bladesInstalled = bladeChassis.GetBladeModulesInstalled()
Dim bayNumber
bayNumber = 0
For Each item in bladesInstalled
bayNumber = bayNumber + 1
If bayNumber &gt; bladesCount Then
Exit For
Else
If item = true Then
Dim blade
Set blade = bladeChassis.GetModuleHealthState("Blade", bayNumber)
If IsNull(blade) or blade is nothing or blade.State = "" or blade.Name = "" Then
Call LogDebugString("Cannot get Blade Bay " &amp; bayNumber &amp; " health state on " + ipaddress, WARNING_LEVEL_DEV)
Else
Call LogDebugString("Add Blade module health: " &amp; bayNumber &amp; ", " &amp; blade.State, INFO_LEVEL_DETAIL)
If blade.State = "Good" Then
oBag.AddValue blade.Name, "Healthy"
oBag.AddValue blade.Name + " -- Description", blade.State
ElseIf blade.State = "Bad" or blade.State = "Discovering" or blade.State = "Communications Error" Then
oBag.AddValue blade.Name, "Error"
oBag.AddValue blade.Name + " -- Description", blade.State
Else
oBag.AddValue blade.Name, "Warning"
oBag.AddValue blade.Name + " -- Description", blade.State
End If
End If
End If
End If
Next
End Function

Function AddManagementModuleHealthBag(bladeChassis, ByRef oBag)
Dim mmCount
Dim mmInstalled
mmCount = bladeChassis.GetManagementModuleCount()
mmInstalled = bladeChassis.GetManagementModulesInstalled()
Dim bayNumber
bayNumber = 0
For Each item in mmInstalled
bayNumber = bayNumber + 1
If bayNumber &gt; mmCount Then
Exit For
Else
If item = true Then
Dim mm
Set mm = bladeChassis.GetModuleHealthState("Management Module", bayNumber)
If IsNull(mm) or mm is nothing or mm.State = "" or mm.Name = "" Then
Call LogDebugString("Cannot get Management Module Bay " &amp; bayNumber &amp; " health state on " + ipaddress, WARNING_LEVEL_DEV)
Else
Call LogDebugString("Add MM module health: " &amp; bayNumber &amp; ", " &amp; mm.State, INFO_LEVEL_DETAIL)
If mm.State = "Good" Then
oBag.AddValue mm.Name, "Healthy"
oBag.AddValue mm.Name + " -- Description", mm.State
ElseIf mm.State = "Bad" Then
oBag.AddValue mm.Name, "Error"
oBag.AddValue mm.Name + " -- Description", mm.State
Else
oBag.AddValue mm.Name, "Warning"
oBag.AddValue mm.Name + " -- Description", mm.State
End If
End If
End If
End If
Next
End Function

Function AddPowerModuleHealthBag(bladeChassis, ByRef oBag)
Dim powerCount
Dim powerInstalled
powerCount = bladeChassis.GetPowerModuleCount()
powerInstalled = bladeChassis.GetPowerModulesInstalled()
Dim bayNumber
bayNumber = 0
For Each item in powerInstalled
bayNumber = bayNumber + 1
If bayNumber &gt; powerCount Then
Exit For
Else
If item = true Then
Dim power
Set power = bladeChassis.GetModuleHealthState("Power", bayNumber)
If IsNull(power) or power is nothing or power.State = "" or power.Name = "" Then
Call LogDebugString("Cannot get Power Bay " &amp; bayNumber &amp; " health state on " + ipaddress, WARNING_LEVEL_DEV)
Else
Call LogDebugString("Add Power module health: " &amp; bayNumber &amp; ", " &amp; power.State, INFO_LEVEL_DETAIL)
If power.State = "Good" Then
oBag.AddValue power.Name, "Healthy"
oBag.AddValue power.Name + " -- Description", power.State
ElseIf power.State = "Critical" or power.State = "Not available" Then
oBag.AddValue power.Name, "Error"
oBag.AddValue power.Name + " -- Description", power.State
Else
oBag.AddValue power.Name, "Warning"
oBag.AddValue power.Name + " -- Description", power.State
End If
End If
End If
End If
Next
End Function

Function AddCoolingModuleHealthBag(bladeChassis, ByRef oBag)
Dim coolingCount
Dim coolingInstalled
coolingCount = bladeChassis.GetBlowerModuleCount()
coolingInstalled = bladeChassis.GetBlowerModulesInstalled()
Dim bayNumber
bayNumber = 0
For Each item in coolingInstalled
bayNumber = bayNumber + 1
If bayNumber &gt; coolingCount Then
Exit For
Else
If item = true Then
Dim cooling
Set cooling = bladeChassis.GetModuleHealthState("Cooling", bayNumber)
If IsNull(cooling) or cooling is nothing or cooling.State = "" or cooling.Name = "" Then
Call LogDebugString("Cannot get Cooling Bay " &amp; bayNumber &amp; " health state on " &amp; ipaddress, WARNING_LEVEL_DEV)
Else
Call LogDebugString("Add Cooling module health: " &amp; bayNumber &amp; ", " &amp; cooling.State, INFO_LEVEL_DETAIL)
If cooling.State = "Good" Then
oBag.AddValue cooling.Name, "Healthy"
oBag.AddValue cooling.Name + " -- Description", cooling.State
ElseIf cooling.State = "Bad" Then
oBag.AddValue cooling.Name, "Error"
oBag.AddValue cooling.Name + " -- Description", cooling.State
Else
oBag.AddValue cooling.Name, "Warning"
oBag.AddValue cooling.Name + " -- Description", cooling.State
End If
End If
End If
End If
Next
End Function

Function AddIOModuleHealthBag(bladeChassis, ByRef oBag)
Dim ioCount
Dim ioInstalled
ioCount = bladeChassis.GetIOModuleCount()
ioInstalled = bladeChassis.GetIOModulesInstalled()
Dim bayNumber
bayNumber = 0
For Each item in ioInstalled
bayNumber = bayNumber + 1
If bayNumber &gt; ioCount Then
Exit For
Else
If item = true Then
Dim io
Set io = bladeChassis.GetModuleHealthState("Switch", bayNumber)
If IsNull(io) or io is nothing or io.State = "" or io.Name = "" Then
Call LogDebugString("Cannot get I/O Bay " &amp; bayNumber &amp;" health state on " + ipaddress, WARNING_LEVEL_DEV)
Else
Call LogDebugString("Add I/O module health: " &amp; bayNumber &amp; ", " &amp; io.State, INFO_LEVEL_DETAIL)
If io.State = "Good" Then
oBag.AddValue io.Name, "Healthy"
oBag.AddValue io.Name + " -- Description", io.State
ElseIf io.State = "Bad" Then
oBag.AddValue io.Name, "Error"
oBag.AddValue io.Name + " -- Description", io.State
Else
oBag.AddValue io.Name, "Warning"
oBag.AddValue io.Name + " -- Description", io.State
End If
End If
End If
End If
Next
End Function

Function AddStorageModuleHealthBag(bladeChassis, ByRef oBag)
For index = 1 to 2
Dim storage
Set storage = bladeChassis.GetModuleHealthState("Storage", index)
If IsNull(storage) or storage is nothing or storage.State = "" or storage.Name = "" Then
Call LogDebugString("Cannot get Storage Bay " &amp; index &amp; " health state on " + ipaddress, WARNING_LEVEL_DEV)
Else
Call LogDebugString("Add Storage module health: " &amp; bayNumber &amp; ", " &amp; storage.State, INFO_LEVEL_DETAIL)
If storage.State = "Good" Then
oBag.AddValue storage.Name, "Healthy"
oBag.AddValue storage.Name + " -- Description", storage.State
ElseIf storage.State = "Critical" or storage.State = "Not available" Then
oBag.AddValue storage.Name, "Error"
oBag.AddValue storage.Name + " -- Description", storage.State
Else
oBag.AddValue storage.Name, "Warning"
oBag.AddValue storage.Name + " -- Description", storage.State
End If
End If
Next
End Function

Function AddMediaTrayModuleHealthBag(bladeChassis, ByRef oBag)
Dim mediaCount
Dim mediaInstalled
mediaCount = bladeChassis.GetMediaModuleCount()
mediaInstalled = bladeChassis.GetMediaModulesInstalled()
Dim bayNumber
bayNumber = 0
For Each item in mediaInstalled
bayNumber = bayNumber + 1
If bayNumber &gt; mediaCount Then
Exit For
Else
'Dim media
'Set media = bladeChassis.GetModuleHealthState("Media Tray", bayNumber)
'If IsNull(media) or media is nothing or media.State = "" or media.Name = "" Then
' Call LogDebugString("Cannot get Media Tray Bay " &amp; bayNumber &amp; " health state on " + ipaddress, WARNING_LEVEL)
'Else
' If media.State = "Good" Then
' oBag.AddValue media.Name, "Healthy"
' oBag.AddValue media.Name + " -- Description", media.State
' ElseIf media.State = "Critical" Then
' oBag.AddValue media.Name, "Error"
' oBag.AddValue media.Name + " -- Description", media.State
' Else
' oBag.AddValue media.Name, "Warning"
' oBag.AddValue media.Name + " -- Description", media.State
' End If
'End If
End If
Next
End Function

Function fDecode(sStringToDecode)
'This function will decode a Base64 encoded string and returns the decoded string.
Const CharList = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
Dim iDataLength, sOutputString, iGroupInitialCharacter
sStringToDecode = Replace(Replace(Replace(sStringToDecode, vbCrLf, ""), vbTab, ""), " ", "")
iDataLength = Len(sStringToDecode)
If iDataLength Mod 4 &lt;&gt; 0 Then
fDecode = "Bad string passed to fDecode() function."
Exit Function
End If
For iGroupInitialCharacter = 1 To iDataLength Step 4
Dim iDataByteCount, iCharacterCounter, sCharacter, iData, iGroup, sPreliminaryOutString
iDataByteCount = 3
iGroup = 0
For iCharacterCounter = 0 To 3
sCharacter = Mid(sStringToDecode, iGroupInitialCharacter + iCharacterCounter, 1)
If sCharacter = "=" Then
iDataByteCount = iDataByteCount - 1
iData = 0
Else
iData = InStr(1, CharList, sCharacter, 0) - 1
If iData = -1 Then
fDecode = "Bad string passed to fDecode() function."
Exit Function
End If
End If
iGroup = 64 * iGroup + iData
Next
iGroup = Hex(iGroup)
iGroup = String(6 - Len(iGroup), "0") &amp; iGroup
sPreliminaryOutString = Chr(CByte("&amp;H" &amp; Mid(iGroup, 1, 2))) &amp; Chr(CByte("&amp;H" &amp; Mid(iGroup, 3, 2))) &amp; Chr(CByte("&amp;H" &amp; Mid(iGroup, 5, 2)))
sOutputString = sOutputString &amp; Left(sPreliminaryOutString, iDataByteCount)
Next
fDecode = sOutputString
End Function

Function Chr2Unicode(byval str)
Dim st, t, i
For i = 1 To Len(str) Step 2
t = Mid(str, i, 1)
st = st + t
Next
Chr2Unicode = st
End Function

'-------------------------------------------------------------------------------
'start of SCOMCreateObject()
'-------------------------------------------------------------------------------
Function SCOMCreateObject(ByVal sProgramId)

Dim oError
Set oError = New Error

On Error Resume Next
Set SCOMCreateObject = WScript.CreateObject(sProgramId)
oError.Save
On Error Goto 0

If (oError.Number &lt;&gt; 0) Then
Call LogDebugString("Error to create object", ERROR_LEVEL)
WScript.Quit
End If

End Function
Sub GetDebugLevel()

'Const HKEY_LOCAL_MACHINE = &amp;H80000002
'Const DEBUG_INFO_KEY = "SOFTWARE\Lenovo\Lenovo SCOM MP\Debug"
' Const DEBUG_LEVEL_NAME = "Level"
Dim oReg,RC_Code
' Set oAPI = SCOMCreateObject("MOM.ScriptAPI")
Set oReg = GetObject("winmgmts://localhost/root/default:StdRegProv")

If (not(oReg is nothing)) Then
RC_Code = oReg.GetStringValue(HKEY_LOCAL_MACHINE, DEBUG_INFO_KEY, DEBUG_LEVEL_NAME, Regdebug)
If ( RC_Code&lt;&gt;0) Then
Regdebug = -1
End If
End If

End Sub
Sub LogDebugString(debugString, debugLevel)
If (Int(Regdebug) &gt;= Int(debugLevel)) Then
Call oAPI.LogScriptEvent("IBMBladeCenterComponentHealthCheck.vbs", 211, DebugLevelToLogLevel(debugLevel), debugString)
End If
End Sub
Function DebugLevelToLogLevel(debugLevel)
DebugLevelToLogLevel = 4
If debugLevel &lt;= 1 then
DebugLevelToLogLevel = 1
ElseIF debugLevel &lt;= 3 then
DebugLevelToLogLevel = 2
Else
DebugLevelToLogLevel = 4
End If
End Function
Class Error
Private lNumber
Private sSource
Private sDescription
Private sHelpContext
Private sHelpFile
Public Sub Save()
lNumber = Err.number
sSource = Err.Source
sDescription = Err.Description
sHelpContext = Err.HelpContext
sHelpFile = Err.helpfile
End Sub
Public Sub Raise()
Err.Raise lNumber, sSource, sDescription, sHelpFile, sHelpContext
End Sub
Public Sub Clear()
lNumber = 0
sSource = ""
sDescription = ""
sHelpContext = ""
sHelpFile = ""
End Sub
Public Default Property Get Number()
Number = lNumber
End Property
Public Property Get Source()
Source = sSource
End Property
Public Property Get Description()
Description = sDescription
End Property
Public Property Get HelpContext()
HelpContext = sHelpContext
End Property
Public Property Get HelpFile()
HelpFile = sHelpFile
End Property
End Class
</Script></ScriptBody>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
</ProbeAction>
</MemberModules>
<Composition>
<Node ID="Script">
<Node ID="PassThrough"/>
</Node>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.PropertyBagData</OutputType>
<TriggerOnly>true</TriggerOnly>
</ProbeActionModuleType>