Dim RC_Code, RegVer
Regdebug = -1
Set oAPI = SCOMCreateObject("MOM.ScriptAPI")
Set oBag = oAPI.CreatePropertyBag()
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
Call LogDebugString("Entering IBMBladeCenterProxyComputerMPVersion", INFO_LEVEL_FUNCTION)
RC_Code = oReg.GetStringValue(HKEY_LOCAL_MACHINE, RMS_KEY, RMS_VERSION, RegVer)
If IsNull(RegVer) Then
Call LogDebugString("Cannot get BladeCenter proxy computer MP version from registry", WARNING_LEVEL_DEV)
Else
Dim SCOMServer
Set SCOMServer = WScript.CreateObject("IBM.SystemsManagement.SCOMHelper.SCOMServer")
Dim MPVer : MPVer = SCOMServer.GetCurrentMPVersion()
If IsNull(MPVer) Then
Call LogDebugString("Cannot get BladeCenter proxy computer MP version from SCOMHelper", WARNING_LEVEL)
Else
Call AddCompareVersionsToBag(RegVer, MPVer, oBag)
End If
End If
Call oAPI.Return(oBag)
End Sub
Function AddCompareVersionsToBag(regVersion, scomVersion, ByRef oBag)
Dim compareResult : compareResult = CompareFileVersions(regVersion, scomVersion)
if compareResult <> 0 then
oBag.AddValue computerID, "Warning"
else
oBag.AddValue computerID, "Healthy"
end if
End Function
'Linlin added, Update the compare rule for patch.
'If the installed version is 2.4.4 and the MP version is 2.4.5, then it should be allowed. It indicates that the 2.4.5 is a MP patch without installation.
Function CompareFileVersions(regVersion, scomVersion)
CompareFileVersions = 0
dim VerBitsReg : VerBitsReg = split(regVersion, ".")
dim VerBitsSCOM : VerBitsSCOM = split(scomVersion, ".")
dim LastIndex
' LastIndex = ubound(VerBitsReg)
'if ubound(VerBitsSCOM) > LastIndex then
' LastIndex = ubound(VerBitsSCOM)
'end if
LastIndex =4
dim i
for i = 0 to LastIndex
dim BitReg, BitSCOM
if i <= ubound(VerBitsReg) then BitReg = VerBitsReg(i) else BitReg = ""
if i <= ubound(VerBitsSCOM) then BitSCOM = VerBitsSCOM(i) else BitSCOM = ""
if BitReg = "" then BitReg = "0"
if BitSCOM = "" then BitSCOM = "0"
if CInt(BitReg) > CInt(BitSCOM) and i< 2 then
CompareFileVersions = 1
elseif CInt(BitReg) < CInt(BitSCOM) and i< 2 then
CompareFileVersions = -1
elseif CInt(BitReg) > CInt(BitSCOM) and i>= 2 then
CompareFileVersions = -1
end if
if CompareFileVersions <> 0 then exit for
next
end Function
Function SCOMCreateObject(ByVal sProgramId)
Dim oError
Set oError = New Error
On Error Resume Next
Set SCOMCreateObject = 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 LogDebugString(debugString, debugLevel)
If (Int(Regdebug) >= Int(debugLevel)) Then
Call oAPI.LogScriptEvent("IBMBladeCenterProxyComputerMPVersion.vbs", 212, 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>