'--------------------------------------------
Dim insideMP
'insideMP = false 'only for test outside MP
insideMP = true 'script runs inside MP
'--------------------------------------------
' Search patterns, e.g. important functions:
' CheckNumberOfRegisteredComponents
' MonitorCommandAndCheckCommfile
'--------------------------------------------
Dim DebugMode
Dim DebugFile
Dim DebugConsole
DebugMode = false
DebugFile = false '*** set to "true" if logfile has been created
DebugConsole = false '*** enables console output for debug
'--------------------------------------------
' WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING:
'
' Adding DEBUG makes the script slower and produces more CPU load!
'
' WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING:
'--------------------------------------------
'
' BCDebug can be changed during runtime in the file given in constant:
' CONST LOGINIFILENAME = "SVISCOM-BL.Log.ini"
' by changing the value "DebugLevel" in the section given by constant:
' CONST INISEC_BLADECOMPMONITOR = "BladeComponentsMonitor"
'
' Note: If "DebugMode" = FALSE, BCDebug has no effect.
'
' Allow no / less / more DEBUG (bitwise, e.g.: 10 = 0x0A = 0x02 + 0x08)
Dim BCDebug
BCDebug = 0
'*** Timeout constants
CONST TIMEOUT_MA_RESPONSE_IN_S = 150 ' timeout waiting for response
CONST WAIT_5S = 5000 ' conversion factor 5s -> ms
CONST WAIT_20S = 20000 ' conversion factor 20s -> ms
CONST TIMEOUT_RESPONSEFILE_60_IN_S = 60 ' timeout for accepting monitoring data for a new command
CONST TIMEOUT_RESPONSEFILE_240_IN_S = 240 ' timeout for accepting monitoring data
CONST TIMEOUT_RESPONSEFILE_300_IN_S = 300 ' timeout for accepting monitoring data
CONST TIMEOUT_RESPONSEFILE_600_IN_S = 600 ' timeout for accepting old data after command has failed
' Use the "WMI" name!
CONST BLADESYSTEMMONITORSERVICE = "PRIMERGYBladeSystemMonitor"
' path to "SVISCOM-BL" in registry
CONST BL_REG_PATH = "HKLM\SOFTWARE\Fujitsu\ServerView Suite\SCOM Integration\SVISCOM-BL"
CONST BL64_REG_PATH = "HKLM\SOFTWARE\Wow6432Node\Fujitsu\ServerView Suite\SCOM Integration\SVISCOM-BL"
' path to "monitor service" in registry (= BL_REG_PATH & "\" & KEY_MONITOR_SERVICE)
' "MonitorService" entries
CONST REGKEY_MS_COMMFILEPATH = "CommFilePath"
CONST REGKEY_MS_CONFIGFILENAME = "ConfigFileName"
CONST REGKEY_MS_CONFIGFILEPATH = "ConfigFilePath"
CONST REGKEY_MS_LOGINIFILENAME = "LogIniFileName"
CONST REGKEY_MS_LOGFILESUBDIR = "LogFileSubDir"
'*** default names of log ini file path/name
CONST LOGINIFILENAME = "SVISCOM-BL.Log.ini"
CONST LOGINIFILEDIR = "C:\Windows\Temp\SVISCOM\BL"
Dim strLogIniFileDir, strLogIniFileName, strLogIniFileNameAbs
Dim strLogFileSubDir, strLogFileDir, strLogFileNameAbs
Dim BlRegPath ' 64 bit OS? Set "(Blade) Registry Path" correspondingly
'*** Args
Dim Component, BC_SerialNumber, ipAddress
Dim strBCCommunicationFile, strEventLogMsg
Dim simulationMode
Dim updateByControlCode
Dim BC_PropertyNameList, PropertyNameList, ComponentsList, BC_ComponentsGroupList
Dim oAPI, WshShell, oDiscoveryEmptyData, xmlDoc
Dim oPropertyBag, oInst
Dim MonitorAgentRunning, MonitorNotRunningSetComponentToWarning
Dim ProcessOverallStatus
Dim oldResponseCouldBeUsed
Dim PropertyArray, NoOfBladeSystem, BladeSystem_i
Dim NoOfMMBUnits, NoOfMMBUnitsMonitored
Dim NoOfPSUnits, NoOfPSUnitsMonitored
Dim NoOfFanUnits, NoOfFanUnitsMonitored
Dim NoOfTSUnits, NoOfTempSensorUnitsMonitored
Dim NoOfCUnits, NoOfConnectUnitsMonitored
Dim NoOfKVMUnits, NoOfKVMUnitsMonitored
Dim NoOfServerBlades, NoOfServerBladesMonitored
Dim NoOfStorageBlades, NoOfStorageBladesMonitored
Dim BladeSystem_No, SerialNumber
Dim MMBUnits, PowerSupplyUnits, FanUnits, TempSensorUnits, ConnectUnits
Dim BC_HealthState, MMB_HealthState, PSU_HealthState, FU_HealthState, TSU_HealthState, CU_HealthState, KVM_HealthState
Dim UnitNumber
Dim Enclosure_HealthState, Enclosure_OperationalState, Enclosure_MonitoringState
Dim Component_Name, Component_HealthState
Dim Compound_HealthState
Dim index, componentNameArray, componentStatusArray, monitoringStatusArray, maxComponent
Dim componentNames, componentStatus, monitoringStatus, componentHealth, failedComponents
Dim BladeSystemCommunicationFilePath
Dim BEnclosureChanged
Dim oArgs, iniVal, SaveBCDebug, nStatus
Dim controlReturn, checkCount, fileUpdated
Dim EnvVar, TEMP, SYSTEMDRIVE, SYSTEMROOT, WINDIR, PROGRAMFILES64
Dim strWhat
PROGRAMFILES64 = ""
PROGRAMFILES64 = EnvVar.Item("ProgramFiles(x86)")
If Len(PROGRAMFILES64) > 0 Then
BlRegPath = BL64_REG_PATH
Else
BlRegPath = BL_REG_PATH
End If
TEMP = ""
If insideMP = TRUE Then
'*** this value is different in interactive mode!
TEMP = EnvVar.Item("TEMP")
End If
If Len(TEMP) = 0 Then
'try this as default
If Len(WINDIR) > 0 Then
TEMP = WINDIR & "\" & KEY_TEMP
Else
If Len(SYSTEMROOT) > 0 Then
TEMP = SYSTEMROOT & "\" & KEY_TEMP
Else
TEMP = SYSTEMDRIVE & "\" & KEY_WINDOWS & "\" & KEY_TEMP
End If
End If
End If
'*** assemble LOG files and LOG INI file dir path
strLogFileSubDir = GetMonSvrRegistryValue(REGKEY_MS_LOGFILESUBDIR)
If Len(strLogFileSubDir) = 0 Then
strLogFileSubDir = LOGFILESUBDIR
End If
If Len(strLogFileSubDir) > 0 AND Len(TEMP) > 0 Then
strLogFileDir = TEMP & "\" & strLogFileSubDir
Else
strLogFileDir = LOGFILEDIR
End If
strLogIniFileDir = strLogFileDir
strLogIniFileName = GetMonSvrRegistryValue(REGKEY_MS_LOGINIFILENAME)
If Len(strLogIniFileName) = 0 Then
strLogIniFileName = LOGINIFILENAME
End If
strLogIniFileNameAbs = strLogIniFileDir & "\" & strLogIniFileName
'*** check if debug mode is enabled by ini file
If DebugMode = False Then
Call GetLogFileIni(strLogIniFileNameAbs, INISEC_BLADECOMPMONITOR)
End If
SaveBCDebug = 0
If DebugMode = TRUE Then
SaveBCDebug = BCDebug
BCDebug = GetOpenIniValue(strLogIniFileNameAbs, INISEC_BLADECOMPMONITOR, INIKEY_DEBUGLEVEL)
If BCDebug = "" Then
'e.g. "no such entry" or "ini file not there": no DEBUG!
BCDebug = 0
End If
End If
If oArgs.Count > 1 Then
If DebugMode = true Then
'*** logfilesdir\PYBladeSystemMonitor_<BCenclosurename>_<component>
strLogFileNameAbs = TEMP & "\" & strLogFileSubDir & "\" & LOGFILENAME & oArgs(0) & "_" & oArgs(1) & ".log"
Call CreateLogFile(strLogFileNameAbs, TRUE)
End If
End If
'*** Terminate if not enough args, logfile will not be created in this case
If insideMP = true And oArgs.Count <= 2 Then
DebugOut("***** Not enought args, script terminates here! *****")
Wscript.Quit(-1)
Else
DebugOut("3 or more params")
BC_SerialNumber = oArgs(0)
Component = oArgs(1)
ipAddress = oArgs(2)
End If
DebugOut("Arguments: BC_SerialNumber = " & BC_SerialNumber & " Component = " & Component & " IpAddress = " & ipAddress)
'*** Check for simulation of blade server discovery/monitoring
simulationMode = false
simulationMode = CheckSimulationMode(strLogIniFileNameAbs)
'*** Create property bag
If insideMP = true Then
Set oAPI = CreateObject("MOM.ScriptAPI")
Set oPropertyBag = oAPI.CreatePropertyBag()
End If
'*** Determine the communication file name
'*** read the name of comm. file from registry
BladeSystemCommunicationFilePath = GetBladeSystemCommunicationFilePath()
If BCDebug AND BCDEBUG_MIN Then
DebugOut("Comm File: " & strBCCommunicationFile)
DebugOut("Blade System Package DEBUG = " & BCDebug & " (" & SaveBCDebug & ")")
DebugOut("Environment Variable SystemRoot = " & SYSTEMROOT)
DebugOut("Environment Variable WinDir = " & WINDIR)
End If
ProcessOverallStatus = false
MonitorAgentRunning = IsMonitorAgentRunning()
'--------------------------------------------------------------------------------------------------------------------------
'--------------------------------------------------------------------------------------------------------------------------
' Real processing starts here
'--------------------------------------------------------------------------------------------------------------------------
'--------------------------------------------------------------------------------------------------------------------------
If InStr(1,ipAddress, "N/A", 1) > 0 Then
DebugOut("******************** Component not discovered ********************")
If insideMP = true Then
If InStr(1,Component, ComponentsList(COMPLIST_SERVERBLADES), 1) > 0 Then
strWhat = BC_SerialNumber & "_" & ComponentsList(COMPLIST_SERVERBLADES) & "_BladeID_N/A"
Call oPropertyBag.AddValue(strWhat & "_MonitoringState", STATUS_BAD)
ElseIf InStr(1,Component, ComponentsList(COMPLIST_STORAGEBLADES), 1) > 0 Then
strWhat = BC_SerialNumber & "_" & ComponentsList(COMPLIST_STORAGEBLADES) & "_BladeID_N/A"
Call oPropertyBag.AddValue(strWhat & "_MonitoringState", STATUS_BAD)
Else
Call oPropertyBag.AddValue(BC_SerialNumber & "_" & Component & "_MonitoringState", STATUS_BAD)
End If
Call oAPI.Return(oPropertyBag)
End If
DebugOut("******************** Monitoring normal end ********************")
WScript.Quit(0)
End If
If MonitorAgentRunning = false Then
DebugOut("******************** Monitoring Agent not running, Script terminates ********************")
'*** we assume that not running BSMA is detected by BSMA monitor, therefor we do not set extra staze Call oPropertyBag.AddValue(BC_SerialNumber & "_" & Component & "_MonitoringState", STATUS_BAD)
Call oAPI.Return(oPropertyBag)
WScript.Quit(0)
End If
If fileUpdated = true Then
fileUpdated = GetCommunicationFile(BC_SerialNumber, Component)
End If
If fileUpdated = False Then
DebugOut("******************** Communication File not available, script ends here! ********************")
strEventLogMsg = "Could not load XML file (4) " & strBCCommunicationFile & " - script ends here!"
DebugOut(strEventLogMsg)
If insideMP = true Then
Call oAPI.LogScriptEvent("PYBladeSystemEnclosureMonitor.vbs/" & Component, 501, WARNING_EVENT, strEventLogMsg)
Call oPropertyBag.AddValue(BC_SerialNumber & "_" & Component & "_MonitoringState", STATUS_BAD)
Call oAPI.Return(oPropertyBag)
End If
WScript.Quit(0)
End If
DebugOut("Processing of 1st Communication File starts")
'*** comm. file is OK then go ahead
'*** initialize component count for all components
NoOfMMBUnits = 0
NoOfPSUnits = 0
NoOfFanUnits = 0
NoOfTSUnits = 0
NoOfCUnits = 0
NoOfKVMUnits = 0
'*** get BC main properties
InitPropertyArray()
'*** Check serial number of the enclosure (maybe changed)
BEnclosureChanged = EnclosureChanged(BC_SerialNumber) = true
Call ProcessResponse()
'*** Overall Status requested / reading 2nd communication file ?
If ProcessOverallStatus = true then
Component = Component & "Ovst"
fileUpdated = SendCommandAndWaitForResponse(BC_SerialNumber, Component, ipAddress)
If fileUpdated = true Then
fileUpdated = GetCommunicationFile(BC_SerialNumber, Component)
End If
If fileUpdated = False Then
DebugOut("******************** 2nd Communication File not available, script ends here! ********************")
strEventLogMsg = "Could not load XML file (4) " & strBCCommunicationFile & " - script ends here!"
DebugOut(strEventLogMsg)
If insideMP = true Then
Call oAPI.LogScriptEvent("PYBladeSystemEnclosureMonitor.vbs/" & Component, 501, WARNING_EVENT, strEventLogMsg)
Call oPropertyBag.AddValue(BC_SerialNumber & "_" & Component & "_MonitoringState", STATUS_BAD)
Call oAPI.Return(oPropertyBag)
End If
WScript.Quit(0)
End If
InitPropertyArray()
Call ProcessResponse()
End If
'--------------------------------------------------------------------------------------------------
' Send Data to SCOM
'--------------------------------------------------------------------------------------------------
'*** Send the data to OpsMgr
If insideMP = true Then
DebugOut("Send data to OpsMgr (oPropertyBag)")
Call oAPI.Return(oPropertyBag)
End If
CleanUpTimeFile("********** Normal End of Monitoring Script *************")
If Component = ComponentsList(COMPLIST_ENCLOSURE) OR Component = KEY_ALL Then
If MonitorAgentRunning = true Then
Component_HealthState = ""
If PropertyArray(BC_OVERALLSTATUS) = "" Then
' sometimes we do not get any value
PropertyArray(BC_OVERALLSTATUS) = 0
DebugOut("#### WARNING: Property OVERALLSTATE")
Enclosure_MonitoringState = STATUS_BAD
End If
Compound_HealthState = ConvertStatus(CInt(PropertyArray(BC_OVERALLSTATUS)), Component)
Component_HealthState = Compound_HealthState(0)
Enclosure_MonitoringState = Compound_HealthState(1)
DebugOut("Converted Overall States: " & Component_HealthState & "/" & Enclosure_MonitoringState)
Else
strEventLogMsg = "The Blade System Monitor Service " & BLADESYSTEMMONITORSERVICE & " is not running!"
If insideMP = true Then
Call oAPI.LogScriptEvent("PYBladeSystemEnclosureMonitor.vbs/" & Component, 503, ERROR_EVENT, strEventLogMsg)
End If
DebugOut(strEventLogMsg)
'*** Check serial number of the enclosure (maybe changed)
If BEnclosureChanged = true then
strEventLogMsg = "Enclosure has changed " & strBCCommunicationFile & " - script ends here!"
Call oAPI.LogScriptEvent("PYBladeSystemEnclosureMonitor.vbs/" & Component, 502, INFORMATIONAL_EVENT, strEventLogMsg)
Enclosure_MonitoringState = STATUS_BAD
Component_HealthState = STATUS_UNKNOWN
End If
DebugOut("Enclosure_HealthState = " & Enclosure_HealthState)
If insideMP = true Then
Call oPropertyBag.AddValue(BC_SerialNumber & "_" & ComponentsList(COMPLIST_ENCLOSURE) & "_State", Component_HealthState)
Call oPropertyBag.AddValue(BC_SerialNumber & "_" & ComponentsList(COMPLIST_ENCLOSURE) & "_MonitoringState", Enclosure_MonitoringState)
If IsInFailedState(Enclosure_HealthState) Then
Call oPropertyBag.AddValue(BC_SerialNumber & "_" & ComponentsList(COMPLIST_ENCLOSURE) & "_Failed", BLADESYSTEMMONITORSERVICE & " Service")
End If
End If
If Component = ComponentsList(COMPLIST_MMBS) OR Component = KEY_ALL Then
If BCDebug AND BCDEBUG_MIN Then
DebugOut("***** State of MMB Units")
End If
NoOfMMBUnits = MAX_MMBCOMPONENT '*** set to max. number
If BCDebug AND BCDEBUG_MEDIUM Then
DebugOut("No. of MMBUnits set to MAX: " & NoOfMMBUnits)
End If
NoOfMMBUnitsMonitored = 0
InitStatusArrays()
index = 0
Unit_i = 1
NoOfUnits = NoOfMMBUnits
'*** check all MMB units of this blade server
Do While NoOfUnits > 0
InitPropertyArray()
If GetBCComponent_Properties(BladeSystem_No, BC_ComponentsGroupList(BC_COMP_MMB), Unit_i, MMB + MMB_MIN, MMB_MAX) > 0 Then
Component_HealthState = ""
UnitNumber = PropertyArray(MMB_ID)
Component_Name = PropertyArray(MMB_PRODUCTNAME)
If PropertyArray(MMB_STATUS) = "" Then
' sometimes we do not get any value
PropertyArray(MMB_STATUS) = MMB_STATUS_UNKNOWN
DebugOut("#### WARNING: Property MMB = 'empty' - set to UNKNOWN!")
End If
Compound_HealthState = ConvertStatus(CInt(PropertyArray(MMB_STATUS)), Component)
If BCDebug AND BCDEBUG_MAX Then
DebugOut("UnitNumber: " & UnitNumber)
DebugOut("Component: " & Component_Name)
DebugOut("Health State: " & PropertyArray(MMB_STATUS))
DebugOut("Converted Health State: " & Component_HealthState)
End If
componentNameArray(index) = UnitNumber & ": " & Component_Name & "; "
componentStatusArray(index) = Compound_HealthState(0)
monitoringStatusArray(index) = Compound_HealthState(1)
index = index + 1
NoOfMMBUnitsMonitored = NoOfMMBUnitsMonitored + 1
Else
If BCDebug AND BCDEBUG_MUCH Then
DebugOut("No Properties of MMB Unit: " & Unit_i)
End If
End If
NoOfUnits = NoOfUnits - 1
Unit_i = Unit_i + 1
If Unit_i > MAX_MMBCOMPONENT Then
NoOfUnits = 0
End If
Loop
If NoOfMMBUnitsMonitored > 0 Then
For i=0 To index
If Len(componentNameArray(i)) > 0 Then
componentNames = componentNames & componentNameArray(i)
End If
Next
If BCDebug AND BCDEBUG_FEW Then
DebugOut("Monitored Components: " & componentNames)
End If
'*** set overall state of all instances of the component class
If Len(componentNames) > 0 Then
SetCollectionStatus(index)
End If
Else
If lastErrorNum = 2 Then
monitoringStatus = STATUS_BAD
DebugOut("*** Communication error reported, no monitored MMB units found")
Else
DebugOut("*** No monitored MMB units found")
End If
End If
If (insideMP = true) And (BEnclosureChanged = false) Then
strWhat = BC_SerialNumber & "_" & ComponentsList(COMPLIST_MMBS)
Call oPropertyBag.AddValue(strWhat & "_State", componentStatus)
Call oPropertyBag.AddValue(strWhat & "_MonitoringState", monitoringStatus)
If IsInFailedState(componentStatus) Then
DebugOut("FAILED: " & strWhat & ": " & failedComponents)
If Len(failedComponents) > 0 Then
Call oPropertyBag.AddValue(strWhat & "_Failed", failedComponents)
End If
End If
End If
End If
If Component = ComponentsList(COMPLIST_POWERSUPPLIES) OR Component = KEY_ALL Then
If BCDebug AND BCDEBUG_MIN Then
DebugOut("***** State of Power Supply Units")
End If
NoOfPSUnits = MAX_PSUCOMPONENT '*** set to max. number
If BCDebug AND BCDEBUG_MEDIUM Then
DebugOut("No. of PowerSupplyUnits set to MAX: " & NoOfPSUnits)
End If
NoOfPSUnitsMonitored = 0
InitStatusArrays()
'*** check all Power supply units of this blade server
index = 0
Unit_i = 1
NoOfUnits = NoOfPSUnits
Do While NoOfUnits > 0
InitPropertyArray()
If GetBCComponent_Properties(BladeSystem_No, BC_ComponentsGroupList(BC_COMP_POWERSUPPLYUNIT), Unit_i, PSU + PSU_MIN, PSU_MAX) > 0 Then
Component_HealthState = ""
UnitNumber = PropertyArray(PSU_ID)
Component_Name = PropertyArray(PSU_PRODUCTNAME)
If BCDebug AND BCDEBUG_MAX Then
DebugOut("UnitNumber: " & UnitNumber)
DebugOut("Component: " & Component_Name)
End If
'*** calculate failed components
Compound_HealthState = ConvertStatus(CInt(PropertyArray(BC_POWERSUPPLYUNITS)), Component)
componentNameArray(index) = UnitNumber & ": " & Component_Name & "; "
componentStatusArray(index) = Compound_HealthState(0)
monitoringStatusArray(index) = Compound_HealthState(1)
index = index + 1
NoOfPSUnitsMonitored = NoOfPSUnitsMonitored + 1
Else
If BCDebug AND BCDEBUG_MUCH Then
DebugOut("No Properties of PowerSupply Unit: " & Unit_i)
End If
End If
NoOfUnits = NoOfUnits - 1
Unit_i = Unit_i + 1
If Unit_i > MAX_PSUCOMPONENT Then
NoOfUnits = 0
End If
Loop
If NoOfPSUnitsMonitored > 0 Then
For i=0 To index
If Len(componentNameArray(i)) > 0 Then
componentNames = componentNames & componentNameArray(i)
End If
Next
If BCDebug AND BCDEBUG_FEW Then
DebugOut("Monitored Components: " & componentNames)
End If
'*** set failed components
If Len(componentNames) > 0 Then
SetCollectionStatus(index)
End If
Else
If lastErrorNum = 2 Then
monitoringStatus = STATUS_BAD
DebugOut("*** Communication error reported, no monitored PSUs found")
Else
DebugOut("*** No monitored PSUs found")
End If
End If
ProcessOverallStatus = true
End If
'--------------------------------------------------------------------------------------------------
' PSU Overall Status processing
'--------------------------------------------------------------------------------------------------
If Component = ComponentsList(COMPLIST_POWERSUPPLIES) & "Ovst" Then
If BCDebug AND BCDEBUG_MIN Then
DebugOut("***** Over all state of Power Supply")
End If
If GetBC_Properties(xmlDoc, BladeSystem_No) > 0 Then
If PropertyArray(BC_PSUOVERALLSTATUS) = "" Then
' sometimes we do not get any value
DebugOut("#### WARNING: Property PSU Overal State unknown")
PropertyArray(BC_PSUOVERALLSTATUS) = "unknown"
End If
Compound_HealthState = ConvertStatus(CInt(PropertyArray(BC_PSUOVERALLSTATUS)), Component)
componentStatus = Compound_HealthState(0)
monitoringStatus = Compound_HealthState(1)
Else
If lastErrorNum = 2 Then
monitoringStatus = STATUS_BAD
DebugOut("*** Communication error reported, no PSU overall status found")
Else
DebugOut("*** No PSU overall status found")
End If
End If
If MonitorAgentRunning <> true And MonitorNotRunningSetComponentToWarning = true Then
componentStatus = STATUS_DEGRADED
failedComponents = BLADESYSTEMMONITORSERVICE
End If
DebugOut("Converted Overall States: " & Component_HealthState & "/" & monitoringStatus)
If (insideMP = true) And (BEnclosureChanged = false) Then
strWhat = BC_SerialNumber & "_" & ComponentsList(COMPLIST_POWERSUPPLIES)
Call oPropertyBag.AddValue(strWhat & "_State", componentStatus)
Call oPropertyBag.AddValue(strWhat & "_MonitoringState", monitoringStatus)
If IsInFailedState(componentStatus) Then
DebugOut("FAILED: " & strWhat & ": " & failedComponents)
If Len(failedComponents) > 0 Then
Call oPropertyBag.AddValue(strWhat & "_Failed", failedComponents)
End If
End If
End If
End If
'--------------------------------------------------------------------------------------------------
' Fan processing
'--------------------------------------------------------------------------------------------------
If Component = ComponentsList(COMPLIST_FANS) OR Component = KEY_ALL Then
If BCDebug AND BCDEBUG_MIN Then
DebugOut("***** State of Fan Subsystem")
End If
NoOfFanUnits = MAX_FANCOMPONENT '*** set to max. number
If BCDebug AND BCDEBUG_MEDIUM Then
DebugOut("No. of FanUnits set to MAX: " & NoOfFanUnits)
End If
NoOfFanUnitsMonitored = 0
InitStatusArrays()
'*** check all fan units of this blade server
index = 0
Unit_i = 1
NoOfUnits = NoOfFanUnits
Do While NoOfUnits > 0
InitPropertyArray()
If GetBCComponent_Properties(BladeSystem_No, BC_ComponentsGroupList(BC_COMP_FANUNIT), Unit_i, FAN + FAN_MIN, FAN_MAX) > 0 Then
Component_HealthState = ""
UnitNumber = PropertyArray(FAN_ID)
Component_Name = PropertyArray(FAN_DESIGNATION)
If PropertyArray(FAN_STATUS) = "" Then
' sometimes we do not get any value
PropertyArray(FAN_STATUS) = FAN_STATUS_UNKNOWN
DebugOut("#### WARNING: Property FAN = 'empty' - set to UNKNOWN!")
End If
Compound_HealthState = ConvertStatus(CInt(PropertyArray(FAN_STATUS)), Component)
If BCDebug AND BCDEBUG_MAX Then
DebugOut("UnitNumber: " & UnitNumber)
DebugOut("Component: " & Component_Name)
DebugOut("Health State: " & PropertyArray(FAN_STATUS))
DebugOut("Converted Health State: " & Component_HealthState)
End If
componentNameArray(index) = UnitNumber & ": " & Component_Name & "; "
componentStatusArray(index) = Compound_HealthState(0)
monitoringStatusArray(index) = Compound_HealthState(1)
index = index + 1
NoOfFanUnitsMonitored = NoOfFanUnitsMonitored + 1
Else
If BCDebug AND BCDEBUG_MUCH Then
DebugOut("No Properties of FAN Unit: " & Unit_i)
End If
End If
NoOfUnits = NoOfUnits - 1
Unit_i = Unit_i + 1
If Unit_i > MAX_FANCOMPONENT Then
NoOfUnits = 0
End If
Loop
If NoOfFanUnitsMonitored > 0 Then
For i=0 To index
If Len(componentNameArray(i)) > 0 Then
componentNames = componentNames & componentNameArray(i)
End If
Next
If BCDebug AND BCDEBUG_FEW Then
DebugOut("Monitored Components: " & componentNames)
End If
If MonitorAgentRunning <> true And MonitorNotRunningSetComponentToWarning = true Then
componentStatus = STATUS_DEGRADED
failedComponents = BLADESYSTEMMONITORSERVICE
End If
'*** set failed components
If Len(componentNames) > 0 Then
SetCollectionStatus(index)
End If
Else
If lastErrorNum = 2 Then
monitoringStatus = STATUS_BAD
DebugOut("*** Communication error reported, no monitored Fans found")
Else
DebugOut("*** No monitored Fans found")
End If
End If
ProcessOverallStatus = true
End If
'--------------------------------------------------------------------------------------------------
' Fan Overall Status processing
'--------------------------------------------------------------------------------------------------
If Component = ComponentsList(COMPLIST_FANS) & "Ovst" Then
If BCDebug AND BCDEBUG_MIN Then
DebugOut("***** Over all state of Fans")
End If
If GetBC_Properties(xmlDoc, BladeSystem_No) > 0 Then
If PropertyArray(BC_FANOVERALLSTATUS) = "" Then
' sometimes we do not get any value
DebugOut("#### WARNING: Property Fan Overall State unknown")
PropertyArray(BC_FANOVERALLSTATUS) = "unknown"
End If
Compound_HealthState = ConvertStatus(CInt(PropertyArray(BC_FANOVERALLSTATUS)), Component)
componentStatus = Compound_HealthState(0)
monitoringStatus = Compound_HealthState(1)
Else
If lastErrorNum = 2 Then
monitoringStatus = STATUS_BAD
DebugOut("*** Communication error reported, no Fan overall status found")
Else
DebugOut("*** No Fan overall status found")
End If
End If
If MonitorAgentRunning <> true And MonitorNotRunningSetComponentToWarning = true Then
componentStatus = STATUS_DEGRADED
failedComponents = BLADESYSTEMMONITORSERVICE
End If
DebugOut("Converted Overall State: " & Component_HealthState & "/" & monitoringStatus)
If (insideMP = true) And (BEnclosureChanged = false) = true Then
strWhat = BC_SerialNumber & "_" & ComponentsList(COMPLIST_FANS)
Call oPropertyBag.AddValue(strWhat & "_State", componentStatus)
Call oPropertyBag.AddValue(strWhat & "_MonitoringState", monitoringStatus)
If IsInFailedState(componentStatus) Then
DebugOut("FAILED: " & strWhat & ": " & failedComponents)
If Len(failedComponents) > 0 Then
Call oPropertyBag.AddValue(strWhat & "_Failed", failedComponents)
End If
End If
End If
End If
If Component = ComponentsList(COMPLIST_TEMPSENSORS) OR Component = KEY_ALL Then
If BCDebug AND BCDEBUG_MIN Then
DebugOut("***** State of Temperature Sensors")
End If
NoOfTSUnits = MAX_TSUCOMPONENT '*** set to max. number
If BCDebug AND BCDEBUG_MEDIUM Then
DebugOut("No. of TempSensorUnits set to MAX: " & NoOfTSUnits)
End If
NoOfTempSensorUnitsMonitored = 0
InitStatusArrays()
index = 0
Unit_i = 1
NoOfUnits = NoOfTSUnits
'*** check all temp. sensor units of this blade server
Do While NoOfUnits > 0
InitPropertyArray()
If GetBCComponent_Properties(BladeSystem_No, BC_ComponentsGroupList(BC_COMP_TEMPSENSORUNIT), Unit_i, TSU + TSU_MIN, TSU_MAX) > 0 Then
Component_HealthState = ""
UnitNumber = PropertyArray(TSU_ID)
Component_Name = PropertyArray(TSU_DESIGNATION)
If PropertyArray(TSU_STATUS) = "" Then
' sometimes we do not get any value
PropertyArray(TSU_STATUS) = TSU_STATUS_UNKNOWN
DebugOut("#### WARNING: Property TSU = 'empty' - set to UNKNOWN!")
End If
Compound_HealthState = ConvertStatus(CInt(PropertyArray(TSU_STATUS)), Component)
If BCDebug AND BCDEBUG_MAX Then
DebugOut("UnitNumber: " & UnitNumber)
DebugOut("Component: " & Component_Name)
DebugOut("Health State: " & PropertyArray(TSU_STATUS))
DebugOut("Converted Health State: " & Component_HealthState)
End If
componentNameArray(index) = UnitNumber & ": " & Component_Name & "; "
componentStatusArray(index) = Compound_HealthState(0)
monitoringStatusArray(index) = Compound_HealthState(1)
index = index + 1
NoOfTempSensorUnitsMonitored = NoOfTempSensorUnitsMonitored + 1
Else
If BCDebug AND BCDEBUG_MUCH Then
DebugOut("No Properties of Temperature Sensor Unit: " & Unit_i)
End If
End If
NoOfUnits = NoOfUnits - 1
Unit_i = Unit_i + 1
If Unit_i > MAX_TSUCOMPONENT Then
NoOfUnits = 0
End If
Loop
If NoOfTempSensorUnitsMonitored > 0 Then
For i=0 To index
If Len(componentNameArray(i)) > 0 Then
componentNames = componentNames & componentNameArray(i)
End If
Next
If BCDebug AND BCDEBUG_FEW Then
DebugOut("Monitored Components: " & componentNames)
End If
'*** set failed components
If Len(componentNames) > 0 Then
SetCollectionStatus(index)
End If
If MonitorAgentRunning <> true And MonitorNotRunningSetComponentToWarning = true Then
componentStatus = STATUS_DEGRADED
failedComponents = BLADESYSTEMMONITORSERVICE
End If
Else
If lastErrorNum = 2 Then
monitoringStatus = STATUS_BAD
DebugOut("*** Communication error reported, no monitored temperature sensors found")
Else
DebugOut("*** No monitored temperature sensors found")
End If
End If
ProcessOverallStatus = true
End If
'--------------------------------------------------------------------------------------------------
' Temp Sensor Overall Status processing
'--------------------------------------------------------------------------------------------------
If Component = ComponentsList(COMPLIST_TEMPSENSORS) & "Ovst" Then
If BCDebug AND BCDEBUG_MIN Then
DebugOut("***** Over all state of temp sensors")
End If
If GetBC_Properties(xmlDoc, BladeSystem_No) > 0 Then
If PropertyArray(BC_TEMPOVERALLSTATUS) = "" Then
' sometimes we do not get any value
DebugOut("#### WARNING: Property temp sensor Overall State unknown")
PropertyArray(BC_TEMPOVERALLSTATUS) = "unknown"
End If
Compound_HealthState = ConvertStatus(CInt(PropertyArray(BC_TEMPOVERALLSTATUS)), Component)
componentStatus = Compound_HealthState(0)
monitoringStatus = Compound_HealthState(1)
Else
If lastErrorNum = 2 Then
monitoringStatus = STATUS_BAD
DebugOut("*** Communication error reported, no Fan overall status found")
Else
DebugOut("*** No Fan overall status found")
End If
End If
If MonitorAgentRunning <> true And MonitorNotRunningSetComponentToWarning = true Then
componentStatus = STATUS_DEGRADED
failedComponents = BLADESYSTEMMONITORSERVICE
End If
DebugOut("Converted Overall State: " & Component_HealthState & "/" & monitoringStatus)
If (insideMP = true) And (BEnclosureChanged = false) Then
strWhat = BC_SerialNumber & "_" & ComponentsList(COMPLIST_TEMPSENSORS)
Call oPropertyBag.AddValue(strWhat & "_State", componentStatus)
Call oPropertyBag.AddValue(strWhat & "_MonitoringState", monitoringStatus)
If IsInFailedState(componentStatus) Then
DebugOut("FAILED: " & strWhat & ": " & failedComponents)
If Len(failedComponents) > 0 Then
Call oPropertyBag.AddValue(strWhat & "_Failed", failedComponents)
End If
End If
End If
End If
'--------------------------------------------------------------------------------------------------
' CCU processing
'--------------------------------------------------------------------------------------------------
compListNum = -1
compGroupNum = -1
If Component = ComponentsList(COMPLIST_CONNECTUNITS) Then
compListNum = COMPLIST_CONNECTUNITS
compGroupNum = BC_COMP_CONNECTUNIT
End If
If Component = ComponentsList(COMPLIST_IBCONNECTUNITS) Then
compListNum = COMPLIST_IBCONNECTUNITS
compGroupNum = BC_COMP_IBCONNECTUNIT
End If
If Component = ComponentsList(COMPLIST_SASCONNECTUNITS) Then
compListNum = COMPLIST_SASCONNECTUNITS
compGroupNum = BC_COMP_SASCONNECTUNIT
End If
If Component = ComponentsList(COMPLIST_FCCONNECTUNITS) Then
compListNum = COMPLIST_FCCONNECTUNITS
compGroupNum = BC_COMP_FCCONNECTUNIT
End If
If Component = ComponentsList(COMPLIST_FCPTCONNECTUNITS) Then
compListNum = COMPLIST_FCPTCONNECTUNITS
compGroupNum = BC_COMP_FCPTCONNECTUNIT
End If
If Component = ComponentsList(COMPLIST_PTCONNECTUNITS) Then
compListNum = COMPLIST_PTCONNECTUNITS
compGroupNum = BC_COMP_PTCONNECTUNIT
End If
If CompListNum > 0 Then
If BCDebug AND BCDEBUG_MIN Then
DebugOut("***** State of Connection Units")
End If
NoOfCUnits = MAX_CUCOMPONENT '*** set to max. number
If BCDebug AND BCDEBUG_MEDIUM Then
DebugOut("No. of ConnectUnits set to MAX: " & NoOfCUnits)
End If
NoOfConnectUnitsMonitored = 0
InitStatusArrays()
index = 0
Unit_i = 1
NoOfUnits = NoOfCUnits
'*** check all connection units of this blade server
Do While NoOfUnits > 0
InitPropertyArray()
If GetBCComponent_Properties(BladeSystem_No, BC_ComponentsGroupList(compGroupNum), Unit_i, CU + CU_MIN, CU_MAX) > 0 Then
Component_HealthState = ""
UnitNumber = PropertyArray(CU_ID)
Component_Name = PropertyArray(CU_PRODUCTNAME)
If PropertyArray(CU_STATUS) = "" AND PropertyArray(CU_STATUS) <> "" Then
' sometimes we do not get any value
PropertyArray(CU_STATUS) = CU_STATUS_UNKNOWN
DebugOut("#### WARNING: Property CU = 'empty' - set to UNKNOWN!")
End If
Compound_HealthState = ConvertStatus(CInt(PropertyArray(CU_STATUS)), Component)
If BCDebug AND BCDEBUG_MAX Then
DebugOut("UnitNumber: " & UnitNumber)
DebugOut("Component: " & Component_Name)
DebugOut("Health State: " & PropertyArray(CU_STATUS))
DebugOut("Converted Health State: " & Component_HealthState)
End If
componentNameArray(index) = UnitNumber & ": " & Component_Name & "; "
componentStatusArray(index) = Compound_HealthState(0)
monitoringStatusArray(index) = Compound_HealthState(1)
index = index + 1
NoOfConnectUnitsMonitored = NoOfConnectUnitsMonitored + 1
Else
If lastErrorNum = 2 Then
monitoringStatus = STATUS_BAD
DebugOut("*** Communication error reported, no monitored CCUs found")
Else
DebugOut("*** No monitored CCUs found")
End If
End If
NoOfUnits = NoOfUnits - 1
Unit_i = Unit_i + 1
If Unit_i > MAX_CUCOMPONENT Then
NoOfUnits = 0
End If
Loop
If NoOfConnectUnitsMonitored > 0 Then
For i=0 To index
If Len(componentNameArray(i)) > 0 Then
componentNames = componentNames & componentNameArray(i)
End If
Next
If BCDebug AND BCDEBUG_FEW Then
DebugOut("Monitored Components: " & componentNames)
End If
'*** set overall state of all instances of the component class
If Len(componentNames) > 0 Then
SetCollectionStatus(index)
End If
If MonitorAgentRunning <> true And MonitorNotRunningSetComponentToWarning = true Then
componentStatus = STATUS_DEGRADED
failedComponents = BLADESYSTEMMONITORSERVICE
End If
Else
DebugOut("*** No monitored Connection units found")
'*** status variables should be initialized
componentStatus = STATUS_OK
End If
If (insideMP = true) And (BEnclosureChanged = false) Then
strWhat = BC_SerialNumber & "_" & ComponentsList(compListNum)
Call oPropertyBag.AddValue(strWhat & "_State", componentStatus)
Call oPropertyBag.AddValue(strWhat & "_MonitoringState", monitoringStatus)
If IsInFailedState(componentStatus) Then
DebugOut("FAILED: " & strWhat & ": " & failedComponents)
If Len(failedComponents) > 0 Then
Call oPropertyBag.AddValue(strWhat & "_Failed", failedComponents)
End If
End If
End If
End If
If Component = ComponentsList(COMPLIST_KVMUNITS) OR Component = KEY_ALL Then
If BCDebug AND BCDEBUG_MIN Then
DebugOut("***** State of KVM Units")
End If
NoOfKVMUnits = MAX_KVMCOMPONENT '*** set to max. number
If BCDebug AND BCDEBUG_MEDIUM Then
DebugOut("No. of KVMUnits set to MAX: " & NoOfKVMUnits)
End If
NoOfKVMUnitsMonitored = 0
InitStatusArrays()
'*** check all KVM switch units of this blade server
index = 0
Unit_i = 1
NoOfUnits = NoOfKVMUnits
Do While NoOfUnits > 0
InitPropertyArray()
If GetBCComponent_Properties(BladeSystem_No, BC_ComponentsGroupList(BC_COMP_KVMUNIT), Unit_i, KVM + KVM_MIN, KVM_MAX) > 0 Then
Component_HealthState = ""
UnitNumber = PropertyArray(KVM_ID)
Component_Name = PropertyArray(KVM_PRODUCTNAME)
If PropertyArray(KVM_STATUS) = "" Then
' sometimes we do not get any value
PropertyArray(KVM_STATUS) = KVM_STATUS_UNKNOWN
DebugOut("#### WARNING: Property KVM = 'empty' - set to UNKNOWN!")
End If
Compound_HealthState = ConvertStatus(CInt(PropertyArray(KVM_STATUS)), Component)
If BCDebug AND BCDEBUG_MAX Then
DebugOut("UnitNumber: " & UnitNumber)
DebugOut("Component: " & Component_Name)
DebugOut("Health State: " & PropertyArray(KVM_STATUS))
DebugOut("Converted Health State: " & Component_HealthState)
End If
componentNameArray(index) = UnitNumber & ": " & Component_Name & "; "
componentStatusArray(index) = Compound_HealthState(0)
monitoringStatusArray(index) = Compound_HealthState(1)
index = index + 1
NoOfKVMUnitsMonitored = NoOfKVMUnitsMonitored + 1
Else
If BCDebug AND BCDEBUG_MUCH Then
DebugOut("No Properties of KVM Unit: " & Unit_i)
End If
End If
NoOfUnits = NoOfUnits - 1
Unit_i = Unit_i + 1
If Unit_i > MAX_KVMCOMPONENT Then
NoOfUnits = 0
End If
Loop
If NoOfKVMUnitsMonitored > 0 Then
For i=0 To index
If Len(componentNameArray(i)) > 0 Then
componentNames = componentNames & componentNameArray(i)
End If
Next
If BCDebug AND BCDEBUG_FEW Then
DebugOut("Monitored Components: " & componentNames)
End If
'*** set overall state of all instances of the component class (global variables componentStatus and monitoringStatus are set)
If Len(componentNames) > 0 Then
SetCollectionStatus(index)
End If
If MonitorAgentRunning <> true And MonitorNotRunningSetComponentToWarning = true Then
componentStatus = STATUS_DEGRADED
failedComponents = BLADESYSTEMMONITORSERVICE
End If
Else
If lastErrorNum = 2 Then
monitoringStatus = STATUS_BAD
DebugOut("*** Communication error reported, no monitored KVM units found")
Else
DebugOut("*** No monitored KVM units found")
End If
End If
If (insideMP = true) And (BEnclosureChanged = false) Then
strWhat = BC_SerialNumber & "_" & ComponentsList(COMPLIST_KVMUNITS)
Call oPropertyBag.AddValue(strWhat & "_State", componentStatus)
Call oPropertyBag.AddValue(strWhat & "_MonitoringState", monitoringStatus)
If IsInFailedState(componentStatus) Then
DebugOut("FAILED: " & strWhat & ": " & failedComponents)
If Len(failedComponents) > 0 Then
Call oPropertyBag.AddValue(strWhat & "_Failed", failedComponents)
End If
End If
End If
End If
'--------------------------------------------------------------------------------------------------
' Server Blade processing
'--------------------------------------------------------------------------------------------------
If Component = ComponentsList(COMPLIST_SERVERBLADES) OR Component = KEY_ALL Then
If BCDebug AND BCDEBUG_MIN Then
DebugOut("***** State of Server Blades")
End If
NoOfServerBlades = MAX_SERVERBLADECOMPONENT '*** set to max. number
If BCDebug AND BCDEBUG_MEDIUM Then
DebugOut("No. of Server Blades set to MAX: " & NoOfServerBlades)
End If
NoOfServerBladesMonitored = 0
InitStatusArrays()
index = 0
Unit_i = 1
NoOfUnits = NoOfServerBlades
If BEnclosureChanged = false Then
'*** check all Server Blades
Do While NoOfUnits > 0
InitPropertyArray()
If GetBCComponent_Properties(BladeSystem_No, BC_ComponentsGroupList(BC_COMP_SERVERBLADE), Unit_i, SRV + SERVER_MIN, SERVER_MAX) > 0 Then
Component_HealthState = ""
UnitNumber = PropertyArray(SERVER_ID)
If PropertyArray(SERVER_STATUS) = "" Then
'sometimes we do not get any value
PropertyArray(SERVER_STATUS) = SERVER_STATUS_UNKNOWN
DebugOut("#### WARNING: Property Server Blade Status = 'empty' - set to UNKNOWN!")
End If
strWhat = BC_SerialNumber & "_" & ComponentsList(COMPLIST_SERVERBLADES) & "_BladeID_" & UnitNumber
Call oPropertyBag.AddValue(strWhat & "_State", componentStatus)
Call oPropertyBag.AddValue(strWhat & "_MonitoringState", monitoringStatus)
If BCDebug AND BCDEBUG_MAX Then
DebugOut("UnitNumber: " & UnitNumber)
DebugOut("Health State: " & PropertyArray(SERVER_STATUS))
DebugOut("Converted Health State: " & componentStatus)
DebugOut("Converted Monitoring State: " & monitoringStatus)
DebugOut(" ")
End If
index = index + 1
NoOfServerBladesMonitored = NoOfServerBladesMonitored + 1
Else
If BCDebug AND BCDEBUG_MUCH Then
DebugOut("No Properties of Server Blade: " & Unit_i)
End If
End If
NoOfUnits = NoOfUnits - 1
Unit_i = Unit_i + 1
If Unit_i > MAX_SERVERBLADECOMPONENT Then
NoOfUnits = 0
End If
Loop
End If '*** If BEnclosureChanged = false
If NoOfServerBladesMonitored = 0 Then
If lastErrorNum = 2 Then
monitoringStatus = STATUS_BAD
For i=1 To MAX_SERVERBLADECOMPONENT
strWhat = BC_SerialNumber & "_" & ComponentsList(COMPLIST_SERVERBLADES) & "_BladeID_" & CStr(i)
Call oPropertyBag.AddValue(strWhat & "_MonitoringState", monitoringStatus)
Next
DebugOut("*** Communication error reported, no monitored server blades found")
Else
DebugOut("*** No monitored server blades found")
End If
End If
End If
If Component = ComponentsList(COMPLIST_STORAGEBLADES) OR Component = KEY_ALL Then
If BCDebug AND BCDEBUG_MIN Then
DebugOut("***** State of Storage Blades")
End If
NoOfStorageBlades = MAX_STORAGEBLADECOMPONENT '*** set to max. number
If BCDebug AND BCDEBUG_MEDIUM Then
DebugOut("No. of Storage Blades set to MAX: " & NoOfStorageBlades)
End If
NoOfStorageBladesMonitored = 0
InitStatusArrays()
index = 0
Unit_i = 1
NoOfUnits = NoOfStorageBlades
If BEnclosureChanged = false Then
'*** check all Storage Blades
Do While NoOfUnits > 0
InitPropertyArray()
If GetBCComponent_Properties(BladeSystem_No, BC_ComponentsGroupList(BC_COMP_STORAGEBLADE), Unit_i, STR + STORAGE_MIN, STORAGE_MAX) > 0 Then
Component_HealthState = ""
UnitNumber = PropertyArray(STORAGE_ID)
If PropertyArray(STORAGE_STATUS) = "" Then
'sometimes we do not get any value
PropertyArray(STORAGE_STATUS) = STORAGE_STATUS_UNKNOWN
DebugOut("#### WARNING: Property Storage Blade Status = 'empty' - set to UNKNOWN!")
End If
strWhat = BC_SerialNumber & "_" & ComponentsList(COMPLIST_STORAGEBLADES) & "_BladeID_" & UnitNumber
Call oPropertyBag.AddValue(strWhat & "_State", componentStatus)
Call oPropertyBag.AddValue(strWhat & "_MonitoringState", monitoringStatus)
If BCDebug AND BCDEBUG_MAX Then
DebugOut("UnitNumber: " & UnitNumber)
DebugOut("Health State: " & PropertyArray(STORAGE_STATUS))
DebugOut("Converted Health State: " & componentStatus)
DebugOut("Converted Monitoring State: " & monitoringStatus)
DebugOut(" ")
End If
index = index + 1
NoOfStorageBladesMonitored = NoOfStorageBladesMonitored + 1
Else
If BCDebug AND BCDEBUG_MUCH Then
DebugOut("No Properties of Storage Blade: " & Unit_i)
End If
End If
NoOfUnits = NoOfUnits - 1
Unit_i = Unit_i + 1
If Unit_i > MAX_STORAGEBLADECOMPONENT Then
NoOfUnits = 0
End If
Loop
End If
If NoOfStorageBladesMonitored = 0 Then
If lastErrorNum = 2 Then
monitoringStatus = STATUS_BAD
For i=1 To MAX_STORAGEBLADECOMPONENT
strWhat = BC_SerialNumber & "_" & ComponentsList(COMPLIST_STORAGEBLADES) & "_BladeID_" & CStr(i)
Call oPropertyBag.AddValue(strWhat & "_MonitoringState", monitoringStatus)
Next
DebugOut("*** Communication error reported, no monitored server blades found")
Else
DebugOut("*** No monitored server blades found")
End If
End If
End If
End Sub
'--------------------------------------------------------------------------------------------------
' MonitoringOnDemand()
'
' Input Parameter: None
' Return Parameter: result indicates if control code was sucessfully sent
'--------------------------------------------------------------------------------------------------
Function MonitoringOnDemand()
CONST strComputer = "."
Dim objWMIService, objItem, objService
Dim colListOfServices, strQuery, strService, result, MonitoringControlCode
Dim CmdBuf, CmdRet, cmdReturnFile
Dim xmlCfgDoc, cfgFileLoaded, xmlCfgDocElem, xmlMonitorNode
Dim strCfgPath, strCfgName, strCfgAbsName
Dim testMCC, checkCount
Dim FSO
'*** read cfg file in order to determin control code
strCfgPath = GetMonSvrRegistryValue(REGKEY_MS_CONFIGFILEPATH)
strCfgName = GetMonSvrRegistryValue(REGKEY_MS_CONFIGFILENAME)
strCfgAbsName = strCfgPath & "\" & strCfgName
If BCDebug AND BCDEBUG_FEW Then
DebugOut("CONFIG file name = " & strCfgAbsName)
End If
'*** (try to) load XML file
Set xmlCfgDoc = CreateObject("Msxml2.DOMDocument")
'disable asynchronous loading
xmlCfgDoc.async = False
checkCount = 3 ' retries - hard coded
cfgFileLoaded = xmlCfgDoc.load(strCfgAbsName)
Do While cfgFileLoaded = false
WScript.Sleep(WAITING_TIME)
checkCount = checkCount - 1
If checkCount = 0 Then
Exit Do
End If
cfgFileLoaded = xmlCfgDoc.load(strCfgAbsName)
Loop
If BCDebug AND BCDEBUG_FEW Then
DebugOut("cfgFileLoaded = " & cfgFileLoaded)
End If
MonitoringControlCode = ""
if cfgFileLoaded Then
On Error Resume Next
Set xmlCfgDocElem = xmlCfgDoc.documentElement
Set xmlMonitorNode = xmlCfgDocElem.selectNodes("//*/Monitoring/ControlCode")
MonitoringControlCode = xmlMonitorNode.item(0).Text
On Error Goto 0
End If
If Len(MonitoringControlCode) = 0 Then
'*** if control code cannot determined use DEFAULT value
MonitoringControlCode = CONTROLCODE_MONITORING
End If
If BCDebug AND BCDEBUG_FUNC OR BCDebug AND BCDEBUG_M_O_D Then
DebugOut("MonitoringOnDemand(), ControlCode = " & MonitoringControlCode)
End If
'*** create al list with all monitor agents
strQuery = "Select * from Win32_Service Where Name=""" & BLADESYSTEMMONITORSERVICE & """"
If BCDebug AND BCDEBUG_FUNC OR BCDebug AND BCDEBUG_M_O_D Then
DebugOut(strQuery)
End If
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery (strQuery)
'*** send the control code to all agents
For Each objService in colListOfServices
result = objService.UserControlService(MonitoringControlCode)
Next
'*** evaluate the result
If BCDebug AND BCDEBUG_FUNC OR BCDebug AND BCDEBUG_M_O_D Then
DebugOut("Return code from WMI control command" & BLADESYSTEMMONITORSERVICE & ": " & result)
End If
'*** error handling
If result <> 0 Then
'*** if error from service control via WMI try another command
CmdBuf = "SC control " & Chr(34) & BLADESYSTEMMONITORSERVICE & Chr(34) &" " & MonitoringControlCode
If BCDebug AND BCDEBUG_FUNC OR BCDebug AND BCDEBUG_M_O_D Then
DebugOut(CmdBuf)
End If
'*** create FSO-Object
Set FSO = CreateObject("Scripting.FileSystemObject")
cmdReturnFile = strLogFileDir & "\MOD\" & BC_SerialNumber & "." & Component & ".txt"
'*** only create file, if it does not yet exist
If FSO.FileExists(cmdReturnFile) = FALSE Then
Call CreateLogFile(cmdReturnFile, FALSE)
End If
CmdRet = WshShell.Run("cmd /c " & CmdBuf & " >" & cmdReturnFile, 0, true)
If BCDebug AND BCDEBUG_FUNC OR BCDebug AND BCDEBUG_M_O_D Then
DebugOut("Return code from SC command: " & CmdRet)
End If
result = CmdRet
End If
'*** provide return parameter
MonitoringOnDemand = result
CONST TargetComputer = "."
Dim Services, Service, AgentState, ServiceFound
If BCDebug AND BCDEBUG_FUNC Then
DebugOut("Check running Monitor Agent " & BLADESYSTEMMONITORSERVICE)
End If
On Error Resume Next
Set Services = GetObject("winmgmts:\\" & TargetComputer & "\root\cimv2").ExecQuery("SELECT * FROM Win32_Service")
AgentState = false
ServiceFound = false
For Each Service in Services
If Service.Name = BLADESYSTEMMONITORSERVICE Then
ServiceFound = true
If BCDebug AND BCDEBUG_FUNC Then
DebugOut("Service Name: " & Service.Name)
DebugOut("Service DisplayName: " & Service.DisplayName)
DebugOut("Service State: " & Service.State)
DebugOut("Service Status: " & Service.Status)
DebugOut("Service Started: " & Service.Started)
End If
If Service.State = "Running" Then
AgentState = true
End If
Exit For
End If
Next
On Error Goto 0
If BCDebug AND BCDEBUG_FUNC Then
DebugOut("Service found = " & ServiceFound)
End If
GetMonSvrRegistryValue = GetBCRegistryValue(KEY_MONITOR_SERVICE & "\" & strName)
End Function
'--------------------------------------------------------------------------------------------------
' GetBaseRegistryValue(strName)
' get a current version in registry
'
' Input Parameter:
' - strName
'
' Return Parameter: value
'--------------------------------------------------------------------------------------------------
Function GetBaseRegistryValue(strName)
GetBaseRegistryValue = GetBCRegistryValue(KEY_CURRENT_VERSION & "\" & strName)
strValue = ""
On Error Resume Next
regPath = BlRegPath & "\" & strValueName
If BCDebug AND BCDEBUG_FUNC Then
DebugOut("regPath = " & regPath)
End If
strValue = WshShell.RegRead(regPath)
On Error Goto 0
If BCDebug AND BCDEBUG_FUNC Then
DebugOut("GetBCRegistryValue() - " & strValueName & " = " & strValue)
End If
If BCDebug AND BCDEBUG_FUNC Then
DebugOut("GetBladeSystemCommunicationFilePath()")
End If
filePath = ""
If simulationMode = true Then
filePath = GetOpenIniValue(strLogIniFileNameAbs, INISEC_COMMUNICATIONFILE, KEY_DIRECTORY)
If BCDebug AND BCDEBUG_FUNC Then
DebugOut("Communication file in simulation mode:")
DebugOut("Path = " & filePath)
End If
End If
'*** use normal communication file
If Len(filePath) = 0 Then
filePath = GetMonSvrRegistryValue(REGKEY_MS_COMMFILEPATH)
End If
If Len(filePath) > 0 Then
strBladeSystemCommFilePath = filePath
Else
strBladeSystemCommFilePath = BCCOMMFILEPATH
If BCDebug AND BCDEBUG_FUNC Then
DebugOut("CommunicationFilePath by default: " & strBladeSystemCommFilePath)
End If
End If
If BCDebug AND BCDEBUG_MIN Then
DebugOut("CommunicationFilePath: " & strBladeSystemCommFilePath)
End If
Function IsInFailedState(state)
IsInFailedState = false
If state = STATUS_DEGRADED Or state = STATUS_ERROR Then
IsInFailedState = true
End If
End Function
If BCDebug AND BCDEBUG_FUNC Then
DebugOut("BC Key Value: " & strValueKey & " = " & strValue)
End If
If Len(strValue) > 0 And strValue <> "-1" Then
For index=BC_MIN To BC_MAX
strValueKey = BC_PropertyNameList(index)
strValue = GetXMLComponentsPropertyValue(xmlDoc, BC_Number, strComponent, strValueKey)
If BCDebug AND BCDEBUG_FUNC Then
DebugOut("BC_Key value: " & strValueKey & " = " & strValue)
End If
If Len(strValue) > 0 And strValue <> "-1" Then
PropertyArray(index) = strValue
count = count + 1
End If
Next
End If
If BCDebug AND BCDEBUG_FUNC Then
DebugOut("No. of BC keys with value: " & count)
End If
Dim xmlDocElement, xmlServerNode, xmlServerComponentsNodes
Dim NoOfBladeSystems
Set xmlDocElement = xmlDoc.documentElement
Set xmlServerNode = xmlDoc.selectNodes("*/Server")
Set xmlServerComponentsNodes = xmlDoc.selectNodes("*/Server/Components")
'we always use ...
NoOfBladeSystems = 1
If BCDebug AND BCDEBUG_FUNC Then
DebugOut("No of Blade Systems: " & NoOfBladeSystems)
End If
GetNoOfBladeSystems = NoOfBladeSystems
Function GetBCComponent_Properties(BC_Number, ComponentName, ComponentNo, key_property_index, property_maxIndex)
Dim strComponent, strValueKey, strValue, count, index, component_index
count = 0
component_index = key_property_index
strComponent = ComponentName & " " & ComponentNo
strValueKey = PropertyNameList(component_index)
'check the 1st property of component
strValue = GetXMLComponentsPropertyValue(xmlDoc, BC_Number, strComponent, strValueKey)
If BCDebug AND BCDEBUG_FUNC Then
DebugOut("Component Key Value: " & strValueKey & " = " & strValue)
End If
If Len(strValue) > 0 And strValue <> "-1" Then
For index=0 To property_maxIndex
strValueKey = PropertyNameList(component_index + index)
strValue = GetXMLComponentsPropertyValue(xmlDoc, BC_Number, strComponent, strValueKey)
If BCDebug AND BCDEBUG_FUNC Then
DebugOut(strValueKey & " = " & strValue)
End If
If Len(strValue) > 0 And strValue <> "-1" Then
'*** save property value in array
PropertyArray(index) = strValue
count = count + 1
End If
Next
End If
If BCDebug AND BCDEBUG_FUNC Then
DebugOut("No. of keys with value: " & count)
End If
If BCDebug AND BCDEBUG_FUNC Then
DebugOut("CheckSimulationMode(" & FilePathName & ")")
End If
simMode = false
iniVal = UCase(GetOpenIniValue(FilePathName, INISEC_COMMUNICATIONFILE, KEY_SIMULATION))
If iniVal = "YES" Then
simMode = true
If BCDebug AND BCDEBUG_FUNC Then
DebugOut("*** Simulation mode is active ***")
End If
End If
Function GetXMLComponentsPropertyValue(xmlDoc, nServerNo, strComponent, strPropertyName)
Dim xmlDocElement, xmlServerNode, xmlServerComponentsNodes, xmlNameOfComponent, xmlComponentNode, xmlElementListNode
Dim i, j, k, l, xmlName, xmlValue
Dim varPropertyValue
Dim bValueFound, bValueInComponentNode
Dim NodeName, ServerNumber
Dim NoOfBladeSystems
If BCDebug AND BCDEBUG_FUNC Then
DebugOut("Input args of GetXMLComponentsPropertyValue: " & nServerNo & "/" & strComponent & "/" & strPropertyName)
End If
varPropertyValue = ""
Set xmlDocElement = xmlDoc.documentElement
Set xmlServerNode = xmlDoc.selectNodes("*/Server/Group/Components")
Set xmlServerComponentsNodes = xmlDoc.selectNodes("*/Server/Group/Components")
'we always use ...
NoOfBladeSystems = 1
bValueFound = false
bValueInComponentNode = true
For i=0 To xmlDocElement.childNodes.length-1
NodeName = xmlDocElement.childNodes.item(i).nodeName
ServerNumber = xmlDocElement.childNodes.item(i).getAttribute("Number")
If BCDebug AND BCDEBUG_FUNC Then
If NodeName = "Server" Then
DebugOut("Blade System No.: " & ServerNumber)
End If
End If
If NodeName = "Server" Then
nServerNo = ServerNumber
'If nServerNo = ServerNumber Or nServerNo = CInt(ServerNumber) Then
Set xmlServerNode = xmlDocElement.childNodes.Item(i)
For j=0 To xmlServerNode.childNodes.length-1
If xmlServerNode.childNodes.item(j).nodeName = "Components" Then
xmlNameOfComponent = xmlServerNode.childNodes.item(j).getAttribute("Name")
'DebugOut("Node Components = " & xmlNameOfComponent)
If xmlNameOfComponent = strComponent Then
Set xmlComponentNode = xmlServerNode.childNodes.Item(j)
'DebugOut("No of Components subelements: " & xmlComponentNode.childNodes.length)
For k=0 To xmlComponentNode.childNodes.length-1
Set xmlElementListNode = xmlComponentNode.childNodes.Item(k)
'DebugOut("No of ListElements: " & xmlElementListNode.childNodes.length)
varPropertyValue = ""
bValueInComponentNode = false
For l=0 To xmlElementListNode.childNodes.length-1
If xmlElementListNode.childNodes.item(l).childNodes.length > 0 Then
If xmlElementListNode.childNodes.item(l).childNodes.item(0).Text = strPropertyName Then
If BCDebug AND BCDEBUG_FUNC Then
DebugOut(xmlElementListNode.childNodes.item(l).childNodes.item(0).Text & "=[" & _
xmlElementListNode.childNodes.item(l).childNodes.item(1).Text & "]")
End If
varPropertyValue = xmlElementListNode.childNodes.item(l).childNodes.item(1).Text
bValueFound = true
bValueInComponentNode = true
Exit For
End If
End If
Next
If bValueFound = true Or bValueInComponentNode = false Then
Exit For
End If
Next
End If
If bValueFound = true Or bValueInComponentNode = false Then
Exit For
End If
End If
Next
If bValueFound = true Or bValueInComponentNode = false Then
Exit For
End If
'End If
End If
If bValueFound = true Or bValueInComponentNode = false Then
Exit For
End If
Next
If BCDebug AND BCDEBUG_FUNC Then
If bValueFound = false Then
DebugOut("Property value of key '" & strPropertyName & "' not found")
End If
End If
GetXMLComponentsPropertyValue = varPropertyValue
End Function
'--------------------------------------------------------------------------------------------------
' GetOpenIniValue(FilePathName, Section, KeyValue)
' opens ini file and get value for key
'
' Input Parameter:
' - FilePathName
' - Section
' - KeyValue
' Output Parameter: value
'--------------------------------------------------------------------------------------------------
Function GetOpenIniValue(FilePathName, Section, KeyValue)
Dim FSO
Dim value
On Error Resume Next
value = ""
If BCDebug AND BCDEBUG_FUNC Then
DebugOut("GetOpenIniValue(" & FilePathName & ", " & Section & ", " & KeyValue & ")")
End If
'*** create FSO-Object
Set FSO = CreateObject("Scripting.FileSystemObject")
'*** open ini file for reading
If FSO.FileExists(FilePathName) Then
value = GetIniValue(FilePathName, Section, KeyValue)
Else
If BCDebug AND BCDEBUG_FUNC Then
DebugOut("File " & FilePathName & " does not exist!")
End If
End If
On Error Goto 0
If BCDebug AND BCDEBUG_FUNC Then
DebugOut("IniValue = " & value)
End If
GetOpenIniValue = value
End Function
'--------------------------------------------------------------------------------------------------
' GetIniValue(FileName, Section, KeyValue)
' opens ini file and get value for key
'
' Input Parameter:
' - FileName
' - Section
' - KeyValue
' Output Parameter: None
'--------------------------------------------------------------------------------------------------
Function GetIniValue(FileName, Section, KeyValue)
CONST ForReading = 1
Dim FSO, hFile
Dim line, value, char
Dim KeyFound, SectionFound
Dim I
On Error Resume Next
value = ""
'*** create FSO-Object
Set FSO = CreateObject("Scripting.FileSystemObject")
'*** open ini file for reading
Set hFile = FSO.OpenTextFile(FileName, ForReading)
If BCDebug AND BCDEBUG_FUNC Then
DebugOut("hFile: [" & hFile & "]")
End If
If Not IsNull(hFile) Then
KeyFound = False
'*** loop over whole file
Do While Not hFile.AtEndOfStream
line = hFile.readline
'*** check if it is a section
If left(line,1) = "[" Then
'*** Is this the section we are looking for?
If ucase(mid(line, 2, len(Section))) = ucase(Section) Then
'*** yes
SectionFound = True
Else
'*** no
SectionFound = False
End If
Else
If SectionFound Then
'*** has line the value we are looking for?
If ucase(left(line, len(KeyValue))) = ucase(KeyValue) Then
I = len(KeyValue) + 1
'*** continue until value found
Do While I < len(line)
char = MID(line, I, 1)
'*** check equal sign
If char = "=" Then
'*** get value
value = Right(line, Len(line) - I)
'*** break
I = Len(line)
KeyFound = True
Else
I = I + 1
End If
Loop
End If
End If
End If
Loop
hFile.close
If KeyFound = False Then
value = ""
End If
End If
On Error Goto 0
If BCDebug AND BCDEBUG_FUNC Then
DebugOut(FileName & ", " & Section & ", " & KeyValue & " = " & value)
End If
Sub CheckNumberOfRegisteredComponents(strSerNo, strComponent, newValue)
Dim strValue, strModValue, strWhat, oldValue
strValue = GetBladeChassisRegistryValue(strSerNo, strComponent)
if Len(strValue) > 0 Then
oldValue = CInt(strValue)
Else
oldValue = 0
End If
strWhat = strSerNo & "_" & strComponent
If newValue <> oldValue Then
'*** did we have a different value already?
strModValue = GetBladeChassisRegistryValue(strSerNo, strComponent & KEY_REG_MODIFIED)
If Len(strModValue) > 0 Then
'*** we had a different value already - has it become more (INFO) or less (ERROR)?
If CInt(newValue) < CInt(oldValue) Then
'*** we lost one (or some) ...
componentStatus = STATUS_ERROR
If insideMP = true Then
strValue = GetBladeChassisRegistryValue(strSerNo, strComponent & KEY_REG_LOST_WRITTEN)
If Len(strValue) = 0 Then
strEventLogMsg = "lost " & oldValue - newValue & " " & strComponent & "(s)"
Call oAPI.LogScriptEvent("PYBladeSystemEnclosureMonitor.vbs/" & strSerNo, 505, ERROR_EVENT, strEventLogMsg)
Call PutBladeChassisRegistryValue(strSerNo, strComponent & KEY_REG_LOST_WRITTEN, 1)
DebugOut("LOST COMPONENT: " & strWhat & ": Number changed from " & oldValue & " to " & newValue)
End If
End If
Else
If insideMP = true Then
strValue = GetBladeChassisRegistryValue(strSerNo, strComponent & KEY_REG_FOUND_WRITTEN)
If Len(strValue) = 0 Then
strEventLogMsg = "found " & oldValue - newValue & " new " & strComponent & "(s)"
Call oAPI.LogScriptEvent("PYBladeSystemEnclosureMonitor.vbs/" & strSerNo, 506, INFORMATIONAL_EVENT, strEventLogMsg)
Call PutBladeChassisRegistryValue(strSerNo, strComponent & KEY_REG_FOUND_WRITTEN, 1)
End If
End If
DebugOut("COMPONENT ADDED: " & strWhat & ": Number changed from " & oldValue & " to " & newValue)
DeleteBladeChassisRegistryValue(strSerNo & "\" & strComponent & KEY_REG_MODIFIED)
'*** set new value
Call PutBladeChassisRegistryValue(strSerNo, strComponent, newValue)
End If
Else
'*** give it one RETRY (next pass)
Call PutBladeChassisRegistryValue(strSerNo, strComponent & KEY_REG_MODIFIED, newValue)
End If
Else
DeleteBladeChassisRegistryValue(strSerNo & "\" & strComponent & KEY_REG_MODIFIED)
DeleteBladeChassisRegistryValue(strSerNo & "\" & strComponent & KEY_REG_FOUND_WRITTEN)
DeleteBladeChassisRegistryValue(strSerNo & "\" & strComponent & KEY_REG_LOST_WRITTEN)
End If
If insideMP = true Then
Call oPropertyBag.AddValue(strWhat & "_State", componentStatus)
Call oPropertyBag.AddValue(strWhat & "_MonitoringState", monitoringStatus)
If IsInFailedState(componentStatus) Then
DebugOut("FAILED: " & strSerNo & " + " & strComponent & ": " & failedComponents)
If Len(failedComponents) > 0 Then
Call oPropertyBag.AddValue(strWhat & "_Failed", failedComponents)
End If
End If
If CInt(newValue) < CInt(oldValue) Then
strValue = GetBladeChassisRegistryValue(strSerNo, strComponent & KEY_REG_LOST_WRITTEN)
If Len(strValue) > 0 Then
DebugOut("DIFFERENCE: " & strSerNo & " + " & strComponent & ": " & oldValue & " --> " & newValue)
Call oPropertyBag.AddValue(strWhat & "_Lost", oldValue - newValue & " " & strComponent)
End If
End If
End If
failedComponents = ""
If BCDebug AND BCDEBUG_FUNC Then
DebugOut("Set the components overall state")
End If
For i=0 To maxindex-1
If Len(componentStatusArray(i)) = 0 Or componentStatusArray(i) = " " Or componentStatusArray(i) = STATUS_UNKNOWN Then
componentStatusArray(i) = STATUS_UNKNOWN
End If
If BCDebug AND BCDEBUG_FUNC Then
DebugOut("Name of Component at index " & i & ": <" & componentNameArray(i) & ">")
DebugOut("Status of Component at index " & i & ": <" & componentStatusArray(i) & ">")
End If
If (Len(componentNameArray(i)) > 0) And (Len(componentStatusArray(i)) > 0) Then
If componentStatus = STATUS_UNKNOWN And componentStatusArray(i) = STATUS_UNKNOWN Then
componentStatus = STATUS_UNKNOWN
ElseIf componentStatus = STATUS_UNKNOWN And componentStatusArray(i) = STATUS_OK Then
componentStatus = STATUS_OK
ElseIf componentStatus = STATUS_UNKNOWN And componentStatusArray(i) = STATUS_DEGRADED Then
componentStatus = STATUS_DEGRADED
ElseIf componentStatus = STATUS_UNKNOWN And componentStatusArray(i) = STATUS_ERROR Then
componentStatus = STATUS_ERROR
ElseIf componentStatus = STATUS_OK And componentStatusArray(i) = STATUS_UNKNOWN Then
componentStatus = STATUS_OK
ElseIf componentStatus = STATUS_OK And componentStatusArray(i) = STATUS_DEGRADED Then
componentStatus = STATUS_DEGRADED
ElseIf componentStatus = STATUS_OK And componentStatusArray(i) = STATUS_ERROR Then
componentStatus = STATUS_ERROR
ElseIf componentStatus = STATUS_DEGRADED And componentStatusArray(i) = STATUS_ERROR Then
componentStatus = STATUS_ERROR
End If
End If
If (Len(monitoringStatusArray(i)) > 0) Then
If monitoringStatus = STATUS_GOOD And monitoringStatusArray(i) = STATUS_BAD Then
monitoringStatus = STATUS_BAD
End If
End If
Next
If BCDebug AND BCDEBUG_FUNC Then
DebugOut("Set the defect components")
End If
For i=0 To maxindex-1
If BCDebug AND BCDEBUG_FUNC Then
DebugOut("Name of Component at index " & i & ": <" & componentNameArray(i) & ">")
DebugOut("Status of Component at index " & i & ": <" & componentStatusArray(i) & ">")
End If
If Len(componentNameArray(i)) > 0 And Len(componentStatusArray(i)) > 0 Then
If componentStatusArray(i) = STATUS_DEGRADED Then
failedComponents = failedComponents & componentNameArray(i)
ElseIf componentStatusArray(i) = STATUS_ERROR Then
failedComponents = failedComponents & componentNameArray(i)
ElseIf monitoringStatusArray(i) = STATUS_BAD Then
failedComponents = failedComponents & componentNameArray(i)
End If
End If
Next
'*** There are also combinations unknown/good; but preleminary we save the old solution
' If componentStatus = STATUS_UNKNOWN Then
' '*** componentStatus = STATUS_DEGRADED
' monitoringStatus = STATUS_BAD
' End If
If BCDebug AND BCDEBUG_FUNC Then
DebugOut("OverallState of components collection: " & componentStatus)
DebugOut("Failed Component/s: " & failedComponents)
End If
End Sub
On Error Resume Next
regPath = BlRegPath & "\" & strValueName
If BCDebug AND BCDEBUG_FUNC Then
DebugOut("regPath = " & regPath)
End If
strReadValue = WshShell.RegRead(regPath)
'*** avoid WRITE, if possible
If CString(strReadValue) <> CString(strValue) Then
Call WshShell.RegWrite(regPath, strValue)
End If
On Error Goto 0
If BCDebug AND BCDEBUG_FUNC Then
DebugOut("PutBCRegistryValue() - " & strValueName & " = " & strValue & " done.")
End If
On Error Resume Next
regPath = BlRegPath & "\" & strValueName
If BCDebug AND BCDEBUG_FUNC Then
DebugOut("regPath = " & regPath)
End If
strReadValue = WshShell.RegRead(regPath)
If Len(strReadValue) > 0 Then
Call WshShell.RegDelete(regPath)
End If
On Error Goto 0
If BCDebug AND BCDEBUG_FUNC Then
DebugOut("DeleteBCRegistryValue() - " & strValueName & " done.")
End If
Dim sMessage, sMPVersion, sLogString
Dim oTextStream 'As Scripting.TextStream
Dim oFSO 'As Scripting.FileSystemObject
Dim systemTime
if isLogFile = TRUE Then
'*** this is a real LOG file script ...
sLogString = "********** Start logging script: "
Else
'*** used for ...
sLogString = "********** Temporary File for access time comparison: "
End If
systemTime = Time()
sMessage = sLogString & strLogFileName & " ** " & systemTime & " **********"
sMPVersion = "MP Version: " & MPVERSION
DebugOut(sMessage)
DebugOut(sMPVersion)
On Error Resume Next
Set oFSO = CreateObject("Scripting.FileSystemObject")
If not oFSO.FolderExists(oFSO.GetParentFolderName(strLogFileName)) Then
oFSO.CreateFolder(oFSO.GetParentFolderName(strLogFileName))
End If
Set oTextStream = oFSO.OpenTextFile(strLogFileName, 2, True) ' 2 = new file for writing
oTextStream.WriteLine sMessage
oTextStream.WriteLine sMPVersion
oTextStream.WriteLine "Monitor 0"
oTextStream.Close
Function GetConfigFileEntry(ConfigFileEntry)
Dim xmlCfgDoc, cfgFileLoaded, xmlCfgDocElem, xmlMonitorNode
Dim strCfgPath, strCfgName, strCfgAbsName
Dim checkCount
If Len(strCfgPath) > 0 AND Len(strCfgName) > 0 Then
strCfgAbsName = strCfgPath & "\" & strCfgName
If BCDebug AND BCDEBUG_FEW Then
DebugOut("CONFIG file name = " & strCfgAbsName)
End If
'*** (try to) load XML file
Set xmlCfgDoc = CreateObject("Msxml2.DOMDocument")
'disable asynchronous loading
xmlCfgDoc.async = False
checkCount = 3 ' retries - hard coded
cfgFileLoaded = xmlCfgDoc.load(strCfgAbsName)
Do While cfgFileLoaded = false
WScript.Sleep(WAITING_TIME)
checkCount = checkCount - 1
If checkCount = 0 Then
Exit Do
End If
cfgFileLoaded = xmlCfgDoc.load(strCfgAbsName)
Loop
If BCDebug AND BCDEBUG_FEW Then
DebugOut("cfgFileLoaded = " & cfgFileLoaded)
End If
if cfgFileLoaded Then
On Error Resume Next
Set xmlCfgDocElem = xmlCfgDoc.documentElement
Set xmlMonitorNode = xmlCfgDocElem.selectNodes(ConfigFileEntry)
GetConfigFileEntry = xmlMonitorNode.item(0).Text
Dim sMessage
Dim oTextStream 'As Scripting.TextStream
Dim oFSO 'As Scripting.FileSystemObject
Dim TimeSeconds
If DebugFile = true Then
TimeSeconds = Time()
sMessage = TimeSeconds & ": " & Text
On Error Resume Next
Set oFSO = CreateObject("Scripting.FileSystemObject")
If SYSTEMDRIVE = "C:" Then
Set oTextStream = oFSO.OpenTextFile("C:\Windows\Temp\SVISCOM\BL\DEBUG\out.log", 8, True) ' 8 = append
Else
Set oTextStream = oFSO.OpenTextFile("D:\Windows\Temp\SVISCOM\BL\DEBUG\out.log", 8, True) ' 8 = append
End If
oTextStream.WriteLine sMessage
oTextStream.Close
If IsFileExisting(ChassisSN, component, FILETYPE_RESPONSE) = true Then
DebugOut("SendCommandAndWaitForResponse / response file exists")
If IsFileOutOfDate(ChassisSN, component, FILETYPE_RESPONSE, TIMEOUT_RESPONSEFILE_600_IN_S) = false Then
oldResponseCouldBeUsed = True
End If
If IsFileOutOfDate(ChassisSN, component, FILETYPE_RESPONSE, TIMEOUT_RESPONSEFILE_300_IN_S) = false Then
DebugOut("SendCommandAndWaitForResponse / response file up to date")
'*** response file OK, nothing to do
fileUpdated = true
Else
fileUpdated = false
End If
End If
If fileUpdated = false Then
'*** check if discovery command files exist in this case do not generate further commandfile
discoveryOngoing = IsDiscoveryOngoing(ChassisSN)
If discoveryOngoing = True Then
loopCount = 15
'*** wait until discovery is finished but not longer than a distinct time
Do Until (discoveryOngoing = False) OR (loopCount <= 0)
WScript.Sleep(WAIT_20S)
discoveryOngoing = IsDiscoveryOngoing(ChassisSN)
loopCount = loopCount - 1
Loop
End If
If discoveryOngoing = False Then
If IsFileExisting(ChassisSN, component, FILETYPE_RESPONSE) = true Then
'*** delete old response file since the BSMA does not overwrite
Call DeleteFile(BC_SerialNumber, component, FILETYPE_RESPONSE)
End If
'*** job not yet done => continue
If IsFileExisting(ChassisSN, component, FILETYPE_CMD) = False Then
'*** CMD file doesn't exist, generate it
DebugOut("SendCommandAndWaitForResponse / gen CMD file")
Call GenerateCmdFile(ChassisSN, component, ipAdr)
End If
'*** control code is sent any way
DebugOut("SendCommandAndWaitForResponse / gen signal new CMD")
controlReturn = MonitoringOnDemand()
Do Until fileUpdated OR (loopCount <= 0)
WScript.Sleep(WAIT_5S)
'*** we are waiting for a new response
If IsFileOutOfDate(ChassisSN, component, FILETYPE_RESPONSE, TIMEOUT_RESPONSEFILE_60_IN_S) = false Then
fileUpdated = True
End If
loopCount = loopCount - 1
Loop
Else
DebugOut("Discovery ongoing, no further command files sent")
fileUpdated = FALSE
End If
End If '*** "If fileUpdated = false"
Else
DebugOut("HELP: SERVICE NOT RUNNING???")
fileUpdated = FALSE
End If
SendCommandAndWaitForResponse = fileUpdated
DebugOut("SendCommandAndWaitForResponse = " & fileUpdated)
End Function
Function GetCommunicationFile(ChassisSN, component)
Dim commFile
Dim getFile
DebugOut("Start: GetCommunicationFile(" & ChassisSN & ", " & component &") ...")
getFile = true
Set xmlDoc = CreateObject("Msxml2.DOMDocument")
xmlDoc.async = false
If xmlDoc.parseError.errorCode <> 0 Then
DebugOut("-- GetCommunicationFile: parse error when reading response file 1st")
getFile = false
WScript.Sleep(WAIT_5S)
getFile = xmlDoc.load(commFile)
End If
If xmlDoc.parseError.errorCode <> 0 Then
DebugOut("-- GetCommunicationFile: parse error when reading response file 2nd")
getFile = false
WScript.Sleep(WAIT_5S)
getFile = xmlDoc.load(commFile)
End If
If xmlDoc.parseError.errorCode <> 0 Then
DebugOut("-- GetCommunicationFile: parse error when reading response file")
getFile = false
End If
GetCommunicationFile = getFile
DebugOut("GetCommunicationFile = " & getFile)
End Function
Function GetCommunicationFileOld(ChassisSN, component)
Dim commFile
Dim getFile
DebugOut("Start: GetCommunicationFile(" & ChassisSN & ", " & component &") ...")
getFile = true
Set xmlDoc = CreateObject("Msxml2.DOMDocument")
xmlDoc.async = false
If xmlDoc.parseError.errorCode <> 0 Then
DebugOut("-- GetCommunicationFile: parse error when reading response file 1st")
getFile = false
WScript.Sleep(WAIT_5S)
getFile = xmlDoc.load(commFile)
End If
If xmlDoc.parseError.errorCode <> 0 Then
DebugOut("-- GetCommunicationFile: parse error when reading response file 2nd")
getFile = false
WScript.Sleep(WAIT_5S)
getFile = xmlDoc.load(commFile)
End If
If xmlDoc.parseError.errorCode <> 0 Then
DebugOut("-- GetCommunicationFile: parse error when reading response file")
getFile = false
End If
GetCommunicationFileOld = getFile
DebugOut("GetCommunicationFile = " & getFile)
End Function
Function IsFileExisting(ChassisSN, component, fileType)
Dim fileExists
Dim FSO1
Dim tmpFile
DebugOut("Start: IsFileExisting(" & ChassisSN & ", " & component &") ...")
Set FSO1 = CreateObject("Scripting.FileSystemObject")
'--------------------------------------------------------------------------------------------------
' IsFileOutOfDate: checks file timeout
'
' Input Parameter:
' - ChassisSN part of filename
' - component part of filename
' - fileType part of filename
' - timeout timeout in seconds
' Result Parameter: true/false; result is also true if file doesn't exist
'--------------------------------------------------------------------------------------------------
Function IsFileOutOfDate(ChassisSN, component, fileType, timeout)
Dim FSO
Dim tmpFile
Dim fileOutOfDate
Dim diffsec
Dim file1
Dim acc1, mod1
DebugOut("Start: IsFileOutOfDate() ...")
Set FSO = CreateObject("Scripting.FileSystemObject")
tmpFile = ComposeFilename(ChassisSN, component, fileType)
If FSO.FileExists(tmpFile) = false Then
fileOutOfDate = true
Else
Set file1 = FSO.GetFile(tmpFile)
acc1 = file1.DateLastAccessed
mod1 = file1.DateLastModified
'*** difference between W2K3 and W2K8 ... take the newest of the two times!
If mod1 > acc1 Then
acc1 = mod1
End If
diffsec = datediff("s",acc1, now())
If diffsec > timeout Then
fileOutOfDate = true
Else
fileOutOfDate = false
End If
End If
IsFileOutOfDate = fileOutOfDate
Set FSO = Nothing
DebugOut("IsFileOutOfDate = " & IsFileOutOfDate)
End Function
'--------------------------------------------------------------------------------------------------
' IsDiscoveryOngoing: checks if discovery command files for a ceertain chassis exist
'
' Input Parameter:
' - ChassisSN part of filename
' Result Parameter: true/false
'--------------------------------------------------------------------------------------------------
Function IsDiscoveryOngoing(ChassisSN)
Dim FSO
Dim tmpFile
Dim i
Dim discoveryOngoing
Set FSO = CreateObject("Scripting.FileSystemObject")
i = 0
discoveryOngoing = false
Do While (discoveryOngoing = false) and (i < BC_COMPNUM_MAX)
tmpFile = ComposeFilename(ChassisSN, ComponentsList(i), FILETYPE_CMD_DISCOVERY)
If FSO.FileExists(tmpFile) = true Then
discoveryOngoing = true
End If
i = i + 1
Loop
IsDiscoveryOngoing = discoveryOngoing
End Function
'--------------------------------------------------------------------------------------------------
' Function ComposeFilename(ChassisSN, component, fileType)
'--------------------------------------------------------------------------------------------------
Function ComposeFilename(ChassisSN, component, fileType)
Dim tmpFile
DebugOut("Start: ComposeFilename(" & ChassisSN & ", " & component &") ...")
Select Case fileType
Case FILETYPE_RESPONSE
tmpFile = BladeSystemCommunicationFilePath & "\Blade_" & ChassisSN & "_" & component & "Mon_" & "comm.xml"
Case FILETYPE_RESPONSE_OLD
tmpFile = BladeSystemCommunicationFilePath & "\OLD\Blade_" & ChassisSN & "_" & component & "Mon_" & "comm.xml"
Case FILETYPE_CMD
tmpFile = BladeSystemCommunicationFilePath & "\CMD_" & ChassisSN & "_" & component & "Mon" & ".xml"
Case FILETYPE_CMD_DISCOVERY
tmpFile = BladeSystemCommunicationFilePath & "\CMD_" & ChassisSN & "_" & component & "Dis" & ".xml"
Case FILETYPE_CMD_TEMPLATE
tmpFile = BladeSystemCommunicationFilePath & "\TEMPLATE\CMD_Template_" & component & "Mon" & ".xml"
Case Else
'*** wrong file type
End Select
ComposeFilename = tmpFile
DebugOut("ComposeFilename = " & tmpFile)
End Function
'--------------------------------------------------------------------------------------------------
' Sub GenerateCmdFile(ChassisSN, component, IPaddress)
'--------------------------------------------------------------------------------------------------
Sub GenerateCmdFile(ChassisSN, component, IPaddress)
Dim templFile, outpFile
Dim xmlCMDDoc
Dim server
Dim tmp
DebugOut("Start: GenerateCmdFile() ...")
Set xmlCMDDoc = CreateObject("Msxml2.DOMDocument")
xmlCMDDoc.async = false
If xmlCMDDoc.parseError.errorCode <> 0 Then
DebugOut("-- GenerateCmdFile: parse error when updating template")
Else
Set server = xmlCMDDoc.selectSingleNode("//Server")
Call server.setAttribute("ChassisSerialNumber",ChassisSN)
tmp = "IpAddress"
Call server.setAttribute(tmp,IPaddress)
outpFile = ComposeFilename(ChassisSN, component, FILETYPE_CMD)
xmlCMDDoc.Save(outpFile)
End If
Set xmlCMDDoc = Nothing
End Sub
Sub SendEventLog_599()
strEventLogMsg = "Reading response from old folder! SN/Component: " & BC_SerialNumber & "/" & Component
Call oAPI.LogScriptEvent("PYBladeSystemEnclosureMonitor.vbs/" & Component, 599, ERROR_EVENT, strEventLogMsg)