BladeSystem Enclosure Health State Data Source

Fujitsu.PRIMERGY.BladeSystem.Enclosure.HealthStateDataSource (DataSourceModuleType)

Element properties:

TypeDataSourceModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
OutputTypeSystem.PropertyBagData

Member Modules:

ID Module Type TypeId RunAs 
DS DataSource System.CommandExecuterPropertyBagSource Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
PeriodInSecondsint$Config/PeriodInSeconds$BladeSystem Enclosure Health State Data Source Period In SecondsBladeSystem Enclosure Health State Data Source Period In Seconds

Source Code:

<DataSourceModuleType ID="Fujitsu.PRIMERGY.BladeSystem.Enclosure.HealthStateDataSource" Accessibility="Internal" Batching="false">
<Configuration>
<xsd:element minOccurs="1" name="PeriodInSeconds" type="xsd:integer"/>
<xsd:element minOccurs="1" name="SerialNumber" type="xsd:string"/>
<xsd:element minOccurs="1" name="Component" type="xsd:string"/>
<xsd:element minOccurs="1" name="IpAddress" type="xsd:string"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="PeriodInSeconds" Selector="$Config/PeriodInSeconds$" ParameterType="int"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<DataSource ID="DS" TypeID="System!System.CommandExecuterPropertyBagSource">
<IntervalSeconds>$Config/PeriodInSeconds$</IntervalSeconds>
<ApplicationName>%windir%\System32\cscript.exe</ApplicationName>
<WorkingDirectory/>
<CommandLine>$file/PYBladeSystemEnclosureMonitor.vbs$ $Config/SerialNumber$ $Config/Component$ "$Config/IpAddress$"</CommandLine>
<TimeoutSeconds>900</TimeoutSeconds>
<RequireOutput>true</RequireOutput>
<Files>
<File>
<Name>PYBladeSystemEnclosureMonitor.vbs</Name>
<Contents><Script>
'-----------------------------------------------------------------
'-MONITORING-MONITORING-MONITORING-MONITORING-MONITORING-MONITORING
'------------------------------------------------------------------
' Fujitsu Technology Solutions
' Copyright (C) Fujitsu Technology Solutions 2014
' PYBladeSystemEnclosureMonitor.vbs
' $Config/SerialNumber$
' $Config/Component$
'
'
'
'
' Summary:
' Monitors Fujitsu PRIMERGY BladeSystem enclosure components
'
' Remarks:
' - BL = Blade (management) Pack
' - BC = Blade Chassis (mostly meant: the MMB, or the whole chassis)
'
'-------------------------------------------------------------------
Option Explicit

SetLocale("en-us")

Const MPVERSION = "*** 5.0 ***"

'--------------------------------------------
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

CONST BCDEBUG_MIN = 1 ' 0x0001
CONST BCDEBUG_FEW = 2 ' 0x0002
CONST BCDEBUG_MEDIUM = 4 ' 0x0004
CONST BCDEBUG_MUCH = 8 ' 0x0008

CONST BCDEBUG_MAX = 16 ' 0x0010
CONST BCDEBUG_MONITOR = 32 ' 0x0020

CONST BCDEBUG_FUNC = 256 ' 0x0100 "Function ...()"
CONST BCDEBUG_SUB = 512 ' 0x0200 "Sub ...()"
CONST BCDEBUG_M_O_D = 1024 ' 0x0400 Monitoring On Demand
CONST BCDEBUG_TIME = 2048 ' 0x0800 Put time stamp entries into the windows event log

'--------------------------------------------

CONST INISEC_BLADECOMPMONITOR = "BladeComponentsMonitor"
CONST INISEC_COMMUNICATIONFILE = "CommunicationFile"

CONST INIKEY_DEBUGMODE = "DebugMode"
CONST INIKEY_DEBUGLEVEL = "DebugLevel"

CONST KEY_ALL = "ALL"
CONST KEY_BLADE_CHASSIS = "BladeChassis"
CONST KEY_COMM_ERROR = "COMMUNICATION ERROR"
CONST KEY_CURRENT_VERSION = "CurrentVersion"
CONST KEY_DIRECTORY = "Directory"
CONST KEY_EVENT_LOG = "FujitsuBladeSystemMMB"
CONST KEY_FILE_DISCOVERY = "DISCOVERY.txt"
CONST KEY_FILE_DIS_DONE = "DISCOVERY.done.txt"
CONST KEY_MONITOR_SERVICE = "MonitorService"
CONST KEY_NAME = "Name"
CONST KEY_NOOFBLADESYSTEM = "NoOfBladeSystem"
CONST KEY_REG_COMM_ERROR = "COMM_Error" ' remember in registry: "COMMUNICATION ERROR" already seen once!
CONST KEY_REG_FOUND_WRITTEN = "FoundWritten" ' remember in registry: "Found" SEL already written!
CONST KEY_REG_LOST_WRITTEN = "LostWritten" ' remember in registry: "Lost" SEL already written!
CONST KEY_REG_MODIFIED = "Modified" ' save modified value (found) in registry
CONST KEY_SIMULATION = "Simulation"
CONST KEY_SYSTEMDRIVE = "C:"
CONST KEY_TEMP = "Temp"
CONST KEY_TIME = "TIME"
CONST KEY_UNKNOWN = "unknown"
CONST KEY_WINDOWS = "Windows"

'*** Filetypes
CONST FILETYPE_NONE = 0
CONST FILETYPE_RESPONSE = 1
CONST FILETYPE_CMD = 2
CONST FILETYPE_CMD_TEMPLATE = 3
CONST FILETYPE_CMD_DISCOVERY = 4
CONST FILETYPE_RESPONSE_OLD = 99

'*** Timeout constants
CONST TIMEOUT_MA_RESPONSE_IN_S = 150 ' timeout waiting for response
CONST WAIT_5S = 5000 ' conversion factor 5s -&gt; ms
CONST WAIT_20S = 20000 ' conversion factor 20s -&gt; 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 &amp; "\" &amp; 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"

'*** default names of log file path/name
CONST LOGFILENAME = "PYBladeSystemMonitor_"
CONST LOGFILESUBDIR = "SVISCOM\BL"


Dim strLogIniFileDir, strLogIniFileName, strLogIniFileNameAbs
Dim strLogFileSubDir, strLogFileDir, strLogFileNameAbs
Dim BlRegPath ' 64 bit OS? Set "(Blade) Registry Path" correspondingly

Dim TimeFile


'----------------------

CONST ERROR_EVENT = 1
CONST WARNING_EVENT = 2
CONST INFORMATIONAL_EVENT = 4

CONST CONTROLCODE_MONITORING = 201
CONST CHECKCOUNTMAX = 500
CONST WAITING_TIME = 1000


CONST BCCOMMFILEPATH = "C:\Program Files\Fujitsu\ServerView Suite\SCOM Integration\SVISCOM-BL\MonitorService\comm\"

CONST BC_COMP_CHASSISINFORMATION = 0
CONST BC_COMP_MMB = 1
CONST BC_COMP_POWERSUPPLYUNIT = 2
CONST BC_COMP_FANUNIT = 3
CONST BC_COMP_TEMPSENSORUNIT = 4
CONST BC_COMP_CONNECTUNIT = 5
CONST BC_COMP_IBCONNECTUNIT = 6
CONST BC_COMP_SASCONNECTUNIT = 7
CONST BC_COMP_FCCONNECTUNIT = 8
CONST BC_COMP_FCPTCONNECTUNIT = 9
CONST BC_COMP_PTCONNECTUNIT = 10
CONST BC_COMP_KVMUNIT = 11
CONST BC_COMP_SERVERBLADE = 12
CONST BC_COMP_STORAGEBLADE = 13
CONST BC_COMPNUM_MAX = 14 ' number of different components


CONST BC_CHASSISSERIALNUMBER = 0
CONST BC_IPADDRESS = 1
CONST BC_BLADESYSTEMMODEL = 2
CONST BC_BLADESYSTEMCHASSIS = 3
CONST BC_MMBUNITS = 4
CONST BC_POWERSUPPLYUNITS = 5
CONST BC_FANUNITS = 6
CONST BC_TEMPSENSORUNITS = 7
CONST BC_CONNECTUNITS = 8
CONST BC_KVMUNITS = 9
CONST BC_OVERALLSTATUS = 10
CONST BC_PSUOVERALLSTATUS = 11
CONST BC_FANOVERALLSTATUS = 12
CONST BC_TEMPOVERALLSTATUS = 13

CONST BC_MIN = 0
CONST BC_MAX = 13


CONST MAX_MMBCOMPONENT = 2
CONST MAX_PSUCOMPONENT = 8
CONST MAX_FANCOMPONENT = 64
CONST MAX_TSUCOMPONENT = 48
CONST MAX_CUCOMPONENT = 8
CONST MAX_KVMCOMPONENT = 4
CONST MAX_SERVERBLADECOMPONENT = 18
CONST MAX_STORAGEBLADECOMPONENT = 18

CONST MAX_BX900_MMBCOMPONENT = 2
CONST MAX_BX900_PSUCOMPONENT = 4
CONST MAX_BX900_FANCOMPONENT = 64
CONST MAX_BX900_TSUCOMPONENT = 48
CONST MAX_BX900_CUCOMPONENT = 8
CONST MAX_BX900_KVMCOMPONENT = 4


CONST MAXINDEX = 64 'biggest ever possible index of all components above, at the moment MAX_BX900_FANCOMPONENT


CONST MMB = 0
CONST PSU = 15
CONST FAN = 30
CONST TSU = 45
CONST CU = 60
CONST KVM = 75
CONST SRV = 90
CONST STR = 105


CONST MMB_ID = 0
CONST MMB_SERIALNUMBER = 1
CONST MMB_MODELNAME = 2
CONST MMB_MANUFACTURE = 3
CONST MMB_PRODUCTNAME = 4
CONST MMB_HARDWAREVERSION = 5
CONST MMB_FIRMWAREVERSION = 6
CONST MMB_PHYSICALADDRESS = 7
CONST MMB_STATUS = 8

CONST MMB_MIN = 0
CONST MMB_MAX = 8

CONST MMB_STATUS_UNDEFINED = 0
CONST MMB_STATUS_UNKNOWN = 1
CONST MMB_STATUS_OK = 2
CONST MMB_STATUS_NOTPRESENT = 3
CONST MMB_STATUS_ERROR = 4
CONST MMB_STATUS_CRITICAL = 5
CONST MMB_STATUS_STANDBY = 6


CONST PSU_ID = 0
CONST PSU_SERIALNUMBER = 1
CONST PSU_MODELNAME = 2
CONST PSU_PRODUCTNAME = 3
CONST PSU_MANUFACTURER = 4
CONST PSU_STATUS = 5

CONST PSU_MIN = 0
CONST PSU_MAX = 5

CONST PSU_STATUS_UNDEFINED = 0
CONST PSU_STATUS_UNKNOWN = 1
CONST PSU_STATUS_OK = 2
CONST PSU_STATUS_NOTPRESENT = 3
CONST PSU_STATUS_ERROR = 4
CONST PSU_STATUS_CRITICAL = 5
CONST PSU_STATUS_OFF = 6
CONST PSU_STATUS_DUMMY = 7
CONST PSU_STATUS_FANMODULE = 8 ' new: this is no real PSU but only a HW that holds fans


CONST FAN_ID = 0
CONST FAN_DESIGNATION = 1
CONST FAN_CURRENTSPEED = 2
CONST FAN_CURRENTMAXSPEED = 3
CONST FAN_STATUS = 4

CONST FAN_MIN = 0
CONST FAN_MAX = 4

CONST FAN_STATUS_UNDEFINED = 0
CONST FAN_STATUS_UNKNOWN = 1
CONST FAN_STATUS_DISABLE = 2
CONST FAN_STATUS_OK = 3
CONST FAN_STATUS_FAIL = 4
CONST FAN_STATUS_PREDFAIL = 5
CONST FAN_STATUS_FAILED = 6
CONST FAN_STATUS_NOTMANAGE = 7
CONST FAN_STATUS_NOTPRESENT = 8
CONST FAN_STATUS_AVAILABLE = 9


CONST TSU_ID = 0
CONST TSU_DESIGNATION = 1
CONST TSU_CURRENTVALUE = 2
CONST TSU_STATUS = 3

CONST TSU_MIN = 0
CONST TSU_MAX = 3

CONST TSU_STATUS_UNDEFINED = 0
CONST TSU_STATUS_UNKNOWN = 1
CONST TSU_STATUS_DISABLE = 2
CONST TSU_STATUS_OK = 3
CONST TSU_STATUS_SENSORFAIL = 4
CONST TSU_STATUS_WARNING = 5
CONST TSU_STATUS_CRITICAL = 6
CONST TSU_STATUS_NOTAVAILABLE = 7


CONST CU_ID = 0
CONST CU_PRODUCTNAME = 1
CONST CU_MODELNAME = 2
CONST CU_IPADDR = 3
CONST CU_FIRMWAREVERSION = 4
CONST CU_VERSION = 5
CONST CU_MACADDR = 6
CONST CU_SERIALNUMBER = 7
CONST CU_MANUFACTURE = 8
CONST CU_ADMINURL = 9
CONST CU_STATUS = 10

CONST CU_MIN = 0
CONST CU_MAX = 10

CONST CU_STATUS_UNDEFINED = 0
CONST CU_STATUS_UNKNOWN = 1
CONST CU_STATUS_OK = 2
CONST CU_STATUS_NOTPRESENT = 3
CONST CU_STATUS_ERROR = 4
CONST CU_STATUS_CRITICAL = 5
CONST CU_STATUS_STANDBY = 6
CONST CU_STATUS_PRESENT = 7


CONST KVM_ID = 0
CONST KVM_MANUFACTURE = 1
CONST KVM_SERIALNUMBER = 2
CONST KVM_PRODUCTNAME = 3
CONST KVM_MODELNAME = 4
CONST KVM_VERSION = 5
CONST KVM_IPADDR = 6
CONST KVM_ADMINURL = 7
CONST KVM_STATUS = 8

CONST KVM_MIN = 0
CONST KVM_MAX = 8

CONST SERVER_ID = 0
CONST SERVER_STATUS = 1
CONST SERVER_SERIALNUMBER = 2
CONST SERVER_PRODUCTNAME = 3
CONST SERVER_MODELNAME = 4
CONST SERVER_HWVERSION = 5
CONST SERVER_FWVERSION = 6
CONST SERVER_BIOSVERSION = 7
CONST SERVER_OSTYPE = 8
CONST SERVER_OSVERSION = 9
CONST SERVER_VIOMSETTINGSTATUS = 10
CONST SERVER_HOSTNAME = 11

CONST SERVER_MIN = 0
CONST SERVER_MAX = 11

CONST SERVER_STATUS_UNDEFINED = 0
CONST SERVER_STATUS_UNKNOWN = 1
CONST SERVER_STATUS_OK = 2
CONST SERVER_STATUS_NOTPRESENT = 3
CONST SERVER_STATUS_ERROR = 4
CONST SERVER_STATUS_CRITICAL = 5
CONST SERVER_STATUS_STANDBY = 6


CONST STORAGE_ID = 0
CONST STORAGE_SERIALNUMBER = 1
CONST STORAGE_PRODUCTNAME = 2
CONST STORAGE_MODELNAME = 3
CONST STORAGE_HWVERSION = 4
CONST STORAGE_STATUS = 5
CONST STORAGE_FWVERSION = 6
CONST STORAGE_BIOSVERSION = 7

CONST STORAGE_MIN = 0
CONST STORAGE_MAX = 7

CONST STORAGE_STATUS_UNDEFINED = 0
CONST STORAGE_STATUS_UNKNOWN = 1
CONST STORAGE_STATUS_OK = 2
CONST STORAGE_STATUS_NOTPRESENT = 3
CONST STORAGE_STATUS_ERROR = 4
CONST STORAGE_STATUS_CRITICAL = 5
CONST STORAGE_STATUS_STANDBY = 6



CONST KVM_STATUS_UNDEFINED = 0
CONST KVM_STATUS_UNKNOWN = 1
CONST KVM_STATUS_OK = 2
CONST KVM_STATUS_NOTPRESENT = 3
CONST KVM_STATUS_ERROR = 4
CONST KVM_STATUS_CRITICAL = 5
CONST KVM_STATUS_STANDBY = 6


CONST STATUS_DEGRADED = "Degraded"
CONST STATUS_DISABLE = "Disable"
CONST STATUS_ERROR = "Error"
CONST STATUS_DUMMY = "Dummy"
CONST STATUS_NOTPRESENT = "Not Present"
CONST STATUS_NOTAVAILABLE = "Not Available"
CONST STATUS_OFF = "Off"
CONST STATUS_OK = "OK"
CONST STATUS_STANDBY = "Standby"
CONST STATUS_UNKNOWN = "Unknown"
CONST STATUS_GOOD = "Good"
CONST STATUS_BAD = "Bad"

'*** 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

monitoringStatus = STATUS_GOOD

CONST COMPLIST_ENCLOSURE = 0
CONST COMPLIST_MMBS = 1
CONST COMPLIST_POWERSUPPLIES = 2
CONST COMPLIST_FANS = 3
CONST COMPLIST_TEMPSENSORS = 4
CONST COMPLIST_CONNECTUNITS = 5
CONST COMPLIST_IBCONNECTUNITS = 6
CONST COMPLIST_SASCONNECTUNITS = 7
CONST COMPLIST_FCCONNECTUNITS = 8
CONST COMPLIST_FCPTCONNECTUNITS = 9
CONST COMPLIST_PTCONNECTUNITS = 10
CONST COMPLIST_KVMUNITS = 11
CONST COMPLIST_SERVERBLADES = 12
CONST COMPLIST_STORAGEBLADES = 13

ComponentsList = array("Enclosure", "MMBUnits", "PowerSupplyUnits", "FanUnits", "TempSensors", "ConnectUnits", "IBConnectUnits", "SASConnectUnits", "FCConnectUnits", "FCPTConnectUnits", "PTConnectUnits", "KVMUnits", "ServerBlades", "StorageBlades")

BC_ComponentsGroupList = Array("Chassis Information 1", "Management Blade", "Power Supply Units", "Fan Unit", "Temperature Sensor Unit", "Connect Unit", "Connect Unit IB", "Connect Unit SAS", "Connect Unit FC", "Connect Unit FCPT", "Connect Unit PT", "KVM Unit", "Server Blade", "Storage Blade")


BC_PropertyNameList = Array("SysChassisSerialNumber", "AgentIpAddress", "SysCtrlSystemName", "SysCtrlHousingType", "SysCtrlMMBUnits", "SysCtrlNumberPowerSupplyUnit", _
"SysCtrlNumberFans", "SysCtrlNumberTempSensors", "NumberConnectUnits", "NumberKvmUnits", "SysCtrlOverallStatus", "SysPowerSupplyStatus", "SysFanOverallStatus", "SysTemperatureStatus")

'*** 15 properties / component
PropertyNameList = Array("MgmtBladeId", "MgmtBladeSerialNumber", "MgmtBladeModelName", "MgmtBladeManufacture", "MgmtBladeProductName",_
"MgmtBladeHardwareVersion", "MgmtBladeFirmwareVersion", "MgmtBladePhysicalAddress", "MgmtBladeStatus", "", _
"", "", "", "", "", _
"SysPowerSupplyUnitId", "SysPowerSupplyUnitSerialNumber", "SysPowerSupplyUnitModelName", "SysPowerSupplyUnitProductName", "SysPowerSupplyUnitManufacture", _
"SysPowerSupplyUnitStatus", "", "", "", "",_
"", "", "", "", "", _
"SysFanId", "SysFanDesignation","SysFanCurrentSpeed", "SysFanCurrentMaximumSpeed", "SysFanStatus",_
"", "", "", "", "", _
"", "", "", "", "", _
"SysTempSensorId", "SysTempSensorDesignation", "SysTempCurrentValue", "SysTempSensorStatus", "", _
"", "", "", "", "", _
"", "", "", "", "", _
"SwitchBladeId", "SwitchBladeProductName", "SwitchBladeModelName", "SwitchBladeIpAddress", "SwitchBladeFirmwareVersion", _
"SwitchBladeVersion", "SwitchBladePhysicalAddress", "SwitchBladeSerialNumber", "SwitchBladeManufacture", "SwitchBladeAdministrativeUrl", _
"SwitchBladeStatus", "", "", "", "", _
"KvmBladeId", "KvmBladeManufacture", "KvmBladeSerialNumber", "KvmBladeProductName", "KvmBladeModelName", _
"KvmBladeVersion","KvmBladeIpAddress", "KvmBladeAdministrativeURL", "KvmBladeStatus", "", _
"", "", "", "", "", _
"SvrBladeId", "SvrBladeStatus", "SvrBladeSerialNumber", "SvrBladeProductName", "SvrBladeModelName", _
"SvrBladeHardwareVersion", "SvrBladeFirmwareVersion", "SvrBladeBiosVersion", "SvrBladeOsType", "SvrBladeOsVersion", _
"SvrBladeBiosViomSettingStatus", "SvrHostname", "", "", "", _
"StorageBladeId", "StorageBladeSerialNumber", "StorageBladeProductName", "StorageBladeModelName", "StorageBladeHardwareVersion", _
"StorageBladeStatus", "StorageBladeFWVersion", "StorageBladeHardwareVersion", "StorageBladeAssetTag", "", _
"", "", "", "", "")

Component = KEY_ALL

MonitorNotRunningSetComponentToWarning = false
updateByControlCode = true '*** Note: control code doesn't work on W2K3, see alternative code

'-----------------------------------------------------------------------------------
' Main
'
' Parameters:
' - BC_SerialNumber
' - Component
' - ipAddress
'-----------------------------------------------------------------------------------

Sub Main()

'*** Defines and declares

Dim oArgs, iniVal, SaveBCDebug, nStatus
Dim controlReturn, checkCount, fileUpdated
Dim EnvVar, TEMP, SYSTEMDRIVE, SYSTEMROOT, WINDIR, PROGRAMFILES64
Dim strWhat

'*** Preparations
DebugOut("============= Monitoring ===================")


Set oArgs = WScript.Arguments
Set oDiscoveryEmptyData = Nothing

' extract Environment Variable values
Set WshShell = CreateObject("WScript.Shell")
Set EnvVar = WshShell.Environment("PROCESS")

SYSTEMDRIVE = EnvVar.Item("SYSTEMDRIVE")
If Len(SYSTEMDRIVE) = 0 Then
'try this as default
SYSTEMDRIVE = KEY_SYSTEMDRIVE
End If

SYSTEMROOT = EnvVar.Item("SystemRoot")
WINDIR = EnvVar.Item("windir")

PROGRAMFILES64 = ""
PROGRAMFILES64 = EnvVar.Item("ProgramFiles(x86)")
If Len(PROGRAMFILES64) &gt; 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) &gt; 0 Then
TEMP = WINDIR &amp; "\" &amp; KEY_TEMP
Else
If Len(SYSTEMROOT) &gt; 0 Then
TEMP = SYSTEMROOT &amp; "\" &amp; KEY_TEMP
Else
TEMP = SYSTEMDRIVE &amp; "\" &amp; KEY_WINDOWS &amp; "\" &amp; 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) &gt; 0 AND Len(TEMP) &gt; 0 Then
strLogFileDir = TEMP &amp; "\" &amp; strLogFileSubDir
Else
strLogFileDir = LOGFILEDIR
End If

strLogIniFileDir = strLogFileDir

strLogIniFileName = GetMonSvrRegistryValue(REGKEY_MS_LOGINIFILENAME)
If Len(strLogIniFileName) = 0 Then
strLogIniFileName = LOGINIFILENAME
End If
strLogIniFileNameAbs = strLogIniFileDir &amp; "\" &amp; 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 &gt; 1 Then
If DebugMode = true Then
'*** logfilesdir\PYBladeSystemMonitor_&lt;BCenclosurename&gt;_&lt;component&gt;
strLogFileNameAbs = TEMP &amp; "\" &amp; strLogFileSubDir &amp; "\" &amp; LOGFILENAME &amp; oArgs(0) &amp; "_" &amp; oArgs(1) &amp; ".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 &lt;= 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 = " &amp; BC_SerialNumber &amp; " Component = " &amp; Component &amp; " IpAddress = " &amp; 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: " &amp; strBCCommunicationFile)
DebugOut("Blade System Package DEBUG = " &amp; BCDebug &amp; " (" &amp; SaveBCDebug &amp; ")")
DebugOut("Environment Variable SystemRoot = " &amp; SYSTEMROOT)
DebugOut("Environment Variable WinDir = " &amp; WINDIR)
End If

ProcessOverallStatus = false

MonitorAgentRunning = IsMonitorAgentRunning()

'--------------------------------------------------------------------------------------------------------------------------
'--------------------------------------------------------------------------------------------------------------------------
' Real processing starts here
'--------------------------------------------------------------------------------------------------------------------------
'--------------------------------------------------------------------------------------------------------------------------

If InStr(1,ipAddress, "N/A", 1) &gt; 0 Then

DebugOut("******************** Component not discovered ********************")

If insideMP = true Then
If InStr(1,Component, ComponentsList(COMPLIST_SERVERBLADES), 1) &gt; 0 Then
strWhat = BC_SerialNumber &amp; "_" &amp; ComponentsList(COMPLIST_SERVERBLADES) &amp; "_BladeID_N/A"
Call oPropertyBag.AddValue(strWhat &amp; "_MonitoringState", STATUS_BAD)
ElseIf InStr(1,Component, ComponentsList(COMPLIST_STORAGEBLADES), 1) &gt; 0 Then
strWhat = BC_SerialNumber &amp; "_" &amp; ComponentsList(COMPLIST_STORAGEBLADES) &amp; "_BladeID_N/A"
Call oPropertyBag.AddValue(strWhat &amp; "_MonitoringState", STATUS_BAD)
Else
Call oPropertyBag.AddValue(BC_SerialNumber &amp; "_" &amp; Component &amp; "_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 &amp; "_" &amp; Component &amp; "_MonitoringState", STATUS_BAD)
Call oAPI.Return(oPropertyBag)
WScript.Quit(0)
End If

fileUpdated = SendCommandAndWaitForResponse(BC_SerialNumber, Component, ipAddress)

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) " &amp; strBCCommunicationFile &amp; " - script ends here!"
DebugOut(strEventLogMsg)
If insideMP = true Then
Call oAPI.LogScriptEvent("PYBladeSystemEnclosureMonitor.vbs/" &amp; Component, 501, WARNING_EVENT, strEventLogMsg)
Call oPropertyBag.AddValue(BC_SerialNumber &amp; "_" &amp; Component &amp; "_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 &amp; "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) " &amp; strBCCommunicationFile &amp; " - script ends here!"
DebugOut(strEventLogMsg)
If insideMP = true Then
Call oAPI.LogScriptEvent("PYBladeSystemEnclosureMonitor.vbs/" &amp; Component, 501, WARNING_EVENT, strEventLogMsg)
Call oPropertyBag.AddValue(BC_SerialNumber &amp; "_" &amp; Component &amp; "_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 *************")

End Sub


'--------------------------------------------------------------------------------------------------
' Chassis changed?
'--------------------------------------------------------------------------------------------------

Function EnclosureChanged(sn)

Dim server, receivedSN

Set server = xmlDoc.selectSingleNode("//Server")
receivedSN = server.getAttribute("ChassisSerialNumber")

If StrComp(sn, receivedSN, 1) = 0 Then
EnclosureChanged = false
Else
EnclosureChanged = true
End If

End Function


'--------------------------------------------------------------------------------------------------
' ProcessResponse()
'
' Input Parameter: None
' Output Parameter: None
'--------------------------------------------------------------------------------------------------


Sub ProcessResponse()

Dim NoOfUnits, Unit_i, i
Dim strValue, strModValue, file, strWhat
Dim compListNum, compGroupNum
Dim Compound_HealthState
Dim errors, lastErrorNum

'--------------------------------------------------------------------------------------------------
' Error Code processing
'--------------------------------------------------------------------------------------------------

Set errors = xmlDoc.selectSingleNode("//Server/Errors")
lastErrorNum = CInt(errors.getAttribute("LastErrorCode"))

'*** get chassis number
Call GetBC_Properties(xmlDoc, BladeSystem_No)

'--------------------------------------------------------------------------------------------------
' Enclosure processing
'--------------------------------------------------------------------------------------------------

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: " &amp; Component_HealthState &amp; "/" &amp; Enclosure_MonitoringState)
Else
strEventLogMsg = "The Blade System Monitor Service " &amp; BLADESYSTEMMONITORSERVICE &amp; " is not running!"

If insideMP = true Then
Call oAPI.LogScriptEvent("PYBladeSystemEnclosureMonitor.vbs/" &amp; Component, 503, ERROR_EVENT, strEventLogMsg)
End If
DebugOut(strEventLogMsg)

Component_HealthState = STATUS_UNKNOWN
Enclosure_MonitoringState = STATUS_BAD

End If '*** MonitorAgentRunning = true

'*** Check serial number of the enclosure (maybe changed)
If BEnclosureChanged = true then
strEventLogMsg = "Enclosure has changed " &amp; strBCCommunicationFile &amp; " - script ends here!"
Call oAPI.LogScriptEvent("PYBladeSystemEnclosureMonitor.vbs/" &amp; Component, 502, INFORMATIONAL_EVENT, strEventLogMsg)
Enclosure_MonitoringState = STATUS_BAD
Component_HealthState = STATUS_UNKNOWN
End If

DebugOut("Enclosure_HealthState = " &amp; Enclosure_HealthState)
If insideMP = true Then
Call oPropertyBag.AddValue(BC_SerialNumber &amp; "_" &amp; ComponentsList(COMPLIST_ENCLOSURE) &amp; "_State", Component_HealthState)
Call oPropertyBag.AddValue(BC_SerialNumber &amp; "_" &amp; ComponentsList(COMPLIST_ENCLOSURE) &amp; "_MonitoringState", Enclosure_MonitoringState)
If IsInFailedState(Enclosure_HealthState) Then
Call oPropertyBag.AddValue(BC_SerialNumber &amp; "_" &amp; ComponentsList(COMPLIST_ENCLOSURE) &amp; "_Failed", BLADESYSTEMMONITORSERVICE &amp; " Service")
End If
End If

End If

'--------------------------------------------------------------------------------------------------
' MMB processing
'--------------------------------------------------------------------------------------------------

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: " &amp; NoOfMMBUnits)
End If

NoOfMMBUnitsMonitored = 0
InitStatusArrays()

index = 0
Unit_i = 1
NoOfUnits = NoOfMMBUnits

'*** check all MMB units of this blade server
Do While NoOfUnits &gt; 0

InitPropertyArray()

If GetBCComponent_Properties(BladeSystem_No, BC_ComponentsGroupList(BC_COMP_MMB), Unit_i, MMB + MMB_MIN, MMB_MAX) &gt; 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: " &amp; UnitNumber)
DebugOut("Component: " &amp; Component_Name)
DebugOut("Health State: " &amp; PropertyArray(MMB_STATUS))
DebugOut("Converted Health State: " &amp; Component_HealthState)
End If

componentNameArray(index) = UnitNumber &amp; ": " &amp; Component_Name &amp; "; "
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: " &amp; Unit_i)
End If
End If

NoOfUnits = NoOfUnits - 1
Unit_i = Unit_i + 1
If Unit_i &gt; MAX_MMBCOMPONENT Then
NoOfUnits = 0
End If

Loop

If NoOfMMBUnitsMonitored &gt; 0 Then

For i=0 To index
If Len(componentNameArray(i)) &gt; 0 Then
componentNames = componentNames &amp; componentNameArray(i)
End If
Next

If BCDebug AND BCDEBUG_FEW Then
DebugOut("Monitored Components: " &amp; componentNames)
End If

'*** set overall state of all instances of the component class
If Len(componentNames) &gt; 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 &amp; "_" &amp; ComponentsList(COMPLIST_MMBS)
Call oPropertyBag.AddValue(strWhat &amp; "_State", componentStatus)
Call oPropertyBag.AddValue(strWhat &amp; "_MonitoringState", monitoringStatus)
If IsInFailedState(componentStatus) Then
DebugOut("FAILED: " &amp; strWhat &amp; ": " &amp; failedComponents)
If Len(failedComponents) &gt; 0 Then
Call oPropertyBag.AddValue(strWhat &amp; "_Failed", failedComponents)
End If
End If
End If
End If

'--------------------------------------------------------------------------------------------------
' PSU processing
'--------------------------------------------------------------------------------------------------

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: " &amp; 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 &gt; 0

InitPropertyArray()

If GetBCComponent_Properties(BladeSystem_No, BC_ComponentsGroupList(BC_COMP_POWERSUPPLYUNIT), Unit_i, PSU + PSU_MIN, PSU_MAX) &gt; 0 Then
Component_HealthState = ""
UnitNumber = PropertyArray(PSU_ID)
Component_Name = PropertyArray(PSU_PRODUCTNAME)

If BCDebug AND BCDEBUG_MAX Then
DebugOut("UnitNumber: " &amp; UnitNumber)
DebugOut("Component: " &amp; Component_Name)
End If

'*** calculate failed components
Compound_HealthState = ConvertStatus(CInt(PropertyArray(BC_POWERSUPPLYUNITS)), Component)
componentNameArray(index) = UnitNumber &amp; ": " &amp; Component_Name &amp; "; "
componentStatusArray(index) = Compound_HealthState(0)
monitoringStatusArray(index) = Compound_HealthState(1)

index = index + 1
NoOfPSUnitsMonitored = NoOfPSUnitsMonitored + 1

'*** calculate failed components
Compound_HealthState = ConvertStatus(CInt(PropertyArray(BC_POWERSUPPLYUNITS)), Component)

Else
If BCDebug AND BCDEBUG_MUCH Then
DebugOut("No Properties of PowerSupply Unit: " &amp; Unit_i)
End If
End If

NoOfUnits = NoOfUnits - 1
Unit_i = Unit_i + 1
If Unit_i &gt; MAX_PSUCOMPONENT Then
NoOfUnits = 0
End If
Loop

If NoOfPSUnitsMonitored &gt; 0 Then

For i=0 To index
If Len(componentNameArray(i)) &gt; 0 Then
componentNames = componentNames &amp; componentNameArray(i)
End If
Next

If BCDebug AND BCDEBUG_FEW Then
DebugOut("Monitored Components: " &amp; componentNames)
End If

'*** set failed components
If Len(componentNames) &gt; 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) &amp; "Ovst" Then

If BCDebug AND BCDEBUG_MIN Then
DebugOut("***** Over all state of Power Supply")
End If

If GetBC_Properties(xmlDoc, BladeSystem_No) &gt; 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 &lt;&gt; true And MonitorNotRunningSetComponentToWarning = true Then
componentStatus = STATUS_DEGRADED
failedComponents = BLADESYSTEMMONITORSERVICE
End If

DebugOut("Converted Overall States: " &amp; Component_HealthState &amp; "/" &amp; monitoringStatus)

If (insideMP = true) And (BEnclosureChanged = false) Then
strWhat = BC_SerialNumber &amp; "_" &amp; ComponentsList(COMPLIST_POWERSUPPLIES)
Call oPropertyBag.AddValue(strWhat &amp; "_State", componentStatus)
Call oPropertyBag.AddValue(strWhat &amp; "_MonitoringState", monitoringStatus)
If IsInFailedState(componentStatus) Then
DebugOut("FAILED: " &amp; strWhat &amp; ": " &amp; failedComponents)
If Len(failedComponents) &gt; 0 Then
Call oPropertyBag.AddValue(strWhat &amp; "_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: " &amp; NoOfFanUnits)
End If


NoOfFanUnitsMonitored = 0


InitStatusArrays()

'*** check all fan units of this blade server
index = 0
Unit_i = 1
NoOfUnits = NoOfFanUnits

Do While NoOfUnits &gt; 0

InitPropertyArray()

If GetBCComponent_Properties(BladeSystem_No, BC_ComponentsGroupList(BC_COMP_FANUNIT), Unit_i, FAN + FAN_MIN, FAN_MAX) &gt; 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: " &amp; UnitNumber)
DebugOut("Component: " &amp; Component_Name)
DebugOut("Health State: " &amp; PropertyArray(FAN_STATUS))
DebugOut("Converted Health State: " &amp; Component_HealthState)
End If

componentNameArray(index) = UnitNumber &amp; ": " &amp; Component_Name &amp; "; "
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: " &amp; Unit_i)
End If
End If

NoOfUnits = NoOfUnits - 1
Unit_i = Unit_i + 1
If Unit_i &gt; MAX_FANCOMPONENT Then
NoOfUnits = 0
End If
Loop

If NoOfFanUnitsMonitored &gt; 0 Then

For i=0 To index
If Len(componentNameArray(i)) &gt; 0 Then
componentNames = componentNames &amp; componentNameArray(i)
End If
Next

If BCDebug AND BCDEBUG_FEW Then
DebugOut("Monitored Components: " &amp; componentNames)
End If

If MonitorAgentRunning &lt;&gt; true And MonitorNotRunningSetComponentToWarning = true Then
componentStatus = STATUS_DEGRADED
failedComponents = BLADESYSTEMMONITORSERVICE
End If

'*** set failed components
If Len(componentNames) &gt; 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) &amp; "Ovst" Then

If BCDebug AND BCDEBUG_MIN Then
DebugOut("***** Over all state of Fans")
End If

If GetBC_Properties(xmlDoc, BladeSystem_No) &gt; 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 &lt;&gt; true And MonitorNotRunningSetComponentToWarning = true Then
componentStatus = STATUS_DEGRADED
failedComponents = BLADESYSTEMMONITORSERVICE
End If

DebugOut("Converted Overall State: " &amp; Component_HealthState &amp; "/" &amp; monitoringStatus)

If (insideMP = true) And (BEnclosureChanged = false) = true Then
strWhat = BC_SerialNumber &amp; "_" &amp; ComponentsList(COMPLIST_FANS)
Call oPropertyBag.AddValue(strWhat &amp; "_State", componentStatus)
Call oPropertyBag.AddValue(strWhat &amp; "_MonitoringState", monitoringStatus)
If IsInFailedState(componentStatus) Then
DebugOut("FAILED: " &amp; strWhat &amp; ": " &amp; failedComponents)
If Len(failedComponents) &gt; 0 Then
Call oPropertyBag.AddValue(strWhat &amp; "_Failed", failedComponents)
End If
End If
End If
End If


'--------------------------------------------------------------------------------------------------
' Temp sensor processing
'--------------------------------------------------------------------------------------------------

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: " &amp; 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 &gt; 0

InitPropertyArray()

If GetBCComponent_Properties(BladeSystem_No, BC_ComponentsGroupList(BC_COMP_TEMPSENSORUNIT), Unit_i, TSU + TSU_MIN, TSU_MAX) &gt; 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: " &amp; UnitNumber)
DebugOut("Component: " &amp; Component_Name)
DebugOut("Health State: " &amp; PropertyArray(TSU_STATUS))
DebugOut("Converted Health State: " &amp; Component_HealthState)
End If


componentNameArray(index) = UnitNumber &amp; ": " &amp; Component_Name &amp; "; "
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: " &amp; Unit_i)
End If
End If

NoOfUnits = NoOfUnits - 1
Unit_i = Unit_i + 1
If Unit_i &gt; MAX_TSUCOMPONENT Then
NoOfUnits = 0
End If

Loop

If NoOfTempSensorUnitsMonitored &gt; 0 Then

For i=0 To index
If Len(componentNameArray(i)) &gt; 0 Then
componentNames = componentNames &amp; componentNameArray(i)
End If
Next

If BCDebug AND BCDEBUG_FEW Then
DebugOut("Monitored Components: " &amp; componentNames)
End If

'*** set failed components
If Len(componentNames) &gt; 0 Then
SetCollectionStatus(index)
End If

If MonitorAgentRunning &lt;&gt; 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) &amp; "Ovst" Then

If BCDebug AND BCDEBUG_MIN Then
DebugOut("***** Over all state of temp sensors")
End If

If GetBC_Properties(xmlDoc, BladeSystem_No) &gt; 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 &lt;&gt; true And MonitorNotRunningSetComponentToWarning = true Then
componentStatus = STATUS_DEGRADED
failedComponents = BLADESYSTEMMONITORSERVICE
End If

DebugOut("Converted Overall State: " &amp; Component_HealthState &amp; "/" &amp; monitoringStatus)

If (insideMP = true) And (BEnclosureChanged = false) Then
strWhat = BC_SerialNumber &amp; "_" &amp; ComponentsList(COMPLIST_TEMPSENSORS)
Call oPropertyBag.AddValue(strWhat &amp; "_State", componentStatus)
Call oPropertyBag.AddValue(strWhat &amp; "_MonitoringState", monitoringStatus)
If IsInFailedState(componentStatus) Then
DebugOut("FAILED: " &amp; strWhat &amp; ": " &amp; failedComponents)
If Len(failedComponents) &gt; 0 Then
Call oPropertyBag.AddValue(strWhat &amp; "_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 &gt; 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: " &amp; NoOfCUnits)
End If

NoOfConnectUnitsMonitored = 0

InitStatusArrays()

index = 0
Unit_i = 1
NoOfUnits = NoOfCUnits

'*** check all connection units of this blade server
Do While NoOfUnits &gt; 0

InitPropertyArray()

If GetBCComponent_Properties(BladeSystem_No, BC_ComponentsGroupList(compGroupNum), Unit_i, CU + CU_MIN, CU_MAX) &gt; 0 Then
Component_HealthState = ""
UnitNumber = PropertyArray(CU_ID)
Component_Name = PropertyArray(CU_PRODUCTNAME)

If PropertyArray(CU_STATUS) = "" AND PropertyArray(CU_STATUS) &lt;&gt; "" 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: " &amp; UnitNumber)
DebugOut("Component: " &amp; Component_Name)
DebugOut("Health State: " &amp; PropertyArray(CU_STATUS))
DebugOut("Converted Health State: " &amp; Component_HealthState)
End If


componentNameArray(index) = UnitNumber &amp; ": " &amp; Component_Name &amp; "; "
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 &gt; MAX_CUCOMPONENT Then
NoOfUnits = 0
End If

Loop

If NoOfConnectUnitsMonitored &gt; 0 Then

For i=0 To index
If Len(componentNameArray(i)) &gt; 0 Then
componentNames = componentNames &amp; componentNameArray(i)
End If
Next

If BCDebug AND BCDEBUG_FEW Then
DebugOut("Monitored Components: " &amp; componentNames)
End If

'*** set overall state of all instances of the component class
If Len(componentNames) &gt; 0 Then
SetCollectionStatus(index)
End If

If MonitorAgentRunning &lt;&gt; 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 &amp; "_" &amp; ComponentsList(compListNum)
Call oPropertyBag.AddValue(strWhat &amp; "_State", componentStatus)
Call oPropertyBag.AddValue(strWhat &amp; "_MonitoringState", monitoringStatus)
If IsInFailedState(componentStatus) Then
DebugOut("FAILED: " &amp; strWhat &amp; ": " &amp; failedComponents)
If Len(failedComponents) &gt; 0 Then
Call oPropertyBag.AddValue(strWhat &amp; "_Failed", failedComponents)
End If
End If
End If
End If

'--------------------------------------------------------------------------------------------------
' KVM processing
'--------------------------------------------------------------------------------------------------

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: " &amp; 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 &gt; 0

InitPropertyArray()

If GetBCComponent_Properties(BladeSystem_No, BC_ComponentsGroupList(BC_COMP_KVMUNIT), Unit_i, KVM + KVM_MIN, KVM_MAX) &gt; 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: " &amp; UnitNumber)
DebugOut("Component: " &amp; Component_Name)
DebugOut("Health State: " &amp; PropertyArray(KVM_STATUS))
DebugOut("Converted Health State: " &amp; Component_HealthState)
End If

componentNameArray(index) = UnitNumber &amp; ": " &amp; Component_Name &amp; "; "
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: " &amp; Unit_i)
End If
End If

NoOfUnits = NoOfUnits - 1
Unit_i = Unit_i + 1
If Unit_i &gt; MAX_KVMCOMPONENT Then
NoOfUnits = 0
End If

Loop

If NoOfKVMUnitsMonitored &gt; 0 Then

For i=0 To index
If Len(componentNameArray(i)) &gt; 0 Then
componentNames = componentNames &amp; componentNameArray(i)
End If
Next

If BCDebug AND BCDEBUG_FEW Then
DebugOut("Monitored Components: " &amp; componentNames)
End If

'*** set overall state of all instances of the component class (global variables componentStatus and monitoringStatus are set)
If Len(componentNames) &gt; 0 Then
SetCollectionStatus(index)
End If

If MonitorAgentRunning &lt;&gt; 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 &amp; "_" &amp; ComponentsList(COMPLIST_KVMUNITS)
Call oPropertyBag.AddValue(strWhat &amp; "_State", componentStatus)
Call oPropertyBag.AddValue(strWhat &amp; "_MonitoringState", monitoringStatus)
If IsInFailedState(componentStatus) Then
DebugOut("FAILED: " &amp; strWhat &amp; ": " &amp; failedComponents)
If Len(failedComponents) &gt; 0 Then
Call oPropertyBag.AddValue(strWhat &amp; "_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: " &amp; NoOfServerBlades)
End If

NoOfServerBladesMonitored = 0
InitStatusArrays()

index = 0
Unit_i = 1
NoOfUnits = NoOfServerBlades

If BEnclosureChanged = false Then
'*** check all Server Blades
Do While NoOfUnits &gt; 0

InitPropertyArray()

If GetBCComponent_Properties(BladeSystem_No, BC_ComponentsGroupList(BC_COMP_SERVERBLADE), Unit_i, SRV + SERVER_MIN, SERVER_MAX) &gt; 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 &amp; "_" &amp; ComponentsList(COMPLIST_SERVERBLADES) &amp; "_BladeID_" &amp; UnitNumber

Compound_HealthState = ConvertStatus(CInt(PropertyArray(SERVER_STATUS)), Component)

componentStatusArray(index) = Compound_HealthState(0)
monitoringStatusArray(index) = Compound_HealthState(1)

componentStatus = Compound_HealthState(0)
monitoringStatus = Compound_HealthState(1)

Call oPropertyBag.AddValue(strWhat &amp; "_State", componentStatus)
Call oPropertyBag.AddValue(strWhat &amp; "_MonitoringState", monitoringStatus)

If BCDebug AND BCDEBUG_MAX Then
DebugOut("UnitNumber: " &amp; UnitNumber)
DebugOut("Health State: " &amp; PropertyArray(SERVER_STATUS))
DebugOut("Converted Health State: " &amp; componentStatus)
DebugOut("Converted Monitoring State: " &amp; monitoringStatus)
DebugOut(" ")
End If

index = index + 1
NoOfServerBladesMonitored = NoOfServerBladesMonitored + 1
Else
If BCDebug AND BCDEBUG_MUCH Then
DebugOut("No Properties of Server Blade: " &amp; Unit_i)
End If
End If

NoOfUnits = NoOfUnits - 1
Unit_i = Unit_i + 1
If Unit_i &gt; 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 &amp; "_" &amp; ComponentsList(COMPLIST_SERVERBLADES) &amp; "_BladeID_" &amp; CStr(i)
Call oPropertyBag.AddValue(strWhat &amp; "_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


'--------------------------------------------------------------------------------------------------
' Storage Blade processing
'--------------------------------------------------------------------------------------------------

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: " &amp; NoOfStorageBlades)
End If

NoOfStorageBladesMonitored = 0
InitStatusArrays()

index = 0
Unit_i = 1
NoOfUnits = NoOfStorageBlades

If BEnclosureChanged = false Then
'*** check all Storage Blades
Do While NoOfUnits &gt; 0

InitPropertyArray()

If GetBCComponent_Properties(BladeSystem_No, BC_ComponentsGroupList(BC_COMP_STORAGEBLADE), Unit_i, STR + STORAGE_MIN, STORAGE_MAX) &gt; 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 &amp; "_" &amp; ComponentsList(COMPLIST_STORAGEBLADES) &amp; "_BladeID_" &amp; UnitNumber

Compound_HealthState = ConvertStatus(CInt(PropertyArray(STORAGE_STATUS)), Component)

componentStatusArray(index) = Compound_HealthState(0)
monitoringStatusArray(index) = Compound_HealthState(1)

componentStatus = Compound_HealthState(0)
monitoringStatus = Compound_HealthState(1)

Call oPropertyBag.AddValue(strWhat &amp; "_State", componentStatus)
Call oPropertyBag.AddValue(strWhat &amp; "_MonitoringState", monitoringStatus)

If BCDebug AND BCDEBUG_MAX Then
DebugOut("UnitNumber: " &amp; UnitNumber)
DebugOut("Health State: " &amp; PropertyArray(STORAGE_STATUS))
DebugOut("Converted Health State: " &amp; componentStatus)
DebugOut("Converted Monitoring State: " &amp; monitoringStatus)
DebugOut(" ")
End If

index = index + 1
NoOfStorageBladesMonitored = NoOfStorageBladesMonitored + 1
Else
If BCDebug AND BCDEBUG_MUCH Then
DebugOut("No Properties of Storage Blade: " &amp; Unit_i)
End If
End If

NoOfUnits = NoOfUnits - 1
Unit_i = Unit_i + 1
If Unit_i &gt; 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 &amp; "_" &amp; ComponentsList(COMPLIST_STORAGEBLADES) &amp; "_BladeID_" &amp; CStr(i)
Call oPropertyBag.AddValue(strWhat &amp; "_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 &amp; "\" &amp; strCfgName

If BCDebug AND BCDEBUG_FEW Then
DebugOut("CONFIG file name = " &amp; 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 = " &amp; 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 = " &amp; MonitoringControlCode)
End If

'*** create al list with all monitor agents
strQuery = "Select * from Win32_Service Where Name=""" &amp; BLADESYSTEMMONITORSERVICE &amp; """"
If BCDebug AND BCDEBUG_FUNC OR BCDebug AND BCDEBUG_M_O_D Then
DebugOut(strQuery)
End If

Set objWMIService = GetObject("winmgmts:" &amp; "{impersonationLevel=impersonate}!\\" &amp; strComputer &amp; "\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" &amp; BLADESYSTEMMONITORSERVICE &amp; ": " &amp; result)
End If

'*** error handling
If result &lt;&gt; 0 Then
'*** if error from service control via WMI try another command

CmdBuf = "SC control " &amp; Chr(34) &amp; BLADESYSTEMMONITORSERVICE &amp; Chr(34) &amp;" " &amp; 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 &amp; "\MOD\" &amp; BC_SerialNumber &amp; "." &amp; Component &amp; ".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 " &amp; CmdBuf &amp; " &gt;" &amp; cmdReturnFile, 0, true)

If BCDebug AND BCDEBUG_FUNC OR BCDebug AND BCDEBUG_M_O_D Then
DebugOut("Return code from SC command: " &amp; CmdRet)
End If
result = CmdRet
End If

'*** provide return parameter
MonitoringOnDemand = result

End Function

'--------------------------------------------------------------------------------------------------
' IsMonitorAgentRunning
'
' Input Parameter: None
' Return Parameter: AgentState
'--------------------------------------------------------------------------------------------------

Function IsMonitorAgentRunning()

CONST TargetComputer = "."
Dim Services, Service, AgentState, ServiceFound

If BCDebug AND BCDEBUG_FUNC Then
DebugOut("Check running Monitor Agent " &amp; BLADESYSTEMMONITORSERVICE)
End If

On Error Resume Next
Set Services = GetObject("winmgmts:\\" &amp; TargetComputer &amp; "\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: " &amp; Service.Name)
DebugOut("Service DisplayName: " &amp; Service.DisplayName)
DebugOut("Service State: " &amp; Service.State)
DebugOut("Service Status: " &amp; Service.Status)
DebugOut("Service Started: " &amp; 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 = " &amp; ServiceFound)
End If

IsMonitorAgentRunning = AgentState

End Function


'--------------------------------------------------------------------------------------------------
' GetBladeChassisRegistryValue(strSerNo, strName)
'
' Input Parameter: None
' Output Parameter: None
'--------------------------------------------------------------------------------------------------

Function GetBladeChassisRegistryValue(strSerNo, strName)

GetBladeChassisRegistryValue = GetBCRegistryValue(KEY_BLADE_CHASSIS &amp; "\" &amp; strSerNo &amp; "\" &amp; strName)

End Function

'--------------------------------------------------------------------------------------------------
' GetMonSvrRegistryValue(strName)
'
' Input Parameter: None
' Output Parameter: None
'--------------------------------------------------------------------------------------------------

Function GetMonSvrRegistryValue(strName)

GetMonSvrRegistryValue = GetBCRegistryValue(KEY_MONITOR_SERVICE &amp; "\" &amp; 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 &amp; "\" &amp; strName)

End Function

'--------------------------------------------------------------------------------------------------
' GetBCRegistryValue(strValueName)
'
' Input Parameter:
' - strValueName
' Return Parameter: strValue
'--------------------------------------------------------------------------------------------------

Function GetBCRegistryValue(strValueName)

Dim regPath, strValue

strValue = ""
On Error Resume Next
regPath = BlRegPath &amp; "\" &amp; strValueName
If BCDebug AND BCDEBUG_FUNC Then
DebugOut("regPath = " &amp; regPath)
End If
strValue = WshShell.RegRead(regPath)
On Error Goto 0

If BCDebug AND BCDEBUG_FUNC Then
DebugOut("GetBCRegistryValue() - " &amp; strValueName &amp; " = " &amp; strValue)
End If

GetBCRegistryValue = strValue

End Function

'--------------------------------------------------------------------------------------------------
' GetBladeSystemCommunicationFilePath()
'
' Input Parameter: None
' Return Parameter: strBladeSystemCommFilePath
'--------------------------------------------------------------------------------------------------

Function GetBladeSystemCommunicationFilePath()

Dim filePath, strBladeSystemCommFilePath

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 = " &amp; filePath)
End If
End If

'*** use normal communication file
If Len(filePath) = 0 Then
filePath = GetMonSvrRegistryValue(REGKEY_MS_COMMFILEPATH)
End If


If Len(filePath) &gt; 0 Then
strBladeSystemCommFilePath = filePath
Else
strBladeSystemCommFilePath = BCCOMMFILEPATH
If BCDebug AND BCDEBUG_FUNC Then
DebugOut("CommunicationFilePath by default: " &amp; strBladeSystemCommFilePath)
End If
End If

If BCDebug AND BCDEBUG_MIN Then
DebugOut("CommunicationFilePath: " &amp; strBladeSystemCommFilePath)
End If

GetBladeSystemCommunicationFilePath = strBladeSystemCommFilePath

End Function

'--------------------------------------------------------------------------------------------------
' ConvertStatus(nStatus, Component)
'
' Input Parameter:
' - nStatus
' - Component
' Return Parameter: converted status
'--------------------------------------------------------------------------------------------------

Function ConvertStatus(nStatus, Component)

Dim strStatus

If Component = ComponentsList(COMPLIST_ENCLOSURE) Then '*** s31SysCtrlOverallStatus
Select Case nStatus
Case 0 strStatus = array(STATUS_UNKNOWN, STATUS_BAD) '*** undef
Case 1 strStatus = array(STATUS_UNKNOWN, STATUS_BAD) '*** unknown
Case 2 strStatus = array(STATUS_OK, STATUS_GOOD) '*** OK
Case 3 strStatus = array(STATUS_DEGRADED, STATUS_GOOD) '*** error
Case 4 strStatus = array(STATUS_ERROR, STATUS_GOOD) '*** critical
Case Else strStatus = array(STATUS_UNKNOWN, STATUS_BAD)
End Select
ElseIf Component = ComponentsList(COMPLIST_MMBS) Then '*** s31MgmtBladeStatus
Select Case nStatus
Case 0 strStatus = array(STATUS_UNKNOWN, STATUS_BAD) '*** undef
Case 1 strStatus = array(STATUS_UNKNOWN, STATUS_BAD) '*** unknown
Case 2 strStatus = array(STATUS_OK, STATUS_GOOD) '*** OK
Case 3 strStatus = array(STATUS_UNKNOWN, STATUS_BAD) '*** not-present
Case 4 strStatus = array(STATUS_DEGRADED, STATUS_GOOD) '*** error
Case 5 strStatus = array(STATUS_ERROR, STATUS_GOOD) '*** critical
Case 6 strStatus = array(STATUS_OK, STATUS_GOOD) '*** standby
Case Else strStatus = array(STATUS_UNKNOWN, STATUS_BAD)
End Select
ElseIf Component = ComponentsList(COMPLIST_POWERSUPPLIES) Then '*** s31SysPowerSupplyUnitStatus
Select Case nStatus
Case 0 strStatus = array(STATUS_UNKNOWN, STATUS_BAD) '*** undef
Case 1 strStatus = array(STATUS_UNKNOWN, STATUS_BAD) '*** unknown
Case 2 strStatus = array(STATUS_OK, STATUS_GOOD) '*** OK
Case 3 strStatus = array(STATUS_UNKNOWN, STATUS_BAD) '*** not-present
Case 4 strStatus = array(STATUS_DEGRADED, STATUS_GOOD) '*** error
Case 5 strStatus = array(STATUS_ERROR, STATUS_GOOD) '*** critical
Case 6 strStatus = array(STATUS_OK, STATUS_GOOD) '*** off
Case 7 strStatus = array(STATUS_UNKNOWN, STATUS_GOOD) '*** dummy
Case 8 strStatus = array(STATUS_UNKNOWN, STATUS_GOOD) '*** fanmodule
Case Else strStatus = array(STATUS_UNKNOWN, STATUS_BAD)
End Select
ElseIf Component = ComponentsList(COMPLIST_FANS) Then '*** s31SysFanStatus
Select Case nStatus
Case 0 strStatus = array(STATUS_UNKNOWN, STATUS_BAD) '*** undef
Case 1 strStatus = array(STATUS_UNKNOWN, STATUS_BAD) '*** unknown
Case 2 strStatus = array(STATUS_UNKNOWN, STATUS_BAD) '*** disable
Case 3 strStatus = array(STATUS_OK, STATUS_GOOD) '*** OK
Case 4 strStatus = array(STATUS_ERROR, STATUS_GOOD) '*** fail
Case 5 strStatus = array(STATUS_DEGRADED, STATUS_GOOD) '*** prefailure-predicted
Case 6 strStatus = array(STATUS_DEGRADED, STATUS_GOOD) '*** redundant-fan-failed
Case 7 strStatus = array(STATUS_OK, STATUS_GOOD) '*** not-manageable
Case 8 strStatus = array(STATUS_UNKNOWN, STATUS_BAD) '*** not-present
Case 9 strStatus = array(STATUS_OK, STATUS_GOOD) '*** not-available
Case Else strStatus = array(STATUS_UNKNOWN, STATUS_BAD)
End Select
ElseIf Component = ComponentsList(COMPLIST_TEMPSENSORS) Then
Select Case nStatus
Case 0 strStatus = array(STATUS_UNKNOWN, STATUS_BAD) '*** undef
Case 1 strStatus = array(STATUS_UNKNOWN, STATUS_BAD) '*** unknown
Case 2 strStatus = array(STATUS_UNKNOWN, STATUS_BAD) '*** disable
Case 3 strStatus = array(STATUS_OK, STATUS_GOOD) '*** OK
Case 4 strStatus = array(STATUS_ERROR, STATUS_GOOD) '*** sensor-fail
Case 5 strStatus = array(STATUS_DEGRADED, STATUS_GOOD) '*** warning-temp-warm
Case 6 strStatus = array(STATUS_ERROR, STATUS_GOOD) '*** critical-temp-warm
Case 7 strStatus = array(STATUS_OK, STATUS_GOOD) '*** not-available
Case 8 strStatus = array(STATUS_DEGRADED, STATUS_GOOD) '*** warning-temp-cold(8),
Case 9 strStatus = array(STATUS_ERROR, STATUS_GOOD) '*** critical-temp-cold
Case Else strStatus = array(STATUS_UNKNOWN, STATUS_BAD)
End Select
ElseIf Component = ComponentsList(COMPLIST_TEMPSENSORS) &amp; "Ovst" Then
Select Case nStatus
Case 0 strStatus = array(STATUS_UNKNOWN, STATUS_BAD) '*** undef
Case 1 strStatus = array(STATUS_UNKNOWN, STATUS_BAD) '*** unknown
Case 2 strStatus = array(STATUS_OK, STATUS_GOOD) '*** OK
Case 3 strStatus = array(STATUS_DEGRADED, STATUS_GOOD) '*** degraded
Case 4 strStatus = array(STATUS_ERROR, STATUS_GOOD) '*** critical
Case Else strStatus = array(STATUS_UNKNOWN, STATUS_BAD)
End Select

ElseIf InStr(1,Component,ComponentsList(COMPLIST_CONNECTUNITS), 1) Then '*** s31SwitchBladeStatus
Select Case nStatus
Case 0 strStatus = array(STATUS_UNKNOWN, STATUS_BAD) '*** undef
Case 1 strStatus = array(STATUS_UNKNOWN, STATUS_BAD) '*** unknown
Case 2 strStatus = array(STATUS_OK, STATUS_GOOD) '*** OK
Case 3 strStatus = array(STATUS_UNKNOWN, STATUS_BAD) '*** not-present
Case 4 strStatus = array(STATUS_DEGRADED, STATUS_GOOD) '*** error
Case 5 strStatus = array(STATUS_ERROR, STATUS_GOOD) '*** critical
Case 6 strStatus = array(STATUS_UNKNOWN, STATUS_BAD) '*** standby
Case 7 strStatus = array(STATUS_UNKNOWN, STATUS_GOOD) '*** present
Case Else strStatus = array(STATUS_UNKNOWN, STATUS_BAD)
End Select
ElseIf Component = ComponentsList(COMPLIST_KVMUNITS) Then '*** s31KvmBladeStatus
Select Case nStatus
Case 0 strStatus = array(STATUS_UNKNOWN, STATUS_BAD) '*** undef
Case 1 strStatus = array(STATUS_UNKNOWN, STATUS_BAD) '*** unknown
Case 2 strStatus = array(STATUS_OK, STATUS_GOOD) '*** OK
Case 3 strStatus = array(STATUS_UNKNOWN, STATUS_BAD) '*** not-present
Case 4 strStatus = array(STATUS_DEGRADED, STATUS_GOOD) '*** error
Case 5 strStatus = array(STATUS_ERROR, STATUS_GOOD) '*** critical
Case 6 strStatus = array(STATUS_UNKNOWN, STATUS_GOOD) '*** standby
Case Else strStatus = array(STATUS_UNKNOWN, STATUS_BAD)
End Select
ElseIf Component = ComponentsList(COMPLIST_SERVERBLADES) Then '*** s31SvrBladeStatus
Select Case nStatus
Case 0 strStatus = array(STATUS_UNKNOWN, STATUS_BAD) '*** undef
Case 1 strStatus = array(STATUS_UNKNOWN, STATUS_BAD) '*** unknown
Case 2 strStatus = array(STATUS_OK, STATUS_GOOD) '*** OK
Case 3 strStatus = array(STATUS_UNKNOWN, STATUS_BAD) '*** not-present
Case 4 strStatus = array(STATUS_DEGRADED, STATUS_GOOD) '*** error
Case 5 strStatus = array(STATUS_ERROR, STATUS_GOOD) '*** critical
Case 6 strStatus = array(STATUS_UNKNOWN, STATUS_GOOD) '*** standby
Case Else strStatus = array(STATUS_UNKNOWN, STATUS_BAD)
End Select
ElseIf Component = ComponentsList(COMPLIST_STORAGEBLADES) Then '*** s31StorageBladeStatus
Select Case nStatus
Case 0 strStatus = array(STATUS_UNKNOWN, STATUS_BAD) '*** undef
Case 1 strStatus = array(STATUS_UNKNOWN, STATUS_BAD) '*** unknown
Case 2 strStatus = array(STATUS_OK, STATUS_GOOD) '*** OK
Case 3 strStatus = array(STATUS_UNKNOWN, STATUS_BAD) '*** not-present
Case 4 strStatus = array(STATUS_DEGRADED, STATUS_GOOD) '*** error
Case 5 strStatus = array(STATUS_ERROR, STATUS_GOOD) '*** critical
Case 6 strStatus = array(STATUS_UNKNOWN, STATUS_GOOD) '*** standby
Case Else strStatus = array(STATUS_UNKNOWN, STATUS_BAD)
End Select
ElseIf Component = ComponentsList(COMPLIST_POWERSUPPLIES) &amp; "Ovst" Then
Select Case nStatus
Case 0 strStatus = array(STATUS_UNKNOWN, STATUS_BAD) '*** undef
Case 1 strStatus = array(STATUS_UNKNOWN, STATUS_BAD) '*** unknown
Case 2 strStatus = array(STATUS_OK, STATUS_GOOD) '*** OK
Case 3 strStatus = array(STATUS_DEGRADED, STATUS_GOOD) '*** degraded
Case 4 strStatus = array(STATUS_ERROR, STATUS_GOOD) '*** critical
Case Else strStatus = array(STATUS_UNKNOWN, STATUS_BAD)
End Select
ElseIf Component = ComponentsList(COMPLIST_FANS) &amp; "Ovst" Then
Select Case nStatus
Case 0 strStatus = array(STATUS_UNKNOWN, STATUS_BAD) '*** undef
Case 1 strStatus = array(STATUS_UNKNOWN, STATUS_BAD) '*** unknown
Case 2 strStatus = array(STATUS_OK, STATUS_GOOD) '*** OK
Case 3 strStatus = array(STATUS_DEGRADED, STATUS_GOOD) '*** degraded
Case 4 strStatus = array(STATUS_ERROR, STATUS_GOOD) '*** critical
Case Else strStatus = array(STATUS_UNKNOWN, STATUS_BAD)
End Select
Else strStatus = array(STATUS_UNKNOWN, STATUS_BAD) '*** unknown component

End If

ConvertStatus = strStatus

End Function

'--------------------------------------------------------------------------------------------------
' IsInFailedState(state)
'
' Input Parameter: None
' Output Parameter: None
'--------------------------------------------------------------------------------------------------

Function IsInFailedState(state)
IsInFailedState = false
If state = STATUS_DEGRADED Or state = STATUS_ERROR Then
IsInFailedState = true
End If
End Function

'--------------------------------------------------------------------------------------------------
' GetBC_Properties(xmlDoc, BC_Number)
'
' Input Parameter:
' - xmlDoc
' - BC_Number
' Output Parameter: PropertyArray updated
' Return Parameter: count number of properties
'--------------------------------------------------------------------------------------------------

Function GetBC_Properties(xmlDoc, BC_Number)

Dim strComponent, strValueKey, strValue, count, index

count = 0

strComponent = BC_ComponentsGroupList(BC_COMP_CHASSISINFORMATION)
strValueKey = BC_PropertyNameList(BC_CHASSISSERIALNUMBER)
'read 1st property of component
strValue = GetXMLComponentsPropertyValue(xmlDoc, BC_Number, strComponent, strValueKey)

If BCDebug AND BCDEBUG_FUNC Then
DebugOut("BC Key Value: " &amp; strValueKey &amp; " = " &amp; strValue)
End If

If Len(strValue) &gt; 0 And strValue &lt;&gt; "-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: " &amp; strValueKey &amp; " = " &amp; strValue)
End If
If Len(strValue) &gt; 0 And strValue &lt;&gt; "-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: " &amp; count)
End If

GetBC_Properties = count

End Function

'--------------------------------------------------------------------------------------------------
' GetNoOfBladeSystems(xmlDoc)
'
' Input Parameter:
' xmlDoc
' Output Parameter: 1 (is always 1)
'--------------------------------------------------------------------------------------------------

Function GetNoOfBladeSystems(xmlDoc)

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: " &amp; NoOfBladeSystems)
End If
GetNoOfBladeSystems = NoOfBladeSystems

End Function

'--------------------------------------------------------------------------------------------------
' GetBCComponent_Properties(BC_Number, ComponentName, ComponentNo, key_property_index, property_maxIndex)
'
' Input Parameter:
' - BC_Number
' - ComponentName
' - ComponentNo
' - key_property_index
' - property_maxIndex
' Return Parameter: count
'--------------------------------------------------------------------------------------------------

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 &amp; " " &amp; 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: " &amp; strValueKey &amp; " = " &amp; strValue)
End If

If Len(strValue) &gt; 0 And strValue &lt;&gt; "-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 &amp; " = " &amp; strValue)
End If
If Len(strValue) &gt; 0 And strValue &lt;&gt; "-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: " &amp; count)
End If

GetBCComponent_Properties = count

End Function


'--------------------------------------------------------------------------------------------------
' CheckSimulationMode(FilePathName)
'
' Input Parameter: FilePathName
' Output Parameter: None
'--------------------------------------------------------------------------------------------------

Function CheckSimulationMode(FilePathName)

Dim iniVal, simMode

If BCDebug AND BCDEBUG_FUNC Then
DebugOut("CheckSimulationMode(" &amp; FilePathName &amp; ")")
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

CheckSimulationMode = simMode

End Function

'--------------------------------------------------------------------------------------------------
' GetXMLComponentsPropertyValue(xmlDoc, nServerNo, strComponent, strPropertyName)
'
' Input Parameter:
' - xmlDoc
' - nServerNo
' - strComponent
' - strPropertyName
' Output Parameter: None
'--------------------------------------------------------------------------------------------------

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: " &amp; nServerNo &amp; "/" &amp; strComponent &amp; "/" &amp; 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.: " &amp; 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 = " &amp; xmlNameOfComponent)
If xmlNameOfComponent = strComponent Then
Set xmlComponentNode = xmlServerNode.childNodes.Item(j)
'DebugOut("No of Components subelements: " &amp; xmlComponentNode.childNodes.length)

For k=0 To xmlComponentNode.childNodes.length-1
Set xmlElementListNode = xmlComponentNode.childNodes.Item(k)
'DebugOut("No of ListElements: " &amp; xmlElementListNode.childNodes.length)
varPropertyValue = ""
bValueInComponentNode = false
For l=0 To xmlElementListNode.childNodes.length-1
If xmlElementListNode.childNodes.item(l).childNodes.length &gt; 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 &amp; "=[" &amp; _
xmlElementListNode.childNodes.item(l).childNodes.item(1).Text &amp; "]")
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 '" &amp; strPropertyName &amp; "' 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(" &amp; FilePathName &amp; ", " &amp; Section &amp; ", " &amp; KeyValue &amp; ")")
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 " &amp; FilePathName &amp; " does not exist!")
End If
End If

On Error Goto 0

If BCDebug AND BCDEBUG_FUNC Then
DebugOut("IniValue = " &amp; 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: [" &amp; hFile &amp; "]")
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 &lt; 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 &amp; ", " &amp; Section &amp; ", " &amp; KeyValue &amp; " = " &amp; value)
End If

GetIniValue = value

End Function


'--------------------------------------------------------------------------------------------------
' CheckNumberOfRegisteredComponents(strSerNo, strComponent, newValue)
'
' Input Parameter:
' - strSerNo
' - strComponent
' - newValue
' Output Parameter: None
'--------------------------------------------------------------------------------------------------

Sub CheckNumberOfRegisteredComponents(strSerNo, strComponent, newValue)

Dim strValue, strModValue, strWhat, oldValue


strValue = GetBladeChassisRegistryValue(strSerNo, strComponent)
if Len(strValue) &gt; 0 Then
oldValue = CInt(strValue)
Else
oldValue = 0
End If

strWhat = strSerNo &amp; "_" &amp; strComponent


If newValue &lt;&gt; oldValue Then
'*** did we have a different value already?
strModValue = GetBladeChassisRegistryValue(strSerNo, strComponent &amp; KEY_REG_MODIFIED)
If Len(strModValue) &gt; 0 Then

'*** we had a different value already - has it become more (INFO) or less (ERROR)?
If CInt(newValue) &lt; CInt(oldValue) Then
'*** we lost one (or some) ...
componentStatus = STATUS_ERROR
If insideMP = true Then
strValue = GetBladeChassisRegistryValue(strSerNo, strComponent &amp; KEY_REG_LOST_WRITTEN)
If Len(strValue) = 0 Then
strEventLogMsg = "lost " &amp; oldValue - newValue &amp; " " &amp; strComponent &amp; "(s)"
Call oAPI.LogScriptEvent("PYBladeSystemEnclosureMonitor.vbs/" &amp; strSerNo, 505, ERROR_EVENT, strEventLogMsg)
Call PutBladeChassisRegistryValue(strSerNo, strComponent &amp; KEY_REG_LOST_WRITTEN, 1)
DebugOut("LOST COMPONENT: " &amp; strWhat &amp; ": Number changed from " &amp; oldValue &amp; " to " &amp; newValue)
End If
End If
Else
If insideMP = true Then
strValue = GetBladeChassisRegistryValue(strSerNo, strComponent &amp; KEY_REG_FOUND_WRITTEN)
If Len(strValue) = 0 Then
strEventLogMsg = "found " &amp; oldValue - newValue &amp; " new " &amp; strComponent &amp; "(s)"
Call oAPI.LogScriptEvent("PYBladeSystemEnclosureMonitor.vbs/" &amp; strSerNo, 506, INFORMATIONAL_EVENT, strEventLogMsg)
Call PutBladeChassisRegistryValue(strSerNo, strComponent &amp; KEY_REG_FOUND_WRITTEN, 1)
End If
End If
DebugOut("COMPONENT ADDED: " &amp; strWhat &amp; ": Number changed from " &amp; oldValue &amp; " to " &amp; newValue)
DeleteBladeChassisRegistryValue(strSerNo &amp; "\" &amp; strComponent &amp; KEY_REG_MODIFIED)
'*** set new value
Call PutBladeChassisRegistryValue(strSerNo, strComponent, newValue)
End If
Else
'*** give it one RETRY (next pass)
Call PutBladeChassisRegistryValue(strSerNo, strComponent &amp; KEY_REG_MODIFIED, newValue)
End If
Else
DeleteBladeChassisRegistryValue(strSerNo &amp; "\" &amp; strComponent &amp; KEY_REG_MODIFIED)
DeleteBladeChassisRegistryValue(strSerNo &amp; "\" &amp; strComponent &amp; KEY_REG_FOUND_WRITTEN)
DeleteBladeChassisRegistryValue(strSerNo &amp; "\" &amp; strComponent &amp; KEY_REG_LOST_WRITTEN)
End If

If insideMP = true Then
Call oPropertyBag.AddValue(strWhat &amp; "_State", componentStatus)
Call oPropertyBag.AddValue(strWhat &amp; "_MonitoringState", monitoringStatus)
If IsInFailedState(componentStatus) Then
DebugOut("FAILED: " &amp; strSerNo &amp; " + " &amp; strComponent &amp; ": " &amp; failedComponents)
If Len(failedComponents) &gt; 0 Then
Call oPropertyBag.AddValue(strWhat &amp; "_Failed", failedComponents)
End If
End If
If CInt(newValue) &lt; CInt(oldValue) Then
strValue = GetBladeChassisRegistryValue(strSerNo, strComponent &amp; KEY_REG_LOST_WRITTEN)
If Len(strValue) &gt; 0 Then
DebugOut("DIFFERENCE: " &amp; strSerNo &amp; " + " &amp; strComponent &amp; ": " &amp; oldValue &amp; " --&gt; " &amp; newValue)
Call oPropertyBag.AddValue(strWhat &amp; "_Lost", oldValue - newValue &amp; " " &amp; strComponent)
End If
End If
End If


End Sub

'--------------------------------------------------------------------------------------------------
' InitPropertyArray()
'
' Input Parameter: None
' Output Parameter: None
'--------------------------------------------------------------------------------------------------

Sub InitPropertyArray()

'**** property array for the properties of ONE component instance
PropertyArray = Array("", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "")

End Sub

'--------------------------------------------------------------------------------------------------
' InitStatusArrays()
'
' Input Parameter: None
' Output Parameter: None
'--------------------------------------------------------------------------------------------------

Sub InitStatusArrays()

'*** MAXINDEX (64) elements in every array available ***

componentNameArray = array("", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "")

componentStatusArray = array("", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "")

monitoringStatusArray = array("", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "")

componentNames = ""
componentStatus = ""
'*** monitoringStatus = ""

End Sub

'--------------------------------------------------------------------------------------------------
' SetCollectionStatus(maxindex)
'
' Input Parameter:
' - maxindex
' - componentStatusArray
' - monitoringStatusArray
' Output Parameter:
' - componentStatus
' - monitoringStatus
'
'--------------------------------------------------------------------------------------------------

Sub SetCollectionStatus(maxindex)
Dim i

componentStatus = STATUS_UNKNOWN
'*** monitoringStatus = STATUS_GOOD

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 " &amp; i &amp; ": &lt;" &amp; componentNameArray(i) &amp; "&gt;")
DebugOut("Status of Component at index " &amp; i &amp; ": &lt;" &amp; componentStatusArray(i) &amp; "&gt;")
End If

If (Len(componentNameArray(i)) &gt; 0) And (Len(componentStatusArray(i)) &gt; 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)) &gt; 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 " &amp; i &amp; ": &lt;" &amp; componentNameArray(i) &amp; "&gt;")
DebugOut("Status of Component at index " &amp; i &amp; ": &lt;" &amp; componentStatusArray(i) &amp; "&gt;")
End If

If Len(componentNameArray(i)) &gt; 0 And Len(componentStatusArray(i)) &gt; 0 Then
If componentStatusArray(i) = STATUS_DEGRADED Then
failedComponents = failedComponents &amp; componentNameArray(i)
ElseIf componentStatusArray(i) = STATUS_ERROR Then
failedComponents = failedComponents &amp; componentNameArray(i)
ElseIf monitoringStatusArray(i) = STATUS_BAD Then
failedComponents = failedComponents &amp; 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: " &amp; componentStatus)
DebugOut("Failed Component/s: " &amp; failedComponents)
End If
End Sub

'--------------------------------------------------------------------------------------------------
' GetLogFileIni(FilePathName, Section)
'
' Input Parameter: None
' Output Parameter: None
'--------------------------------------------------------------------------------------------------

Sub GetLogFileIni(FilePathName, Section)

Dim val

val = GetOpenIniValue(FilePathName, Section, INIKEY_DEBUGMODE)

If val = "yes" OR val = "YES" OR val = "1" Then
DebugMode = true
DebugFile = true
End If

End Sub

'--------------------------------------------------------------------------------------------------
' PutBladeChassisRegistryValue(strSerNo, strName, strValue)
'
' Input Parameter: None
' Output Parameter: None
'--------------------------------------------------------------------------------------------------

Sub PutBladeChassisRegistryValue(strSerNo, strName, strValue)

Call PutBCRegistryValue(KEY_BLADE_CHASSIS &amp; "\" &amp; strSerNo &amp; "\" &amp; strName, strValue)

End Sub

'--------------------------------------------------------------------------------------------------
' PutBCRegistryValue(strValueName, strValue)
'
' Input Parameter: None
' Output Parameter: None
'--------------------------------------------------------------------------------------------------

Sub PutBCRegistryValue(strValueName, strValue)

Dim regPath
Dim strReadValue

On Error Resume Next
regPath = BlRegPath &amp; "\" &amp; strValueName
If BCDebug AND BCDEBUG_FUNC Then
DebugOut("regPath = " &amp; regPath)
End If
strReadValue = WshShell.RegRead(regPath)
'*** avoid WRITE, if possible
If CString(strReadValue) &lt;&gt; CString(strValue) Then
Call WshShell.RegWrite(regPath, strValue)
End If
On Error Goto 0

If BCDebug AND BCDEBUG_FUNC Then
DebugOut("PutBCRegistryValue() - " &amp; strValueName &amp; " = " &amp; strValue &amp; " done.")
End If

End Sub

'--------------------------------------------------------------------------------------------------
' DeleteBladeChassisRegistryValue(strName)
'
' Input Parameter: None
' Output Parameter: None
'--------------------------------------------------------------------------------------------------

Sub DeleteBladeChassisRegistryValue(strName)

DeleteBCRegistryValue(KEY_BLADE_CHASSIS &amp; "\" &amp; strName)

End Sub

'--------------------------------------------------------------------------------------------------
'DeleteBCRegistryValue(strValueName)
'
' Input Parameter: None
' Output Parameter: None
'--------------------------------------------------------------------------------------------------

Sub DeleteBCRegistryValue(strValueName)

Dim regPath
Dim strReadValue

On Error Resume Next
regPath = BlRegPath &amp; "\" &amp; strValueName
If BCDebug AND BCDEBUG_FUNC Then
DebugOut("regPath = " &amp; regPath)
End If
strReadValue = WshShell.RegRead(regPath)
If Len(strReadValue) &gt; 0 Then
Call WshShell.RegDelete(regPath)
End If
On Error Goto 0

If BCDebug AND BCDEBUG_FUNC Then
DebugOut("DeleteBCRegistryValue() - " &amp; strValueName &amp; " done.")
End If

End Sub

'--------------------------------------------------------------------------------------------------
' CreateLogFile(strLogFileName, isLogFile)
'
' Input Parameter: None
' Output Parameter: None
'--------------------------------------------------------------------------------------------------

Sub CreateLogFile(strLogFileName, isLogFile)

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 &amp; strLogFileName &amp; " ** " &amp; systemTime &amp; " **********"
sMPVersion = "MP Version: " &amp; 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

DebugFile = true

DebugOut("Monitor 1")

On Error Goto 0

DebugOut("Monitor 2")

End Sub

'--------------------------------------------------------------------------------------------------
' DebugOut(Text)
'
' Input Parameter: None
' Output Parameter: None
'--------------------------------------------------------------------------------------------------

Sub DebugOut(Text)

Dim sMessage
Dim oTextStream 'As Scripting.TextStream
Dim oFSO 'As Scripting.FileSystemObject
Dim TimeSeconds

If (DebugMode = true) AND (DebugConsole = true) Then
sMessage = "***DebugOut: " &amp; Text &amp; vbCrLf
WScript.Echo sMessage
End If

If DebugFile = true Then
TimeSeconds = Time()
sMessage = TimeSeconds &amp; ": " &amp; Text

On Error Resume Next

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oTextStream = oFSO.OpenTextFile(strLogFileNameAbs, 8, True) ' 8 = append
oTextStream.WriteLine sMessage
oTextStream.Close

On Error Goto 0

End If

End Sub

'--------------------------------------------------------------------------------------------------
' CleanUpTimeFile(strText)
'
' Input Parameter: None
' Output Parameter: None
'--------------------------------------------------------------------------------------------------

Function CleanUpTimeFile(strText)

Dim FSO1


DebugOut(strText)

Set FSO1 = CreateObject("Scripting.FileSystemObject")

On Error Resume Next

If FSO1.FileExists(TimeFile) = TRUE Then
Call FSO1.DeleteFile(TimeFile, TRUE)
End If

On Error Goto 0

WScript.Sleep(WAITING_TIME)
Set FSO1 = Nothing

End Function

'--------------------------------------------------------------------------------------------------
' GetConfigFileEntry(ConfigFileEntry)
'
' Input Parameter: None
' Output Parameter: None
'--------------------------------------------------------------------------------------------------

Function GetConfigFileEntry(ConfigFileEntry)
Dim xmlCfgDoc, cfgFileLoaded, xmlCfgDocElem, xmlMonitorNode
Dim strCfgPath, strCfgName, strCfgAbsName
Dim checkCount


GetConfigFileEntry = ""


strCfgPath = GetMonSvrRegistryValue(REGKEY_MS_CONFIGFILEPATH)
strCfgName = GetMonSvrRegistryValue(REGKEY_MS_CONFIGFILENAME)

If Len(strCfgPath) &gt; 0 AND Len(strCfgName) &gt; 0 Then

strCfgAbsName = strCfgPath &amp; "\" &amp; strCfgName

If BCDebug AND BCDEBUG_FEW Then
DebugOut("CONFIG file name = " &amp; 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 = " &amp; cfgFileLoaded)
End If

if cfgFileLoaded Then

On Error Resume Next

Set xmlCfgDocElem = xmlCfgDoc.documentElement
Set xmlMonitorNode = xmlCfgDocElem.selectNodes(ConfigFileEntry)
GetConfigFileEntry = xmlMonitorNode.item(0).Text

On Error Goto 0
End If

End If

End Function

'--------------------------------------------------------------------------------------------------
' DebOut(Text)
'
' Input Parameter: None
' Output Parameter: None
'--------------------------------------------------------------------------------------------------

Sub DebOut(Text)

Dim sMessage
Dim oTextStream 'As Scripting.TextStream
Dim oFSO 'As Scripting.FileSystemObject
Dim TimeSeconds

If DebugFile = true Then
TimeSeconds = Time()
sMessage = TimeSeconds &amp; ": " &amp; 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

On Error Goto 0
End If
End Sub


'--------------------------------------------------------------------------------------------------
' SendCommandAndWaitForResponse(ChassisSN, component)
'
' Input Parameter:
' - fileName
' Output Parameter: None
'--------------------------------------------------------------------------------------------------

Function SendCommandAndWaitForResponse(ChassisSN, component, ipAdr)

Dim fileUpdated, loopCount
Dim controlReturn
Dim discoveryOngoing

DebugOut("Start: SendCommandAndWaitForResponse(" &amp; ChassisSN &amp; ", " &amp; component &amp;") ...")

fileUpdated = FALSE
oldResponseCouldBeUsed = False

If MonitorAgentRunning = true And updateByControlCode = true Then

DebugOut("SendCommandAndWaitForResponse / BSMA running")

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 &lt;= 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 =&gt; 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()

loopCount = TIMEOUT_RESPONSEFILE_300_IN_S / 5
DebugOut("SendCommandAndWaitForResponse / wait for response file")

Do Until fileUpdated OR (loopCount &lt;= 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 = " &amp; fileUpdated)

End Function


Function GetCommunicationFile(ChassisSN, component)

Dim commFile
Dim getFile

DebugOut("Start: GetCommunicationFile(" &amp; ChassisSN &amp; ", " &amp; component &amp;") ...")

getFile = true

Set xmlDoc = CreateObject("Msxml2.DOMDocument")
xmlDoc.async = false

commFile = ComposeFilename(ChassisSN, component, FILETYPE_RESPONSE)
getFile = xmlDoc.load(commFile)

If xmlDoc.parseError.errorCode &lt;&gt; 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 &lt;&gt; 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 &lt;&gt; 0 Then
DebugOut("-- GetCommunicationFile: parse error when reading response file")
getFile = false
End If

GetCommunicationFile = getFile
DebugOut("GetCommunicationFile = " &amp; getFile)

End Function

Function GetCommunicationFileOld(ChassisSN, component)

Dim commFile
Dim getFile

DebugOut("Start: GetCommunicationFile(" &amp; ChassisSN &amp; ", " &amp; component &amp;") ...")

getFile = true

Set xmlDoc = CreateObject("Msxml2.DOMDocument")
xmlDoc.async = false

commFile = ComposeFilename(ChassisSN, component, FILETYPE_RESPONSE_OLD)
getFile = xmlDoc.load(commFile)

If xmlDoc.parseError.errorCode &lt;&gt; 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 &lt;&gt; 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 &lt;&gt; 0 Then
DebugOut("-- GetCommunicationFile: parse error when reading response file")
getFile = false
End If

GetCommunicationFileOld = getFile
DebugOut("GetCommunicationFile = " &amp; getFile)

End Function


Function IsFileExisting(ChassisSN, component, fileType)

Dim fileExists
Dim FSO1
Dim tmpFile

DebugOut("Start: IsFileExisting(" &amp; ChassisSN &amp; ", " &amp; component &amp;") ...")

Set FSO1 = CreateObject("Scripting.FileSystemObject")

tmpFile = ComposeFilename(ChassisSN, component, fileType)

If FSO1.FileExists(tmpFile) = true Then
fileExists = true
Else
fileExists = false
End If

Set FSO1 = Nothing
IsFileExisting = fileExists

End Function


Function DeleteFile(ChassisSN, component, fileType)

Dim FSO1
Dim tmpFile

DebugOut("Start: DeleteFile(" &amp; ChassisSN &amp; ", " &amp; component &amp;") ...")

Set FSO1 = CreateObject("Scripting.FileSystemObject")

tmpFile = ComposeFilename(ChassisSN, component, fileType)
Call FSO1.DeleteFile(tmpFile, TRUE)

Set FSO1 = Nothing
DeleteFile = TRUE

End Function


'--------------------------------------------------------------------------------------------------
' 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 &gt; acc1 Then
acc1 = mod1
End If

diffsec = datediff("s",acc1, now())

If diffsec &gt; timeout Then
fileOutOfDate = true
Else
fileOutOfDate = false
End If
End If
IsFileOutOfDate = fileOutOfDate

Set FSO = Nothing

DebugOut("IsFileOutOfDate = " &amp; 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 &lt; 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(" &amp; ChassisSN &amp; ", " &amp; component &amp;") ...")


Select Case fileType
Case FILETYPE_RESPONSE
tmpFile = BladeSystemCommunicationFilePath &amp; "\Blade_" &amp; ChassisSN &amp; "_" &amp; component &amp; "Mon_" &amp; "comm.xml"
Case FILETYPE_RESPONSE_OLD
tmpFile = BladeSystemCommunicationFilePath &amp; "\OLD\Blade_" &amp; ChassisSN &amp; "_" &amp; component &amp; "Mon_" &amp; "comm.xml"
Case FILETYPE_CMD
tmpFile = BladeSystemCommunicationFilePath &amp; "\CMD_" &amp; ChassisSN &amp; "_" &amp; component &amp; "Mon" &amp; ".xml"
Case FILETYPE_CMD_DISCOVERY
tmpFile = BladeSystemCommunicationFilePath &amp; "\CMD_" &amp; ChassisSN &amp; "_" &amp; component &amp; "Dis" &amp; ".xml"
Case FILETYPE_CMD_TEMPLATE
tmpFile = BladeSystemCommunicationFilePath &amp; "\TEMPLATE\CMD_Template_" &amp; component &amp; "Mon" &amp; ".xml"
Case Else
'*** wrong file type
End Select

ComposeFilename = tmpFile
DebugOut("ComposeFilename = " &amp; 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

templFile = ComposeFilename("", component, FILETYPE_CMD_TEMPLATE)
xmlCMDDoc.load(templFile)

If xmlCMDDoc.parseError.errorCode &lt;&gt; 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: " &amp; BC_SerialNumber &amp; "/" &amp; Component
Call oAPI.LogScriptEvent("PYBladeSystemEnclosureMonitor.vbs/" &amp; Component, 599, ERROR_EVENT, strEventLogMsg)

End Sub

'****************************************************************
'****************************************************************
'****************************************************************

Main()

'****************************************************************
'****************************************************************
'****************************************************************
'****************************************************************
</Script></Contents>
</File>
</Files>
</DataSource>
</MemberModules>
<Composition>
<Node ID="DS"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.PropertyBagData</OutputType>
</DataSourceModuleType>