Call LogDebugString("IP Address = " & ipaddress, INFO_LEVEL_FUNCTION)
Call LogDebugString("init = " & init, INFO_LEVEL_DETAIL)
If (init = 0) then
Dim ret
ret = bladeChassis.GetComponentSupportedAndInstalled()
If (ret <> 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 AddFanMuxModuleHealthBag(bladeChassis, oBag)
Call AddRearLEDModuleHealthBag(bladeChassis,oBag)
'Call AddStorageModuleHealthBag(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 Flex System chassis health state on " + ipaddress, WARNING_LEVEL_DEV)
Else
Call LogDebugString("Add Chassis module health", INFO_LEVEL_DETAIL)
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 " & bladesCount, INFO_LEVEL_DETAIL)
bladesInstalled = bladeChassis.GetBladeModulesInstalled()
Dim bayNumber
bayNumber = 0
For Each item in bladesInstalled
bayNumber = bayNumber + 1
If bayNumber > bladesCount Then
Exit For
Else
If item = true Then
Dim blade , blade1
Set blade = bladeChassis.GetBladeModule(bayNum)
If IsNull(blade) or blade is nothing or blade.State = "" or blade.Name = "" Then
Call LogDebugString("Cannot get Blade Bay " & bayNumber & " health state on " + ipaddress, WARNING_LEVEL_DEV)
Else
Call LogDebugString("Add Blade module health: " & bayNumber & ", " & 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" or blade.State = "Initialization Failure" 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
Set blade1 = bladeChassis.GetBladeModuleOfCara(bayNum)
If IsNull(blade1) or blade1 is nothing or blade1.State = "" or blade1.Name = "" Then
WScript.Echo("This is not CaraCara!")
Else
WScript.Echo("This is CaraCara , and Add the other server health!")
If blade1.State = "Good" Then
oBag.AddValue blade1.Name, "Healthy"
oBag.AddValue blade1.Name + " -- Description", blade1.State
ElseIf blade1.State = "Bad" or blade1.State = "Discovering" or blade1.State = "Communications Error" or blade1.State = "Initialization Failure" Then
oBag.AddValue blade1.Name, "Error"
oBag.AddValue blade1.Name + " -- Description", blade1.State
Else
oBag.AddValue blade1.Name, "Warning"
oBag.AddValue blade1.Name + " -- Description", blade1.State
End If
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 > 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 " & bayNumber & " health state on " + ipaddress, WARNING_LEVEL_DEV)
Else
Call LogDebugString("Add MM module health: " & bayNumber & ", " & 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 > 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 " & bayNumber & " health state on " + ipaddress, WARNING_LEVEL_DEV)
Else
Call LogDebugString("Add Power module health: " & bayNumber & ", " & 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 > 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 " & bayNumber & " health state on " & ipaddress, WARNING_LEVEL_DEV)
Else
Call LogDebugString("Add Cooling module health: " & bayNumber & ", " & 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 > 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 " & bayNumber &" health state on " + ipaddress, WARNING_LEVEL_DEV)
Else
Call LogDebugString("Add I/O module health: " & bayNumber & ", " & 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 " & index & " health state on " + ipaddress, WARNING_LEVEL_DEV)
Else
Call LogDebugString("Add Storage module health: " & bayNumber & ", " & 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 AddFanMuxModuleHealthBag(bladeChassis, ByRef oBag)
Dim FanMuxCount
Dim FanMuxInstalled
FanMuxCount = bladeChassis.GetFanMuxModuleCount()
FanMuxInstalled = bladeChassis.GetFanMuxModulesInstalled()
Dim bayNumber
bayNumber = 0
For Each item in FanMuxInstalled
bayNumber = bayNumber + 1
If bayNumber > FanMuxCount Then
Exit For
Else
If item = true Then
Dim FanMux
Set FanMux = bladeChassis.GetModuleHealthState("FanMux", bayNumber)
If IsNull(FanMux) or FanMux is nothing or FanMux.State = "" or FanMux.Name = "" Then
Call LogDebugString("Cannot get FanMux Bay " & bayNumber & " health state on " & ipaddress, WARNING_LEVEL_DEV)
Else
Call LogDebugString("Add FanMux module health: " & bayNumber & ", " & FanMux.State, INFO_LEVEL_DETAIL)
If FanMux.State = "Functional" Then
oBag.AddValue FanMux.Name, "Healthy"
oBag.AddValue FanMux.Name + " -- Description", FanMux.State
Else
oBag.AddValue FanMux.Name, "Warning"
oBag.AddValue FanMux.Name + " -- Description", FanMux.State
End If
End If
End If
End If
Next
End Function
Function AddRearLEDModuleHealthBag(bladeChassis, ByRef oBag)
Dim RearLEDCount
Dim RearLEDInstalled
RearLEDCount = bladeChassis.GetRearLEDModuleCount()
RearLEDInstalled = bladeChassis.GetRearLEDModulesInstalled()
Dim bayNumber
bayNumber = 0
For Each item in RearLEDInstalled
bayNumber = bayNumber + 1
If bayNumber > RearLEDCount Then
Exit For
Else
If item = true Then
Dim RearLED
Set RearLED = bladeChassis.GetModuleHealthState("RearLED", bayNumber)
If IsNull(RearLED) or RearLED is nothing or RearLED.State = "" or RearLED.Name = "" Then
Call LogDebugString("Cannot get RearLED Bay " & bayNumber & " health state on " & ipaddress, WARNING_LEVEL_DEV)
Else
Call LogDebugString("Add LED module health: " & bayNumber & ", " & RearLED.State, INFO_LEVEL_DETAIL)
If RearLED.State = "Communicating" Then
oBag.AddValue RearLED.Name, "Healthy"
oBag.AddValue RearLED.Name + " -- Description", RearLED.State
Else
oBag.AddValue RearLED.Name, "Warning"
oBag.AddValue RearLED.Name + " -- Description", RearLED.State
End If
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 <> 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") & iGroup
sPreliminaryOutString = Chr(CByte("&H" & Mid(iGroup, 1, 2))) & Chr(CByte("&H" & Mid(iGroup, 3, 2))) & Chr(CByte("&H" & Mid(iGroup, 5, 2)))
sOutputString = sOutputString & 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 <> 0) Then
Call LogDebugString("Error to create object", ERROR_LEVEL)
WScript.Quit
End If
End Function
Sub GetDebugLevel()
'Const HKEY_LOCAL_MACHINE = &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<>0) Then
Regdebug = -1
End If
End If
End Sub
Sub LogDebugString(debugString, debugLevel)
If (Int(Regdebug) >= Int(debugLevel)) Then
Call oAPI.LogScriptEvent("IBMFlexChassisComponentHealthCheck.vbs", 231, DebugLevelToLogLevel(debugLevel), debugString)
End If
End Sub
Function DebugLevelToLogLevel(debugLevel)
DebugLevelToLogLevel = 4
If debugLevel <= 1 then
DebugLevelToLogLevel = 1
ElseIF debugLevel <= 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>