Fujitsu PRIMERGY BladeSystem Enclosure DiscoveryDataSource

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

Discovery Source Code.

Element properties:

TypeDataSourceModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
OutputTypeSystem.Discovery.Data

Member Modules:

ID Module Type TypeId RunAs 
DS DataSource System.CommandExecuterDiscoveryDataSource Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
IntervalSecondsint$Config/IntervalSeconds$Fujitsu PRIMERGY BladeSystem Enclosure DiscoveryDataSource Interval SecondsFujitsu PRIMERGY BladeSystem Enclosure DiscoveryDataSource Interval Seconds

Source Code:

<DataSourceModuleType ID="Fujitsu.PRIMERGY.BladeSystem.Enclosure.DiscoveryDataSource" Accessibility="Internal" Batching="false">
<Configuration>
<xsd:element minOccurs="1" name="IntervalSeconds" type="xsd:integer"/>
<xsd:element minOccurs="0" name="DiscoveryPreference" type="xsd:string"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<DataSource ID="DS" TypeID="System!System.CommandExecuterDiscoveryDataSource">
<IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
<ApplicationName>%windir%\System32\cscript.exe</ApplicationName>
<WorkingDirectory/>
<CommandLine>$file/PYBladeSystemEnclosureDiscovery.vbs$ $MPElement$ $Target/Id$ $Target/Property[Type="FTSLIB!Fujitsu.ServerView.MonitorService"]/PrincipalName$ $Target/Property[Type="FTSLIB!Fujitsu.ServerView.ManagementServerSoftware"]/ServerName$ $Config/DiscoveryPreference$</CommandLine>
<TimeoutSeconds>2400</TimeoutSeconds>
<RequireOutput>true</RequireOutput>
<Files>
<File>
<Name>PYBladeSystemEnclosureDiscovery.vbs</Name>
<Contents><Script>

'----------------------------------------------------------------------
'-DISCOVERY-DISCOVERY-DISCOVERY-DISCOVERY-DISCOVERY-DISCOVERY-DISCOVERY
'----------------------------------------------------------------------
' Fujitsu Limited
' Copyright 2017 FUJITSU LIMITED
' PYBladeSystemEnclosureDiscovery.vbs
' $MPElement$
' $Target/Id$
' $Target/Property[Type="FTSLIB!Fujitsu.ServerView.MonitorService"]/PrincipalName$
' $Target/Property[Type="FTSLIB!Fujitsu.ServerView.ManagementServerSoftware"]/ServerName$
' $Config/DiscoveryPreference$
'
' Summary:
' Discover Fujitsu PRIMERGY BladeSystem (respectively the MMBs)
'
' Remarks:
' - BL = Blade (management) Pack
' - BC = Blade Chassis (mostly meant: the MMB, or the whole chassis)
'
'-------------------------------------------------------------------
Option Explicit

SetLocale("en-us")

Const MPVERSION = "*** 8.0.4.0 ***"

'--------------------------------------------
Dim insideMP
'insideMP = false 'only for test outside MP
insideMP = true 'script runs inside MP
'--------------------------------------------
' Search patterns, e.g. important functions:
' MonitorCommandAndCheckCommfile
'--------------------------------------------

Dim DebugMode
Dim DebugFile
Dim DebugConsole

DebugMode = false '*** enables Deug generally, may be overrided by inifile
DebugFile = false '*** set to "true" if logfile has been created
DebugConsole = false '*** enables console output for debug

'--------------------------------------------
' 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_BLADESYSTEMDISCOVERY = "BladeSystemDiscovery"
'
' 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 BCNUM_MAX_INDEX = 49 ' maximum index for supported enclosures
CONST BC_MAX_NUM = 50 ' maximum number of supported enclosures
CONST BCDEBUG_MIN = 1 ' 0x0001
CONST BCDEBUG_MAX = 2 ' 0x0004
CONST BCDEBUG_FUNC = 16 ' 0x0010 "Function ...()"

'--------------------------------------------
Dim Registry
Const HKEY_LOCAL_MACHINE = &amp;H80000002

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

Dim ErrorsDetected
ErrorsDetected = false

Dim ExitOnMonitorServiceNotRunning '*** true: script quits if monitor service is not running
ExitOnMonitorServiceNotRunning = true

Dim updateByControlCode
updateByControlCode = true '*** disabled because control code doesn't work on W2K3


CONST INISEC_BLADESYSTEMDISCOVERY = "BladeSystemDiscovery"
CONST INISEC_COMMUNICATIONFILE = "CommunicationFile"

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


CONST KEY_BLADE_CHASSIS = "BladeChassis"
CONST KEY_CONTROLCODE = "ControlCode"
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_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_RESP = 4
CONST FILETYPE_MNGD_NODES = 5
CONST FILETYPE_MON_RESPONSE = 6
CONST FILETYPE_CFG_TEMPLATE = 7
CONST FILETYPE_CFG_OUTPUT = 8


Dim absDiscoveryFileName, absDiscoveryDoneFileName


' path to "SVISCOM-BL" in registry
CONST BL_REG_PATH = "SOFTWARE\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_LOGFILESUBDIR = "LogFileSubDir"
CONST REGKEY_MS_LOGINIFILENAME = "LogIniFileName"
CONST REGKEY_MS_MANAGEDFILENAME = "ManagedFileName"


' Use the "WMI" name!
CONST BLADESYSTEMMONITORSERVICE = "PRIMERGYBladeSystemMonitor"


'*** absolute default name of communication file (if it cannot be determined else)
CONST ABSBCCOMMFILE = "C:\Program Files\Fujitsu\ServerView Suite\SCOM Integration\SVISCOM-BL\MonitorService\comm\ManagedPRIMERGYBlades.xml"



'*** LOG files and the LOG INI file are stored here:

'*** default name of log file subdirectory
CONST LOGFILESUBDIR = "SVISCOM\SVISCOM-BL"
'*** default name of log file path (if it cannot be determined else)
CONST LOGFILEDIR = "C:\Windows\Temp\SVISCOM\SVISCOM-BL"
'*** Note: This path is assembled during runtime!
'*** For the beginning of the path the system environment variable "TEMP" (usually: C:\Windows)
'*** is used, e.g. if OS is NOT installed in partition "C:" or subdir "Windows",
'*** and for the end the reg key value of "REGKEY_MS_LOGFILESUBDIR"!

'*** default name of log file name
CONST LOGFILENAME = "PYBladeSystemDiscovery_"

'*** default name of log ini file name
CONST LOGINIFILENAME = "SVISCOM-BL.Log.ini"



Dim strLogIniFileDir, strLogIniFileName, strLogIniFileNameAbs
Dim strLogFileSubDir, strLogFileDir, strLogFileNameAbs
Dim Computer, simulationMode

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

CONST strDebugFilePath = "D:\Windows\Temp\SVISCOM\SVISCOM-BL\DEBUG\out.log"

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

CONST CONTROLCODE_MONITORING = 201
CONST CHECKCOUNTMAX = 500
CONST CHECKCOUNTMIN = 5
CONST WAITING_TIME = 1000
CONST WAIT_5S = 5000
CONST MONITORING_TIMEOUT = 750 '* 750s

CONST cMAXINDEX = 102

'*** index for string array "BC_ComponentsGroupList"
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 = 13

CONST BC_SUBCOMP_ETHCONNECTUNIT = 0
CONST BC_SUBCOMP_IBCONNECTUNIT = 1
CONST BC_SUBCOMP_SASCONNECTUNIT = 2
CONST BC_SUBCOMP_FCCONNECTUNIT = 3
CONST BC_SUBCOMP_FCPTCONNECTUNIT = 4
CONST BC_SUBCOMP_PTCONNECTUNIT = 5
CONST BC_SUBCOMP_CCU_MAX = 5

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_RACKNAME = 11
CONST BC_HTTP_PORT = 12
CONST BC_SYSLOCATION = 13
CONST BC_SYSCONTACT = 14

CONST BC_MIN = 0
CONST BC_MAX = 14


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_SERVERBLADES = 18
CONST MAX_STORAGEBLADES= 18

'CONST MAX_BX900_MMBCOMPONENT = 2
'CONST MAX_BX900_PSUCOMPONENT = 4
'CONST MAX_BX900_FANCOMPONENT = 64
'CONST MAX_BX900_TSUCOMPONENT = 24
'CONST MAX_BX900_CUCOMPONENT = 4
'CONST MAX_BX900_KVMCOMPONENT = 4


CONST MMB = 0
CONST PSU = 20
CONST FAN = 40
CONST TSU = 60
CONST CU = 80
CONST KVM = 100
CONST SRV = 120
CONST STR = 140


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_REDUNDANCY = 6

CONST PSU_MIN = 0
CONST PSU_MAX = 6

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 holding 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 TSU_STATUS_WARN_COLD = 8
CONST TSU_STATUS_CRITICAL_COLD = 9


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 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 SERVER_ID = 0
CONST SERVER_STATUS = 1
CONST SERVER_SERIALNUMBER = 2
CONST SERVER_CUSTOMERPRODUCTNAME = 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_MANUFACTURER = 12
CONST SERVER_GUID = 13
CONST SERVER_ASSETTAG = 14

CONST SERVER_MIN = 0
CONST SERVER_MAX = 14

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_CUSTOMERPRODUCTNAME = 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


'*** index for string array "ComponentsList"
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_KVMUNITS = 6
CONST COMPLIST_SERVERBLADES = 7
CONST COMPLIST_STORAGEBLADES = 8
CONST COMPLIST_MAX = 8

Dim oAPI, WshShell, oDiscoveryEmptyData, xmlDoc
Dim FSO1
Dim StartTime

Dim MonitorAgentRunning, strEventLogMsg
Dim strBladeSystemErrorLogName

Dim BC_PropertyNameList, PropertyNameList, ComponentsList, BC_ComponentsGroupList

Dim index, SCCIindex, componentNameArray, componentInfoArray
Dim componentNames, componentInfos, componentHealth
Dim nStatus

Dim PropertyArray
Dim NoOfBladeSystem
Dim SysChassisSerialNumber, SysCtrlSystemName, SysCtrlHousingType, BCIpAddress


Dim NoOfStorageBladesMonitored

Dim SourceType, SourceID, ManagedEntityId, PrincipalName
Dim oDiscoveryData, oInstBC, oInst
Dim TEMP
Dim BladeSystemCommunicationFilePath

Dim NoOfMMBUnits
Dim NoOfPSUnits
Dim NoOfFanUnits
Dim NoOfTempSensorUnits
Dim NoOfConnectUnits
Dim NoOfKVMUnits
Dim NoOfServerBlades
Dim NoOfStorageBlades

Dim lastErrorNum

ComponentsList = array("Enclosure", "MMBUnits", "PowerSupplyUnits", "FanUnits", "TempSensors", "ConnectUnits", "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", "SysChassisRackName", "AgentHttpPort", "Location", "Contact")

'*** 20 properties / component
PropertyNameList = Array("MgmtBladeId", "MgmtBladeSerialNumber", "MgmtBladeModelName", "MgmtBladeManufacture", "MgmtBladeProductName",_
"MgmtBladeHardwareVersion", "MgmtBladeFirmwareVersion", "MgmtBladePhysicalAddress", "MgmtBladeStatus", "", _
"", "", "", "", "", _
"", "", "", "", "", _
"SysPowerSupplyUnitId", "SysPowerSupplyUnitSerialNumber", "SysPowerSupplyUnitModelName", "SysPowerSupplyUnitProductName", "SysPowerSupplyUnitManufacture", _
"SysPowerSupplyUnitStatus", "SysPowerSupplyRedundancy", "", "", "",_
"", "", "", "", "", _
"", "", "", "", "", _
"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", "SvrBladeCustomerProductName", "SvrBladeModelName", _
"SvrBladeHardwareVersion", "SvrBladeFirmwareVersion", "SvrBladeBiosVersion", "SvrBladeOsType", "SvrBladeOsVersion", _
"SvrBladeBiosViomSettingStatus", "SvrBladeHostname", "SvrBladeManufacturer", "SvrBladeGuid", "SvrBladeAssetTag", _
"", "", "", "", "", _
"StorageBladeId", "StorageBladeSerialNumber", "StorageBladeCustomerProductName", "StorageBladeModelName", "StorageBladeHardwareVersion", _
"StorageBladeStatus", "StorageBladeFWVersion", "StorageBladeHardwareVersion", "StorageBladeAssetTag", "", _
"", "", "", "", "", _
"", "", "", "", "")




'*** Script MUST support a maximum of 100 blade "servers", thus:
'*** 102 (cMAXINDEX) elements in every array available ***
'*** (102 is the next multiple of 16, which is bigger than 100 ...)

Dim arrSysChasSerNo

arrSysChasSerNo = array("", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "")

Dim arrDiscoveryIp

arrDiscoveryIp = array("", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "")


Dim arrEnclosureName

arrEnclosureName = array("", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "")

Dim arrViomSettingTab

arrViomSettingTab = array("unknown", "unknown", "power-on-pending", "processing", "mmb-error", "viom-setting-ok", _
"viom-setting-failed", "boot-without-viom", "inventory-boot-ok", "inventory-boot-failed", "n-a")


Dim arrDnsName

arrDnsName = array("", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "")


Dim arrServerBladesCfg

arrServerBladesCfg = array("", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "")
Dim arrStorageBladesCfg

arrStorageBladesCfg = array("", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "")


Dim arrKVMCfg

arrKVMCfg = array("", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "")


'*** Done Matrix, first index: BC number, second index: component number
Dim arrDoneMatrix(50, 10)
Dim responseMatrix(50, 10)


'********************************************************************
' Sub Main(): main sub
'********************************************************************

Sub Main()

Dim oArgs, iniVal
Dim i, j, TargetComputer
Dim controlReturn, checkCount, fileUpdated, fileCouldBeRead, filePath
Dim BC_number, NoOfUnits, Unit_i, SaveBCDebug
Dim EnvVar, SYSTEMDRIVE, SYSTEMROOT, WINDIR
Dim strCommand, strComponent, strValue, strCOMM3File, strTempName
Dim retGetBC_Properties
Dim discoveryDone
Dim fileNames
Dim tmpEnclosures
Dim commFileFolder
Dim allFiles
Dim ResponseProcessed
Dim responseFile
Dim acc1, mod1, diffsec

Dim respFileCount, retryCount

'*** Check function arguments *************************************************

Set oArgs = WScript.Arguments

If insideMP = true Then
If oArgs.Count &lt; 4 Then
DebugOut("Not enough args!")
Wscript.Quit -1
ElseIf oArgs.Count = 4 Then
SourceId = oArgs(0)
ManagedEntityId = oArgs(1)
PrincipalName = oArgs(2)
TargetComputer = oArgs(3)
Else
'*** more than 4 arguments
SourceId = oArgs(0)
ManagedEntityId = oArgs(1)
PrincipalName = oArgs(2)
TargetComputer = oArgs(3)
If oArgs(4) = "ComponentInstances" Then
ComponentInstances = true
End If
End If
End If

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

' determine 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")

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_BLADESYSTEMDISCOVERY)
End If

SaveBCDebug = 0
If DebugMode = TRUE Then
SaveBCDebug = BCDebug
BCDebug = GetOpenIniValue(strLogIniFileNameAbs, INISEC_BLADESYSTEMDISCOVERY, "DebugLevel")
If BCDebug = "" Then
'e.g. ini file not there: restore old value
BCDebug = SaveBCDebug
End If
End If

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

If DebugMode = true Then
strLogFileNameAbs = strLogFileDir &amp; "\" &amp; LOGFILENAME &amp; TargetComputer &amp; ".log"
Call CreateLogFile(strLogFileNameAbs, TRUE)
End If

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

'*** we create *.in_ file if not yet done
Call CreateLogIniFile(strLogIniFileDir)


'### On Error Resume Next

If BCDebug AND BCDEBUG_MAX Then

'*** get the windows error log file name from out of the config file
strTempName = GetConfigFileEntry("//*/LogFile/Name")
'*** it ends with ".log" - we don't need it - replace it by "" (nothing) [= delete the ".log" appendix]
strBladeSystemErrorLogName = Replace(strTempName, ".log", "")

If Len(strBladeSystemErrorLogName) = 0 Then
'*** use DEFAULT
strBladeSystemErrorLogName = KEY_EVENT_LOG
End If

strCommand = "eventcreate /L " &amp; strBladeSystemErrorLogName &amp; " /T Information /SO " &amp; _
Chr(34) &amp; "SVISCOM-BL Discovery" &amp; Chr(34) &amp; " /ID 499 /D " &amp; Chr(34) &amp; _
"SVISCOM-BL: Started new DISCOVERY cycle." &amp; Chr(34)

WshShell.Run strCommand
'### On Error Goto 0
End If

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

If BCDebug AND BCDEBUG_MIN Then
DebugFile = true
End If

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

If insideMP = true Then
strCommand = "Args: " &amp; "SourceId=" &amp; SourceId &amp; ", ManagedEntityId=" &amp; ManagedEntityId &amp; ", PrincipalName=" &amp; PrincipalName &amp; ", TargetComputer=" &amp; TargetComputer
DebugOut(strCommand)
Else
strCommand = "Args: TargetComputer = " &amp; TargetComputer
DebugOut(strCommand)
DebugOut("EnvVar SYSTEMDRIVE = '" &amp; SYSTEMDRIVE &amp; "'")
End If

'Warning: string 'strCommand' is used below again (do not change in between!)

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

If BCDebug AND BCDEBUG_MIN Then
DebugOut("*** Check for simulation of blade server discovery/monitoring")
End If
simulationMode = false
simulationMode = CheckSimulationMode(strLogIniFileNameAbs)

'*** Create discovery data object

If insideMP = true Then
DebugOut("*** Create OM Script API and DiscoveryData Object")
Set oAPI = CreateObject("MOM.ScriptAPI")
Set oDiscoveryData = oAPI.CreateDiscoveryData(SourceType, SourceId, ManagedEntityId)
Set oDiscoveryEmptyData = oAPI.CreateDiscoveryData(SourceType, SourceId, ManagedEntityId)
End If

'*** Generate start message

If insideMP = true Then
strEventLogMsg = "Fujitsu PRIMERGY Blade System Discovery started"
Call oAPI.LogScriptEvent("PYBladeSystemEnclosureDiscovery.vbs", 401, INFORMATIONAL_EVENT, strEventLogMsg)
DebugOut(strEventLogMsg)
End If

'*** Check the running state of the Blade System monitor agent

MonitorAgentRunning = IsMonitorAgentRunning()

If MonitorAgentRunning &lt;&gt; true Then

If ExitOnMonitorServiceNotRunning = true Then
strEventLogMsg = "The Blade System Monitor Service '" &amp; BLADESYSTEMMONITORSERVICE &amp; "' is not running, the Discovery script ends here!"
If insideMP = true Then
Call oAPI.LogScriptEvent("PYBladeSystemEnclosureDiscovery.vbs", 402, ERROR_EVENT, strEventLogMsg)
End If
DebugOut(strEventLogMsg)
WScript.Quit(0)
End If
End If

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

BladeSystemCommunicationFilePath = GetBladeSystemCommunicationFilePath()

' *** assemble absolute "DISCOVERY" file name
absDiscoveryFileName = BladeSystemCommunicationFilePath &amp; "\" &amp; KEY_TIME &amp; "\" &amp; KEY_FILE_DISCOVERY

' *** assemble absolute "DISCOVERY.done" file name
absDiscoveryDoneFileName = BladeSystemCommunicationFilePath &amp; "\" &amp; KEY_TIME &amp; "\" &amp; KEY_FILE_DIS_DONE

' *** delete "done" file, if it exists
Set FSO1 = CreateObject("Scripting.FileSystemObject")

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


'*** we must set "NoOf...Units" to MAX (and check status) to find all units, e.g. those after "empty" ones

NoOfMMBUnits = MAX_MMBCOMPONENT '*** set to max. number
NoOfPSUnits = MAX_PSUCOMPONENT '*** set to max. number
NoOfFanUnits = MAX_FANCOMPONENT '*** set to max. number
NoOfTempSensorUnits = MAX_TSUCOMPONENT '*** set to max. number
NoOfConnectUnits = MAX_CUCOMPONENT '*** set to max. number
NoOfKVMUnits = MAX_KVMCOMPONENT '*** set to max. number
NoOfServerBlades = MAX_SERVERBLADES '*** set to max. number
NoOfStorageBlades = MAX_STORAGEBLADES '*** set to max. number

StartTime = now()

'******************************************************************************
'**** Real processing starts here *********************************************
'******************************************************************************

'*** cleanup old discovery files
Set commFileFolder = FSO1.GetFolder(BladeSystemCommunicationFilePath)
Set allFiles = commFileFolder.files
For Each responseFile in allFiles
On Error Resume Next
If (InStr(1,responseFile.Name, "Blade_", 1) &gt; 0) and (InStr(1,responseFile.Name, "Dis_comm.xml", 1) &gt; 0) Then
Call responseFile.Delete(TRUE)
End If
On Error GoTo 0
Next

respFileCount = 0
retryCount = 0

'*** Try to send enclosure CMDs for all enclosures

tmpEnclosures = ReadCOMM2FileAndSendEnclosureCMDs()

If tmpEnclosures &lt; 0 Then
'*** file not available or other serious problem
strEventLogMsg = "File with managed enclosures couldn't be read. Discovery script ends here!"
If insideMP = true Then
Call oAPI.Return(oDiscoveryEmptyData)
Call oAPI.LogScriptEvent("PYBladeSystemEnclosureDiscovery.vbs", 404, ERROR_EVENT, strEventLogMsg) '#### to be changed
End If
DebugOut(strEventLogMsg)
WScript.Quit(0)
End If

If tmpEnclosures = 0 Then
'*** file available but no enclosures defined
strEventLogMsg = "No Blade System found in communication file. Discovery script ends here!"
If insideMP = true Then
Call oAPI.LogScriptEvent("PYBladeSystemEnclosureDiscovery.vbs", 405, WARNING_EVENT, strEventLogMsg)
Call oAPI.Return(oDiscoveryEmptyData)
End If
DebugOut("***** " &amp; strEventLogMsg &amp; " *****")
WScript.Quit(0)
End If

'*** Proceed in regular way

NoOfBladeSystem = tmpEnclosures
InitDoneMatrix()
InitResponseMatrix()
Set commFileFolder = FSO1.GetFolder(BladeSystemCommunicationFilePath)
discoveryDone = False

'*** now process the response files

Do
ResponseProcessed = False
Set allFiles = commFileFolder.files
'*** check enclosure files with higher priority
For Each responseFile in allFiles
On Error Resume Next
If (InStr(1,responseFile.Name, "Blade_", 1) &gt; 0) and (InStr(1,responseFile.Name, "_EnclosureDis_comm.xml", 1) &gt; 0) Then
On Error Goto 0
'*** file out of date?
diffsec = FileAge(responseFile)
If diffsec &lt; 0 Then
DebugOut("Response file out of date, ignoring it")
Else
On Error Resume Next
ResponseProcessed = ResponseProcessed or ProcessResponseFile(responseFile.Path)(0)
On Error Goto 0
End If
End If
Next

'*** now process all response files
For Each responseFile in allFiles
On Error Resume Next
If (InStr(1,responseFile.Name, "Blade_", 1) &gt; 0) and (InStr(1,responseFile.Name, "Dis_comm.xml", 1) &gt; 0) Then
On Error Goto 0
'*** file out of date?
diffsec = FileAge(responseFile)
If diffsec &lt; 0 Then
DebugOut("Response file out of date, ignoring it")
Else
On Error Resume Next
ResponseProcessed = ResponseProcessed or ProcessResponseFile(responseFile.Path)(0)
On Error Goto 0
End If
End If
Next

If(ResponseProcessed = False) Then
'*** check if all files processed
If AreAllFilesProcessed() Then
If AllResponsesDone() Then
discoveryDone = true
Else
If retryCount = 0 Then
retryCount = retryCount + 1
strEventLogMsg = "Fujitsu PRIMERGY Blade System command retries started"
Call oAPI.LogScriptEvent("PYBladeSystemEnclosureDiscovery.vbs", 419, INFORMATIONAL_EVENT, strEventLogMsg)
PerformRetries()
respFileCount = 0
Else
discoveryDone = true
End If
End If
'*** check timeout for missing files
Else
'*** include delay here
WScript.Sleep(WAIT_5S)
respFileCount = respFileCount + 1
If respFileCount &gt;= 120 Then
If retryCount = 0 Then
retryCount = retryCount + 1
strEventLogMsg = "Fujitsu PRIMERGY Blade System command retries started"
Call oAPI.LogScriptEvent("PYBladeSystemEnclosureDiscovery.vbs", 419, INFORMATIONAL_EVENT, strEventLogMsg)
PerformRetries()
respFileCount = 0
Else
discoveryDone = true
End If
Else
DebugOut("********** Still looping, count = " &amp; CStr(respFileCount) &amp; " **********")
End If
End If
End If
Loop Until discoveryDone = true

Call PostProcessBladeDevicesAndKVM()

Call PostProcessMissingComponents()

If insideMP = true Then
DebugOut("*** Return Discovery Data to OpsMgr")
Call oAPI.Return(oDiscoveryData) ' Submit the data

Set oDiscoveryData = Nothing
Set oAPI = Nothing
End If

CreateDiscoveryDoneFile()

DebugOut("********** Normal End of Discovery **********")

End Sub

'******************************************************************************
'**** Functions and Subs *********************************************
'******************************************************************************

'--------------------------------------------------------------------
' Function AreAllFilesProcessed()
'--------------------------------------------------------------------

Function AreAllFilesProcessed()

Dim i, j
Dim done

i = 1
done = True

Do While done and (i &lt;= NoOfBladeSystem)

For j = 0 To COMPLIST_MAX
done = done and arrDoneMatrix(i,j)
Next
i = i + 1
Loop
AreAllFilesProcessed = done

End Function

'--------------------------------------------------------------------
' Function AllResponsesDone()
'--------------------------------------------------------------------

Function AllResponsesDone()

Dim i, j
Dim done

i = 1
done = True

Do While done and (i &lt;= NoOfBladeSystem)

For j = 0 To COMPLIST_MAX
done = done and responseMatrix(i,j)
Next
i = i + 1
Loop
AllResponsesDone = done

End Function

AllResponsesDone()

'--------------------------------------------------------------------
' Function PerformRetries()
'--------------------------------------------------------------------

Function PerformRetries()

Dim i, j
Dim done
Dim controlReturn
Dim strEventLogMsg


i = 1
done = True

Do While done and (i &lt;= NoOfBladeSystem)
'*** check enclosure
If arrDoneMatrix(i,0) = false Then
'*** process only enclosure file
Call GenerateSelectedDiscoveryCmdFile(arrSysChasSerNo(i), arrDiscoveryIp(i), 0)
Else
'*** process remaining components
For j = 1 To COMPLIST_MAX
If arrDoneMatrix(i,j) = false Then
Call GenerateSelectedDiscoveryCmdFile(arrSysChasSerNo(i), arrDiscoveryIp(i), j)
strEventLogMsg = "File lost"
Call oAPI.LogScriptEvent("PYBladeSystemEnclosureDiscovery.vbs", 430, INFORMATIONAL_EVENT, strEventLogMsg)
End If
Next
End If
i = i + 1
Loop

i = 1
done = True

Do While done and (i &lt;= NoOfBladeSystem)
'*** check enclosure
If responseMatrix(i,0) = false Then
'*** process only enclosure file
arrDoneMatrix(i, 0) = False
Call GenerateSelectedDiscoveryCmdFile(arrSysChasSerNo(i), arrDiscoveryIp(i), 0)
Else
'*** process remaining components
For j = 1 To COMPLIST_MAX
If responseMatrix(i,j) = false Then
arrDoneMatrix(i, j) = False
Call GenerateSelectedDiscoveryCmdFile(arrSysChasSerNo(i), arrDiscoveryIp(i), j)
strEventLogMsg = "Timeout"
Call oAPI.LogScriptEvent("PYBladeSystemEnclosureDiscovery.vbs", 431, INFORMATIONAL_EVENT, strEventLogMsg)
End If
Next
End If
i = i + 1
Loop

controlReturn = MonitoringOnDemand()

PerformRetries = done

End Function


'--------------------------------------------------------------------
' Sub InitDoneMatrix()
'--------------------------------------------------------------------

Sub InitDoneMatrix()

Dim i, j

For i = 0 To BCNUM_MAX_INDEX
For j = 0 To COMPLIST_MAX
arrDoneMatrix(i,j) = false
Next
Next
End Sub


'--------------------------------------------------------------------
' Sub SetComponentsDoneInDoneMatrix(i)
'--------------------------------------------------------------------

Sub SetComponentsDoneInDoneMatrix(i)

Dim j

For j = 1 To COMPLIST_MAX
arrDoneMatrix(i,j) = true
Next
End Sub

'--------------------------------------------------------------------
' Sub InitResponseMatrix()
'--------------------------------------------------------------------

Sub InitResponseMatrix()

Dim i, j

For i = 0 To BCNUM_MAX_INDEX
For j = 0 To COMPLIST_MAX
responseMatrix(i,j) = true
Next
Next
End Sub


'--------------------------------------------------------------------
' Function ProcessResponseFile(responseFile)
'--------------------------------------------------------------------

Function ProcessResponseFile(responseFile)

Dim fileProcessed
Dim chassisSN
Dim indexBC
Dim strEventLogMsg
Dim fullFname
Dim compNum
Dim errors


On Error Goto 0

fileProcessed = array(false, 0)
fullFname = responseFile

DebugOut("Start: Function ProcessResponseFile(responseFile: " &amp; responseFile)
'*** Try to load XML response file
Set xmlDoc = Nothing
Set xmlDoc = CreateObject("Msxml2.DOMDocument")
xmlDoc.async = False
xmlDoc.load(responseFile)

If xmlDoc.parseError Then
DebugOut("Error when parsing the response file. 1st try")

'*** try it again
WScript.Sleep(WAIT_5S)
Set xmlDoc = Nothing
Set xmlDoc = CreateObject("Msxml2.DOMDocument")
xmlDoc.async = False
xmlDoc.load(responseFile)
End If

If xmlDoc.parseError Then
'*** something wrong
strEventLogMsg = "Could not parse XML file (5) " &amp; responseFile
Call oAPI.LogScriptEvent("PYBladeSystemEnclosureDiscovery.vbs", 407, WARNING_EVENT, strEventLogMsg)
DebugOut("Error when parsing the response file. 2nd and last try")
Else
DebugOut("Now evaluating response file")

'*** Error Code processing
Set errors = xmlDoc.selectSingleNode("//Server/Errors")
If Not errors is Nothing Then
lastErrorNum = CInt(errors.getAttribute("LastErrorCode"))
Else
'*** not valid response
lastErrorNum = -1
DebugOut("Missing last error information in response file")
End If

'*** determine chassis serial number from response file
chassisSN = GetChassisSNFromResponeFile(responseFile)
If len(chassisSN) &gt; 0 Then
'*** is this chassis SN known?
indexBC = GetBCNumberFromSN(chassisSN)
If indexBC &lt; 0 Then
'*** No, then generate a warning and ignore this file
strEventLogMsg = "Response file for unknown chassis found; response file name: " &amp; responseFile
If insideMP = true Then
Call oAPI.LogScriptEvent("PYBladeSystemEnclosureDiscovery.vbs", 408, ERROR_EVENT, strEventLogMsg)
End If
DebugOut("No valid chassis number in response file")
Else
DebugOut("Determining response file type")
If InStr(1,responseFile, "EnclosureDis_comm.xml", 1) &lt;&gt; 0 Then
compNum = COMPLIST_ENCLOSURE
If arrDoneMatrix(indexBC,compNum) = false Then
fileProcessed = ProcessEnclosures(indexBC, chassisSN)
Else
DebugOut("File already done")
End If
ElseIf InStr(1,responseFile, "ServerBladesDis_comm.xml", 1) &lt;&gt; 0 Then
compNum = COMPLIST_SERVERBLADES
If arrDoneMatrix(indexBC,compNum) = false Then
fileProcessed = ProcessServerBlades(indexBC, chassisSN)
Else
DebugOut("File already done")
End If
ElseIf InStr(1,responseFile, "StorageBladesDis_comm.xml", 1) &lt;&gt; 0 Then
compNum = COMPLIST_STORAGEBLADES
If arrDoneMatrix(indexBC,compNum) = false Then
fileProcessed = ProcessStorageBlades(indexBC, chassisSN)
Else
DebugOut("File already done")
End If
ElseIf InStr(1,responseFile, "MMBUnitsDis_comm.xml", 1) &lt;&gt; 0 Then
compNum = COMPLIST_MMBS
If arrDoneMatrix(indexBC,compNum) = false Then
fileProcessed = ProcessMMBs(indexBC, chassisSN)
Else
DebugOut("File already done")
End If
ElseIf InStr(1,responseFile, "PowerSupplyUnitsDis_comm.xml", 1) &lt;&gt; 0 Then
compNum = COMPLIST_POWERSUPPLIES
If arrDoneMatrix(indexBC,compNum) = false Then
fileProcessed = ProcessPSUs(indexBC, chassisSN)
Else
DebugOut("File already done")
End If
ElseIf InStr(1,responseFile, "FanUnitsDis_comm.xml", 1) &lt;&gt; 0 Then
compNum = COMPLIST_FANS
If arrDoneMatrix(indexBC,compNum) = false Then
fileProcessed = ProcessFans(indexBC, chassisSN)
Else
DebugOut("File already done")
End If
ElseIf InStr(1,responseFile, "TempSensorsDis_comm.xml", 1) &lt;&gt; 0 Then
compNum = COMPLIST_TEMPSENSORS
If arrDoneMatrix(indexBC,compNum) = false Then
fileProcessed = ProcessTempSensors(indexBC, chassisSN)
Else
DebugOut("File already done")
End If
ElseIf InStr(1,responseFile, "_ConnectUnitsDis_comm.xml", 1) &lt;&gt; 0 Then
compNum = COMPLIST_CONNECTUNITS
If arrDoneMatrix(indexBC,compNum) = false Then
fileProcessed = ProcessCCUs(indexBC, chassisSN, BC_COMP_CONNECTUNIT)
Else
DebugOut("File already done")
End If
ElseIf InStr(1,responseFile, "KVMUnitsDis_comm.xml", 1) &lt;&gt; 0 Then
compNum = COMPLIST_KVMUNITS
If arrDoneMatrix(indexBC,compNum) = false Then
fileProcessed = ProcessKVMs(indexBC, chassisSN)
Else
DebugOut("File already done")
End If
Else
'*** not a response file =&gt; ignore it
DebugOut("Not a response file")
fileProcessed = array(false, 0)
End If
End If
End If
End If

If fileProcessed(0) = true Then
DebugOut("ProcessResponseFile finished with success: ")
'*** set done matrix
arrDoneMatrix(indexBC, compNum) = True
DebugOut("Response file processed")

'*** delete response file
On Error Resume Next
If FSO1.FileExists(responseFile) = TRUE Then
Call FSO1.DeleteFile(responseFile, TRUE)
End If
On Error Goto 0
End If

'*** check on timeouts and other problems
If (fileProcessed(1) = 0) And ((lastErrorNum = 2) Or (lastErrorNum = 3) Or (lastErrorNum = 6) Or (lastErrorNum = 7) Or (lastErrorNum = 8) Or (lastErrorNum = -1)) Then
responseMatrix(indexBC, compNum) = False
DebugOut("Response file with timeout errors")
Else
responseMatrix(indexBC, compNum) = True
End If

Set xmlDoc = Nothing
ProcessResponseFile = fileProcessed
End Function




'--------------------------------------------------------------------
' Function ReadCOMM2FileAndSendEnclosureCMDs():
' - reads communication file with enclosures to be monitored
' - create and send CMDs for getting enclosure data from MA
'--------------------------------------------------------------------

Function ReadCOMM2FileAndSendEnclosureCMDs()

Dim strIpAddress, strChSN, strSystemName, dnsName
Dim strBCCommunicationFile
Dim fileLoaded
Dim maxIndex
Dim enclosureCount
Dim BladeSystem_i
Dim controlReturn

enclosureCount = 0

'*** (try to) load XML file
Set xmlDoc = CreateObject("Msxml2.DOMDocument")
'disable asynchronous loading
xmlDoc.async = False

'*** read the name of communication file in registry
strBCCommunicationFile = GetBladeSystemCommunicationFile()

'*** Now look for the COMM2 file:
fileLoaded = xmlDoc.load(strBCCommunicationFile)

If fileLoaded = false Then
enclosureCount = -1
Else
enclosureCount = CInt(GetNoOfBladeSystems(xmlDoc))
End If

If enclosureCount &gt; 0 Then

maxIndex = cMAXINDEX

BladeSystem_i = 1

If enclosureCount &gt; 0 Then

Do While BladeSystem_i &lt;= enclosureCount

strChSN = GetXMLComponentsPropertyValue(xmlDoc, BladeSystem_i, "Chassis Information", "SysChassisSerialNumber",FILETYPE_MNGD_NODES)
If len(strChSN) &gt; 0 Then
arrSysChasSerNo(BladeSystem_i) = strChSN
DebugOut("Server " &amp; BladeSystem_i &amp; ": SysChassisSerialNumber = " &amp; strChSN)
End If

strIpAddress = GetXMLComponentsPropertyValue(xmlDoc, BladeSystem_i, "Chassis Information", "DiscoveryIpAddress", FILETYPE_MNGD_NODES)
If len(strIpAddress) &gt; 0 Then
arrDiscoveryIp(BladeSystem_i) = strIpAddress
DebugOut("Server " &amp; BladeSystem_i &amp; ": DiscoveryIpAddress = " &amp; strIpAddress)
Else
strIpAddress = GetXMLComponentsPropertyValue(xmlDoc, BladeSystem_i, "Chassis Information", "AgentIpAddress", FILETYPE_MNGD_NODES)
If len(strIpAddress) &gt; 0 Then
arrDiscoveryIp(BladeSystem_i) = strIpAddress
DebugOut("Server " &amp; BladeSystem_i &amp; ": AgentIpAddress = " &amp; strIpAddress)
End If
End If

dnsName = GetXMLComponentsPropertyValue(xmlDoc, BladeSystem_i, "Chassis Information", "DNSName", FILETYPE_MNGD_NODES)
If len(dnsName) &gt; 0 Then
arrDnsName(BladeSystem_i) = dnsName
DebugOut("Server " &amp; BladeSystem_i &amp; ": DNS Name = " &amp; dnsName)
Else
arrDnsName(BladeSystem_i) = "N/A"
DebugOut("Server " &amp; BladeSystem_i &amp; ": DNS Name = " &amp; "N/A")
End If

strSystemName = GetXMLComponentsPropertyValue(xmlDoc, BladeSystem_i, "Chassis Information", "AgentName",FILETYPE_MNGD_NODES)
If (len(strSystemName) &gt; 0) And (len(strSystemName) &lt;= 14) Then
arrEnclosureName(BladeSystem_i) = strSystemName
DebugOut("Server " &amp; BladeSystem_i &amp; ": SystemName = " &amp; strSystemName)
ElseIf len(strSystemName) &gt; 14 Then
arrEnclosureName(BladeSystem_i) = Left(strSystemName,14)
DebugOut("Server " &amp; BladeSystem_i &amp; ": SystemName = " &amp; strSystemName)
Else
arrEnclosureName(BladeSystem_i) = "N/A"
DebugOut("Server " &amp; BladeSystem_i &amp; ": SystemName = " &amp; "N/A")
End If

Call GenerateCmdFile(strChSN, "EnclosureDis", strIpAddress)
controlReturn = MonitoringOnDemand()

BladeSystem_i = BladeSystem_i + 1

If BladeSystem_i &gt;= maxIndex Then
DebugOut("Maximum number of instances reached/exceeded! Abort system detection loop!")
Exit Do
End If
Loop
End If
End If '*** enclosureCount &gt; 0

ReadCOMM2FileAndSendEnclosureCMDs = enclosureCount

End Function

'--------------------------------------------------------------------
' Function ProcessEnclosures():
' - processes receiving enclosure COMM4 files
' - instantiates enclosures
' Note: it is assumed that xmlDoc is already loaded
'--------------------------------------------------------------------

Function ProcessEnclosures(BladeSystem_i, SysChassisSerialNumber)

Dim retGetBC_Properties
Dim BCIpAddress, EnclosureName, BCRackName, BCHttpPort, WebInterfaceUrl, BCDnsName
Dim controlReturn
Dim numEnclosure

'***** Init BladeSystem enclosure values
InitPropertyArray()
numEnclosure = 0

BCIpAddress = arrDiscoveryIp(BladeSystem_i)
BCDnsName = arrDnsName(BladeSystem_i)

retGetBC_Properties = GetBC_Properties(BladeSystem_i)

If BCDebug AND BCDEBUG_MAX Then
DebugOut("Blade System Serial Number: " &amp; SysChassisSerialNumber)
DebugOut("Blade System Serial Number (Property): " &amp; PropertyArray(BC_CHASSISSERIALNUMBER))
End If

SysCtrlSystemName = PropertyArray(BC_BLADESYSTEMMODEL)
If BCDebug AND BCDEBUG_MAX Then
DebugOut("Blade System System Name: " &amp; SysCtrlSystemName)
End If

SysCtrlHousingType = PropertyArray(BC_BLADESYSTEMCHASSIS)
If BCDebug AND BCDEBUG_MAX Then
DebugOut("Blade System Chassis Model: " &amp; SysCtrlHousingType)
End If

If BCDebug AND BCDEBUG_MAX Then
DebugOut("BladeSystem IP Address: " &amp; BCIpAddress)
End If

BCRackName = PropertyArray(BC_RACKNAME)
If BCDebug AND BCDEBUG_MAX Then
DebugOut("BladeSystem Rack Name: " &amp; BCRackName)
End If

BCHttpPort = PropertyArray(BC_HTTP_PORT)
If BCDebug AND BCDEBUG_MAX Then
DebugOut("BladeSystem HTTP Port: " &amp; BCHttpPort)
End If

EnclosureName = arrEnclosureName(BladeSystem_i) &amp; "_" &amp; SysChassisSerialNumber

If BCIpAddress &lt;&gt; "0.0.0.0" And BCIpAddress &lt;&gt; "255.255.255.255" And BCIpAddress &lt;&gt; "" And BCIpAddress &lt;&gt; "N/A" Then
'*** If IPv6 address than add parentheses
If InStr(1,BCIpAddress, ":", 1) &gt; 0 Then
If BCHttpPort &lt;&gt; "" Then
WebInterfaceUrl = "http://" &amp; "[" &amp; BCIpAddress &amp; "]" &amp; ":" &amp; BCHttpPort
Else
WebInterfaceUrl = "http://" &amp; "[" &amp; BCIpAddress &amp; "]"
End If
Else
If BCHttpPort &lt;&gt; "" Then
WebInterfaceUrl = "http://" &amp; BCIpAddress &amp; ":" &amp; BCHttpPort
Else
WebInterfaceUrl = "http://" &amp; BCIpAddress
End If
End If
End If

If insideMP = true And Len(SysChassisSerialNumber) &gt; 0 Then
If BCDebug AND BCDEBUG_MIN Then
DebugOut("***** Create Blade System Instance: '" &amp; EnclosureName &amp; "' *****")
End If
Set oInstBC = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure']$")
Call oInstBC.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", PrincipalName)
Call oInstBC.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.MonitorService']/PrincipalName$", PrincipalName)
Call oInstBC.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", EnclosureName)
Call oInstBC.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure']/SysChassisSerialNumber$", SysChassisSerialNumber)
Call oInstBC.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure']/DnsName$", BCDnsName)

'*** only in the case that we really got data they are transferred to SCOM
if Len(PropertyArray(BC_CHASSISSERIALNUMBER)) &gt; 0 Then
Call oInstBC.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.System']/Model$", SysCtrlHousingType)
Call oInstBC.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.System']/SerialNumber$", SysChassisSerialNumber)
Call oInstBC.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.System']/OperatingSystem$", "Embedded Linux")
Call oInstBC.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure']/SysCtrlSystemName$", SysCtrlSystemName)
Call oInstBC.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure']/SysCtrlHousingType$", SysCtrlHousingType)
Call oInstBC.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure']/IpAddress$", BCIpAddress)
Call oInstBC.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure']/RackName$", BCRackName)
Call oInstBC.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure']/WebInterfaceUrl$", WebInterfaceUrl)
Call oInstBC.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure']/ConnectState$", "connected")
Call oInstBC.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure']/SysLocation$", PropertyArray(BC_SYSLOCATION))
Call oInstBC.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure']/SysContact$", PropertyArray(BC_SYSCONTACT))
Else
Call oInstBC.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure']/ConnectState$", "not connected")
End If

If BCDebug AND BCDEBUG_MAX Then
DebugOut("*** Complete Data of Blade System Enclosure for OpsMgr")
End If

Call oDiscoveryData.AddInstance(oInstBC)
numEnclosure = 1
End If

If numEnclosure &gt; 0 Then
Call GenerateDiscoveryCmdFileForAllComp(SysChassisSerialNumber, BCIpAddress)
controlReturn = MonitoringOnDemand()
ProcessEnclosures = array(True, numEnclosure)
Else
'*** We are finished here, do not wait for component responses
DebugOut("*** No valid data in enclosure response found")
Call SetComponentsDoneInDoneMatrix(BladeSystem_i)
ProcessEnclosures = array(True, 0)
End If

End Function


'--------------------------------------------------------------------
' Function ProcessMMBs():
' - processes receiving MMB COMM4 files
' - instantiates MMBs
' Note: it is assumed that xmlDoc is already loaded
'--------------------------------------------------------------------

Function ProcessMMBs(BladeSystem_i, SysChassisSerialNumber)

Dim NoOfMMBUnitsMonitored
Dim Unit_i
Dim NoOfUnits
Dim index
Dim i, j
Dim strValue
Dim BCIpAddress, EnclosureName

If NoOfMMBUnits &gt; 0 Then

If BCDebug AND BCDEBUG_MIN Then
DebugOut("********* MMB Collection *********")
End If


InitNameStatusArray()
BCIpAddress = arrDiscoveryIp(BladeSystem_i)
EnclosureName = arrEnclosureName(BladeSystem_i) &amp; "_" &amp; SysChassisSerialNumber

index = 0
Unit_i = 1
NoOfMMBUnitsMonitored = 0
NoOfUnits = NoOfMMBUnits

Do While NoOfUnits &gt; 0
If BCDebug AND BCDEBUG_MIN Then
DebugOut("***** Check MMB Properties *****")
End If

InitPropertyArray()
nStatus = 0

If BCDebug AND BCDEBUG_MAX Then
DebugOut("Get MMB Component Properties of Blade System " &amp; BladeSystem_i)
End If
If GetBCComponent_Properties(BladeSystem_i, BC_ComponentsGroupList(BC_COMP_MMB), index+1, MMB + MMB_MIN, MMB_MAX) &gt; 0 Then

If BCDebug AND BCDEBUG_MAX Then
DebugOut("*** Display all MMB property values:")
For i=MMB_MIN to MMB_MAX
DebugOut(PropertyNameList(MMB + i) &amp; "=" &amp; PropertyArray(i))
Next
End If

If Len(PropertyArray(MMB_ID)) &gt; 0 And Len(PropertyArray(MMB_PRODUCTNAME)) &gt; 0 Then

' seen an empty field here - avoid crash of script ...
If PropertyArray(MMB_STATUS) = "" Then
PropertyArray(MMB_STATUS) = MMB_STATUS_UNKNOWN
DebugOut("WARNING: MMB " &amp; Unit_i &amp; " STATUS = UNKNOWN!")
End If
If BCDebug AND BCDEBUG_MAX Then
DebugOut("PropertyArray(MMB)=" &amp; PropertyArray(MMB_STATUS))
End If
nStatus = CInt(PropertyArray(MMB_STATUS))

If (nStatus = MMB_STATUS_STANDBY) Then
componentNameArray(index) = PropertyArray(MMB_ID) &amp; ": " &amp; PropertyArray(MMB_PRODUCTNAME) &amp; " (standby); "
Else
componentNameArray(index) = PropertyArray(MMB_ID) &amp; ": " &amp; PropertyArray(MMB_PRODUCTNAME) &amp; "; "
End If

If Len(PropertyArray(MMB_MODELNAME)) &gt; 0 And Len(PropertyArray(MMB_MANUFACTURE)) &gt; 0 Then
componentInfoArray(index) = PropertyArray(MMB_ID) &amp; ": " &amp; PropertyArray(MMB_MODELNAME) &amp; " / " &amp; PropertyArray(MMB_MANUFACTURE) &amp; "; "
End If

index = index + 1

End If

NoOfUnits = NoOfUnits - 1
Else
If BCDebug AND BCDEBUG_MAX Then
DebugOut("No Properties of MMB Unit: " &amp; Unit_i)
End If
End If

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

Loop

NoOfMMBUnitsMonitored = index
If BCDebug AND BCDEBUG_MIN Then
DebugOut("Number of monitored MMB Units = " &amp; NoOfMMBUnitsMonitored)
End If

If NoOfMMBUnitsMonitored &gt; 0 Then

If BCDebug AND BCDEBUG_MIN Then
DebugOut("********* Create MMB Collection")
End If

If insideMP = true Then
If BCDebug AND BCDEBUG_MIN Then
DebugOut("Create instance of MMB Subsystem")
End If
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.MMBSubsystem']$")
Call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", PrincipalName)
Call oInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.MonitorService']/PrincipalName$", PrincipalName)
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure']/SysChassisSerialNumber$", SysChassisSerialNumber)
Call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "MMB Units")
Call oInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/ServerName$", EnclosureName)
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.HealthCollection']/IpAddress$", BCIpAddress)
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.HealthCollection']/SysChassisSerialNumber$", SysChassisSerialNumber)
End If


If BCDebug AND BCDEBUG_MIN Then
DebugOut("Collect MMB Subsystem Data")
End If

componentNames = "ID / Product Name: "
componentInfos = "ID / Model / Manufacturer: "

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

If BCDebug AND BCDEBUG_MAX Then
DebugOut("Discovered MMB Units: " &amp; componentNames)
DebugOut("Discovered MMB Unit Infos: " &amp; componentInfos)
End If

If insideMP = true Then
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.MMBSubsystem']/MgmtBladeUnits$", NoOfMMBUnitsMonitored)
Call oInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/Devices$", componentNames)
Call oInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/DevicesInfo$", componentInfos)

If BCDebug AND BCDEBUG_MIN Then
DebugOut("Add Instance of MMB Subsystem to OM Data Base")
End If
Call oDiscoveryData.AddInstance(oInst)
Set oInst = Nothing
End If

End If ' If NoOfMMBUnitsMonitored &gt; 0

End If ' If NoOfMMBUnits &gt; 0

ProcessMMBs = array(True, NoOfMMBUnitsMonitored)

End Function

'--------------------------------------------------------------------
' Function ProcessPSUs():
' - processes receiving PSU COMM4 files
' - instantiates PSUs
' Note: it is assumed that xmlDoc is already loaded
'--------------------------------------------------------------------

Function ProcessPSUs(BladeSystem_i, SysChassisSerialNumber)

Dim NoOfPSUnitsMonitored
Dim Unit_i
Dim NoOfUnits
Dim index
Dim i, j
Dim strValue
Dim BCIpAddress, EnclosureName

If NoOfPSUnits &gt; 0 Then

If BCDebug AND BCDEBUG_MIN Then
DebugOut("********* Power Supplies Collection *********")
End If

InitNameStatusArray()
BCIpAddress = arrDiscoveryIp(BladeSystem_i)
EnclosureName = arrEnclosureName(BladeSystem_i) &amp; "_" &amp; SysChassisSerialNumber
index = 0
Unit_i = 1
NoOfPSUnitsMonitored = 0
NoOfUnits = NoOfPSUnits

Do While NoOfUnits &gt; 0
If BCDebug AND BCDEBUG_MIN Then
DebugOut("******** Check Power Supply instances")
End If

InitPropertyArray()
nStatus = 0

If BCDebug AND BCDEBUG_MAX Then
DebugOut("Get Power Supply Component Properties of Blade System " &amp; BladeSystem_i)
End If
If GetBCComponent_Properties(BladeSystem_i, BC_ComponentsGroupList(BC_COMP_POWERSUPPLYUNIT), Unit_i, PSU + PSU_MIN, PSU_MAX) &gt; 0 Then

If BCDebug AND BCDEBUG_MAX Then
DebugOut("*** Display all PSU property values:")
For i=PSU_MIN to PSU_MAX
DebugOut(PropertyNameList(PSU + i) &amp; "=" &amp; PropertyArray(i))
Next
End If

If Len(PropertyArray(PSU_ID)) &gt; 0 And Len(PropertyArray(PSU_PRODUCTNAME)) &gt; 0 Then

If Len(PropertyArray(PSU_STATUS)) &gt; 0 Then
If BCDebug AND BCDEBUG_MAX Then
DebugOut("PropertyArray(PSU)=" &amp; PropertyArray(PSU_STATUS))
End If
nStatus = CInt(PropertyArray(PSU_STATUS))
Else
DebugOut("WARNING: PSU " &amp; Unit_i &amp; " STATUS = UNKNOWN!")
nStatus = PSU_STATUS_UNKNOWN
End If
'*** WARNING: this same condition is used in MONITORING! Keep the same!
If (nStatus = PSU_STATUS_DUMMY) OR (nStatus = PSU_STATUS_FANMODULE) Then
If BCDebug AND BCDEBUG_MIN Then
DebugOut("Status of Power Supply Unit " &amp; Unit_i &amp; _
" = " &amp; PropertyArray(PSU_STATUS) &amp; _
" -&gt; Component instance will NOT be monitored")
End If
Else

componentNameArray(index) = PropertyArray(PSU_ID) &amp; ":" &amp; PropertyArray(PSU_PRODUCTNAME) &amp; "; "

If Len(PropertyArray(PSU_MODELNAME)) &gt; 0 And Len(PropertyArray(PSU_MANUFACTURER)) &gt; 0 Then
componentInfoArray(index) = PropertyArray(PSU_ID) &amp; ":" &amp; PropertyArray(PSU_MODELNAME) &amp; "/" &amp; PropertyArray(PSU_MANUFACTURER) &amp; "; "
End If

index = index + 1
End If

End If

NoOfUnits = NoOfUnits - 1
Else
If BCDebug AND BCDEBUG_MAX Then
DebugOut("No Properties of PowerSupply Unit: " &amp; Unit_i)
End If
End If

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

Loop

NoOfPSUnitsMonitored = index
If BCDebug AND BCDEBUG_MIN Then
DebugOut("Number of monitored Power Supply Units = " &amp; NoOfPSUnitsMonitored)
End If

If NoOfPSUnitsMonitored &gt; 0 Then

If BCDebug AND BCDEBUG_MIN Then
DebugOut("********* Create Power Supplies Collection")
End If

If insideMP = true Then
If BCDebug AND BCDEBUG_MAX Then
DebugOut("Create instance of Power Supply Subsystem")
End If
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.PowerSupplySubsystem']$")
Call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", PrincipalName)
Call oInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.MonitorService']/PrincipalName$", PrincipalName)
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure']/SysChassisSerialNumber$", SysChassisSerialNumber)
Call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Power Supply Units")
Call oInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/ServerName$", EnclosureName)
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.HealthCollection']/IpAddress$", BCIpAddress)
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.HealthCollection']/SysChassisSerialNumber$", SysChassisSerialNumber)
End If


If BCDebug AND BCDEBUG_MIN Then
DebugOut("Collect Power Supply Subsystem Data")
End If

componentNames = "ID / Product Name: "
componentInfos = "ID / Model / Manufacturer: "

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

If BCDebug AND BCDEBUG_MAX Then
DebugOut("Discovered Power Supply Units: " &amp; componentNames)
DebugOut("Discovered Power Supply Unit Infos: " &amp; componentInfos)
End If

If insideMP = true Then
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.PowerSupplySubsystem']/PowerSupplyUnits$", NoOfPSUnitsMonitored)
Call oInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/Devices$", componentNames)
Call oInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/DevicesInfo$", componentInfos)

If BCDebug AND BCDEBUG_MIN Then
DebugOut("Add Instance of PowerSupply Subsystem to OM Data Base")
End If
Call oDiscoveryData.AddInstance(oInst)
Set oInst = Nothing
End If

End If

End If

ProcessPSUs = array(True, NoOfPSUnitsMonitored)

End Function

'--------------------------------------------------------------------
' Function ProcessFans():
' - processes receiving Fan COMM4 files
' - instantiates Fan System Units
' Note: it is assumed that xmlDoc is already loaded
'--------------------------------------------------------------------

Function ProcessFans(BladeSystem_i, SysChassisSerialNumber)

Dim NoOfFanUnitsMonitored
Dim Unit_i
Dim NoOfUnits
Dim index
Dim i, j
Dim strValue
Dim BCIpAddress, EnclosureName

If NoOfFanUnits &gt; 0 Then

If BCDebug AND BCDEBUG_MIN Then
DebugOut("********** Fan Unit Collection **********")
End If

InitNameStatusArray()
BCIpAddress = arrDiscoveryIp(BladeSystem_i)
EnclosureName = arrEnclosureName(BladeSystem_i) &amp; "_" &amp; SysChassisSerialNumber
index = 0
Unit_i = 1
NoOfFanUnitsMonitored = 0
NoOfUnits = NoOfFanUnits

Do While NoOfUnits &gt; 0
If BCDebug AND BCDEBUG_MIN Then
DebugOut("********** Check Fan units")
End If

InitPropertyArray()
nStatus = 0

If BCDebug AND BCDEBUG_MAX Then
DebugOut("Get Fan Unit Component Properties of Blade System " &amp; BladeSystem_i)
End If
If GetBCComponent_Properties(BladeSystem_i, BC_ComponentsGroupList(BC_COMP_FANUNIT), Unit_i, FAN + FAN_MIN, FAN_MAX) &gt; 0 Then

If BCDebug AND BCDEBUG_MAX Then
DebugOut("*** Display all Fan property values:")
For i=FAN_MIN to FAN_MAX
DebugOut(PropertyNameList(FAN + i) &amp; "=" &amp; PropertyArray(i))
Next
End If

If Len(PropertyArray(FAN_ID)) &gt; 0 And Len(PropertyArray(FAN_DESIGNATION)) &gt; 0 Then
If Len(PropertyArray(FAN_STATUS)) &gt; 0 Then
If BCDebug AND BCDEBUG_MAX Then
DebugOut("PropertyArray(FAN)=" &amp; PropertyArray(FAN_STATUS))
End If
nStatus = CInt(PropertyArray(FAN_STATUS))
Else
DebugOut("WARNING: FAN " &amp; Unit_i &amp; " STATUS = UNKNOWN!")
nStatus = FAN_STATUS_UNKNOWN
End If

componentNameArray(index) = PropertyArray(FAN_ID) &amp; ":'" &amp; PropertyArray(FAN_DESIGNATION) &amp; "'; "

index = index + 1

End If

NoOfUnits = NoOfUnits - 1
Else
If BCDebug AND BCDEBUG_MAX Then
DebugOut("No Properties of Fan Unit: " &amp; Unit_i)
End If
End If

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

NoOfFanUnitsMonitored = index
If BCDebug AND BCDEBUG_MIN Then
DebugOut("Monitored Fan units = " &amp; NoOfFanUnitsMonitored)
End If

If NoOfFanUnitsMonitored &gt; 0 Then

If insideMP = true Then
If BCDebug AND BCDEBUG_MAX Then
DebugOut("*** Create instance of Fan Subsystem")
End If
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.FanSubsystem']$")
Call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", PrincipalName)
Call oInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.MonitorService']/PrincipalName$", PrincipalName)
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure']/SysChassisSerialNumber$", SysChassisSerialNumber)
Call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Fan Units")
Call oInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/ServerName$", EnclosureName)
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.HealthCollection']/IpAddress$", BCIpAddress)
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.HealthCollection']/SysChassisSerialNumber$", SysChassisSerialNumber)
End If

componentNames = "ID / Designation: "
componentInfos = "N/A"

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

If BCDebug AND BCDEBUG_MAX Then
DebugOut("Discovered Fan Units: " &amp; componentNames)
DebugOut("Discovered Fan Unit Infos: " &amp; componentInfos)
End If

If Len(componentNames) &gt; 2047 Then
componentNames = UCase(Left(componentNames, 2040)) &amp; " ..."
End If
If Len(componentInfos) &gt; 2047 Then
componentInfos = UCase(Left(componentInfos, 2040)) &amp; " ..."
End If

If insideMP = true Then
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.FanSubsystem']/FanUnits$", NoOfFanUnitsMonitored)
Call oInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/Devices$", componentNames)
Call oInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/DevicesInfo$", componentInfos)

If BCDebug AND BCDEBUG_MIN Then
DebugOut("Add Instance of Fan Subsystem to OM Data Base")
End If
Call oDiscoveryData.AddInstance(oInst)
Set oInst = Nothing
End If

End If

End If

ProcessFans = array(True, NoOfFanUnitsMonitored)

End Function

'--------------------------------------------------------------------
' Function ProcessTempSensors():
' - processes receiving TempSensor COMM4 files
' - instantiates TempSensor Units
' Note: it is assumed that xmlDoc is already loaded
'--------------------------------------------------------------------

Function ProcessTempSensors(BladeSystem_i, SysChassisSerialNumber)

Dim NoOfTempSensorUnitsMonitored
Dim Unit_i
Dim NoOfUnits
Dim index
Dim i, j
Dim strValue
Dim BCIpAddress, EnclosureName

If NoOfTempSensorUnits &gt; 0 Then

If BCDebug AND BCDEBUG_MIN Then
DebugOut("********** Temp. Sensor Collection **********")
End If

InitNameStatusArray()
BCIpAddress = arrDiscoveryIp(BladeSystem_i)
EnclosureName = arrEnclosureName(BladeSystem_i) &amp; "_" &amp; SysChassisSerialNumber
index = 0
Unit_i = 1
NoOfTempSensorUnitsMonitored = 0
NoOfUnits = NoOfTempSensorUnits

Do While NoOfUnits &gt; 0
If BCDebug AND BCDEBUG_MIN Then
DebugOut("********* Check Temperature Sensor instances")
End If

InitPropertyArray()
nStatus = 0

If BCDebug AND BCDEBUG_MAX Then
DebugOut("Get Temperature Sensor Component Properties of Blade System " &amp; BladeSystem_i)
End If
If GetBCComponent_Properties(BladeSystem_i, BC_ComponentsGroupList(BC_COMP_TEMPSENSORUNIT), Unit_i, TSU + TSU_MIN, TSU_MAX) &gt; 0 Then

If BCDebug AND BCDEBUG_MAX Then
DebugOut("*** Display all Temp Sensor property values:")
For i=TSU_MIN to TSU_MAX
DebugOut(PropertyNameList(TSU + i) &amp; "=" &amp; PropertyArray(i))
Next
End If

If BCDebug AND BCDEBUG_MIN Then
DebugOut("******** Create Temperature Sensor Collection")
End If

If Len(PropertyArray(TSU_ID)) &gt; 0 And Len(PropertyArray(TSU_DESIGNATION)) &gt; 0 Then

If Len(PropertyArray(TSU_STATUS)) &gt; 0 Then
If BCDebug AND BCDEBUG_MAX Then
DebugOut("PropertyArray(TSU)=" &amp; PropertyArray(TSU_STATUS))
End If
nStatus = CInt(PropertyArray(TSU_STATUS))
Else
DebugOut("WARNING: TSU " &amp; Unit_i &amp; " STATUS = UNKNOWN!")
nStatus = TSU_STATUS_UNKNOWN
End If
componentNameArray(index) = PropertyArray(TSU_ID) &amp; ":'" &amp; PropertyArray(TSU_DESIGNATION) &amp; "'; "

If Len(PropertyArray(TSU_CURRENTVALUE)) &gt; 0 Then
componentInfoArray(index) = PropertyArray(TSU_CURRENTVALUE) &amp; "; "
End If

index = index + 1

End If

NoOfUnits = NoOfUnits - 1
Else
If BCDebug AND BCDEBUG_MAX Then
DebugOut("No Properties of Temp Sensor Unit: " &amp; Unit_i)
End If
End If

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

Loop

NoOfTempSensorUnitsMonitored = index
If BCDebug AND BCDEBUG_MIN Then
DebugOut("Number of monitored Temp. Sensor Units = " &amp; NoOfTempSensorUnitsMonitored)
End If

If NoOfTempSensorUnitsMonitored &gt; 0 Then

If insideMP = true Then
If BCDebug AND BCDEBUG_MAX Then
DebugOut("*** Create instance of Temperature Sensor Subsystem")
End If
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.TempSensorSubsystem']$")
Call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", PrincipalName)
Call oInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.MonitorService']/PrincipalName$", PrincipalName)
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure']/SysChassisSerialNumber$", SysChassisSerialNumber)
Call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Temperature Sensors")
Call oInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/ServerName$", EnclosureName)
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.HealthCollection']/IpAddress$", BCIpAddress)
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.HealthCollection']/SysChassisSerialNumber$", SysChassisSerialNumber)
End If

If BCDebug AND BCDEBUG_MAX Then
DebugOut("Collect Temp. Sensor Subsystem Data")
End If

componentNames = "ID / Designation: "
componentInfos = "N/A"

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

If BCDebug AND BCDEBUG_MAX Then
DebugOut("Discovered Temp. Sensor Units: " &amp; componentNames)
DebugOut("Discovered Temp. Sensor Unit Infos: " &amp; componentInfos)
End If

If Len(componentNames) &gt; 2047 Then
componentNames = UCase(Left(componentNames, 2040)) &amp; " ..."
End If
If Len(componentInfos) &gt; 2047 Then
componentInfos = UCase(Left(componentInfos, 2040)) &amp; " ..."
End If

If insideMP = true Then
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.TempSensorSubsystem']/TempSensors$", NoOfTempSensorUnitsMonitored)
Call oInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/Devices$", componentNames)
Call oInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/DevicesInfo$", componentInfos)

If BCDebug AND BCDEBUG_MIN Then
DebugOut("Add Instance of Temp. Sensor Subsystem to OM Data Base")
End If
Call oDiscoveryData.AddInstance(oInst)
Set oInst = Nothing
End If

End If

End If

ProcessTempSensors = array(True, NoOfTempSensorUnitsMonitored)

End Function

'--------------------------------------------------------------------
' Function ProcessCCUs():
' - processes receiving CCU COMM4 files
' - instantiates CCUss
' Note: it is assumed that xmlDoc is already loaded
'--------------------------------------------------------------------

Function ProcessCCUs(BladeSystem_i, SysChassisSerialNumber, compNum)

Dim NoOfConnectUnitsMonitored
Dim Unit_i
Dim NoOfUnits
Dim i, j
Dim subCompNum
Dim strValue
Dim BCIpAddress, EnclosureName
Dim ccuIndex
Dim foundUnits
Dim ccuComponentNameArray(8)
Dim ccuComponentInfoArray(8)

EnclosureName = arrEnclosureName(BladeSystem_i) &amp; "_" &amp; SysChassisSerialNumber
BCIpAddress = arrDiscoveryIp(BladeSystem_i)

For subCompNum = 0 to BC_SUBCOMP_CCU_MAX

If NoOfConnectUnits &gt; 0 Then

foundUnits = 0

If BCDebug AND BCDEBUG_MIN Then
DebugOut("********* Connection Unit Collection *********")
End If

Unit_i = 1
NoOfConnectUnitsMonitored = 0
NoOfUnits = NoOfConnectUnits

Do While NoOfUnits &gt; 0
If BCDebug AND BCDEBUG_MIN Then
DebugOut("********* Check Connection Unit instances")
End If

InitPropertyArray()
nStatus = 0

If BCDebug AND BCDEBUG_MAX Then
DebugOut("Get Connection Unit Component Properties of Blade System " &amp; BladeSystem_i)
End If
If GetBCComponent_Properties(BladeSystem_i, BC_ComponentsGroupList(compNum + subCompNum), Unit_i, CU + CU_MIN, CU_MAX) &gt; 0 Then

foundUnits = foundUnits + 1

If BCDebug AND BCDEBUG_MAX Then
DebugOut("*** Display all Connection Unit property values:")
For i=CU_MIN to CU_MAX
DebugOut(PropertyNameList(CU + i) &amp; "=" &amp; PropertyArray(i))
Next
End If

'*** check if component is available
If Len(PropertyArray(CU_ID)) &gt; 0 And Len(PropertyArray(CU_PRODUCTNAME)) &gt; 0 Then

On Error Resume Next
ccuIndex = int(PropertyArray(CU_ID))
On Error Goto 0

'*** check if component is enabled
If Len(PropertyArray(CU_STATUS)) &gt; 0 Then
If BCDebug AND BCDEBUG_MAX Then
DebugOut("PropertyArray(CU)=" &amp; PropertyArray(CU_STATUS))
End If
nStatus = CInt(PropertyArray(CU_STATUS))
Else
DebugOut("WARNING: CU " &amp; Unit_i &amp; " STATUS = UNKNOWN!")
nStatus = CU_STATUS_UNKNOWN
End If
ccuComponentNameArray(ccuIndex) = PropertyArray(CU_ID) &amp; ":'" &amp; PropertyArray(CU_PRODUCTNAME) &amp; "'; "
If Len(PropertyArray(CU_ADMINURL)) &gt; 0 Then
ccuComponentInfoArray(ccuIndex) = PropertyArray(CU_ID) &amp; ":'" &amp; PropertyArray(CU_ADMINURL) &amp; " ; "
End If
End If
NoOfUnits = NoOfUnits - 1
Else
If BCDebug AND BCDEBUG_MAX Then
DebugOut("No Properties of Connection Unit: " &amp; Unit_i)
End If
End If

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

Loop
End If
Next

componentNames = "ID / Product Name: "
componentInfos = "ID / Admin URLs: "

For i = 1 To 8
If (Len(ccuComponentNameArray(i)) &gt; 0) Or (Len(ccuComponentInfoArray(i)) &gt; 0) Then
NoOfConnectUnitsMonitored = NoOfConnectUnitsMonitored + 1
componentNames = componentNames &amp; ccuComponentNameArray(i)
componentInfos = componentInfos &amp; ccuComponentInfoArray(i)
End If
Next

If NoOfConnectUnitsMonitored &gt; 0 Then

If insideMP = true Then
If BCDebug AND BCDEBUG_MAX Then
DebugOut("*** Create instance of Connection Unit Subsystem")
End If
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.ConnectUnitSubsystem']$")
Call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", PrincipalName)
Call oInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.MonitorService']/PrincipalName$", PrincipalName)
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure']/SysChassisSerialNumber$", SysChassisSerialNumber)
Call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Connection Units")
Call oInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/ServerName$", EnclosureName)
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.HealthCollection']/IpAddress$", BCIpAddress)
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.HealthCollection']/SysChassisSerialNumber$", SysChassisSerialNumber)
End If

If BCDebug AND BCDEBUG_MAX Then
DebugOut("Collect Connection Units Data")
DebugOut("Discovered Connection Units: " &amp; componentNames)
DebugOut("Discovered Connection Units Infos: " &amp; componentInfos)
End If

If insideMP = true Then
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.ConnectUnitSubsystem']/ConnectUnits$", NoOfConnectUnitsMonitored)
Call oInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/Devices$", componentNames)
Call oInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/DevicesInfo$", componentInfos)

If BCDebug AND BCDEBUG_MIN Then
DebugOut("Add Instance of Connection Units Subsystem to OM Data Base")
End If
Call oDiscoveryData.AddInstance(oInst)
Set oInst = Nothing
End If
End If

ProcessCCUs = array(True, foundUnits)

End Function



'--------------------------------------------------------------------
' Function ProcessKVMs():
' - processes receiving KVM COMM4 files
' - instantiates KVMs
' Note: it is assumed that xmlDoc is already loaded
'--------------------------------------------------------------------

Function ProcessKVMs(BladeSystem_i, SysChassisSerialNumber)

Dim NoOfKVMUnitsMonitored
Dim Unit_i
Dim NoOfUnits
Dim index
Dim i, j
Dim strValue
Dim BCIpAddress, EnclosureName

If NoOfKVMUnits &gt; 0 Then

If BCDebug AND BCDEBUG_MIN Then
DebugOut("********* KVM Unit Collection *********")
End If

InitNameStatusArray()
BCIpAddress = arrDiscoveryIp(BladeSystem_i)
EnclosureName = arrEnclosureName(BladeSystem_i) &amp; "_" &amp; SysChassisSerialNumber
Unit_i = 1
index = 0
NoOfKVMUnitsMonitored = 0
NoOfUnits = NoOfKVMUnits

Do While NoOfUnits &gt; 0
If BCDebug AND BCDEBUG_MIN Then
DebugOut("********* Check KVM instances")
End If

InitPropertyArray()
nStatus = 0

If BCDebug AND BCDEBUG_MAX Then
DebugOut("Get KVM Unit Component Properties of Blade System " &amp; BladeSystem_i)
End If
If GetBCComponent_Properties(BladeSystem_i, BC_ComponentsGroupList(BC_COMP_KVMUNIT), Unit_i, KVM + KVM_MIN, KVM_MAX) &gt; 0 Then

If BCDebug AND BCDEBUG_MAX Then
DebugOut("*** Display all KVM Unit property values:")
For i=KVM_MIN to KVM_MAX
DebugOut(PropertyNameList(KVM + i) &amp; "=" &amp; PropertyArray(i))
Next
End If

If Len(PropertyArray(KVM_ID)) &gt; 0 And Len(PropertyArray(KVM_PRODUCTNAME)) &gt; 0 Then

'*** check if component is enabled
If Len(PropertyArray(KVM_STATUS)) &gt; 0 Then
If BCDebug AND BCDEBUG_MAX Then
DebugOut("PropertyArray(KVM)=" &amp; PropertyArray(KVM_STATUS))
End If
nStatus = CInt(PropertyArray(KVM_STATUS))
Else
DebugOut("WARNING: KVM " &amp; Unit_i &amp; " STATUS = UNKNOWN!")
nStatus = KVM_STATUS_UNKNOWN
End If

componentNameArray(index) = PropertyArray(KVM_ID) &amp; ":'" &amp; PropertyArray(KVM_PRODUCTNAME) &amp; "'; "

If Len(PropertyArray(KVM_ADMINURL)) &gt; 0 Then
componentInfoArray(index) = PropertyArray(KVM_ADMINURL) &amp; " ; "
End If

index = index + 1

End If

NoOfUnits = NoOfUnits - 1
Else
If BCDebug AND BCDEBUG_MAX Then
DebugOut("No Properties of KVM Unit: " &amp; Unit_i)
End If
End If

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

NoOfKVMUnitsMonitored = index
If BCDebug AND BCDEBUG_MIN Then
DebugOut("Number of monitored KVM Units = " &amp; NoOfKVMUnitsMonitored)
End If

If NoOfKVMUnitsMonitored &gt; 0 Then

If insideMP = true Then
If BCDebug AND BCDEBUG_MAX Then
DebugOut("*** Create instance of KVM Unit Subsystem")
End If
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.KVMUnitSubsystem']$")
Call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", PrincipalName)
Call oInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.MonitorService']/PrincipalName$", PrincipalName)
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure']/SysChassisSerialNumber$", SysChassisSerialNumber)
Call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "KVM Units")
Call oInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/ServerName$", EnclosureName)
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.HealthCollection']/IpAddress$", BCIpAddress)
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.HealthCollection']/SysChassisSerialNumber$", SysChassisSerialNumber)
End If

If BCDebug AND BCDEBUG_MAX Then
DebugOut("Collect KVM Units Data")
End If

componentNames = "ID / Product Name: "
componentInfos = "Admin URL: "

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

If BCDebug AND BCDEBUG_MAX Then
DebugOut("Discovered Connection Units: " &amp; componentNames)
DebugOut("Discovered Connection Units Infos: " &amp; componentInfos)
End If

If insideMP = true Then
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.KVMUnitSubsystem']/KVMUnits$", NoOfKVMUnitsMonitored)
Call oInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/Devices$", componentNames)
Call oInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/DevicesInfo$", componentInfos)

If BCDebug AND BCDEBUG_MIN Then
DebugOut("Add Instance of KVM Units Subsystem to OM Data Base")
End If
Call oDiscoveryData.AddInstance(oInst)
Set oInst = Nothing
End If

'*** store KVM ID in config file
arrKVMCfg(BladeSystem_i) = "1"


End If

End If

ProcessKVMs = array(True, NoOfKVMUnitsMonitored)

End Function


'--------------------------------------------------------------------
' Function ProcessServerBlades(BladeSystem_i):
' - processes receiving Serverblades COMM4 files
' - instantiates Serverblades
' Note: it is assumed that xmlDoc is already loaded
'--------------------------------------------------------------------

Function ProcessServerBlades(BladeSystem_i, SysChassisSerialNumber)

Dim NoOfServerBladesMonitored
Dim Unit_i
Dim NoOfUnits
Dim index
Dim i, j
Dim strValue
Dim BCIpAddress, EnclosureName
Dim ViomStr

If NoOfServerBlades &gt; 0 Then

If BCDebug AND BCDEBUG_MIN Then
DebugOut("********* Server Blade Collection *********")
End If

InitNameStatusArray()
arrServerBladesCfg(BladeSystem_i) = ""
BCIpAddress = arrDiscoveryIp(BladeSystem_i)
EnclosureName = arrEnclosureName(BladeSystem_i) &amp; "_" &amp; SysChassisSerialNumber
Unit_i = 1
index = 0
NoOfServerBladesMonitored = 0
NoOfUnits = NoOfServerBlades

Do While NoOfUnits &gt; 0
If BCDebug AND BCDEBUG_MIN Then
DebugOut("********* Check ServerBlade instances")
End If

InitPropertyArray()
nStatus = 0

If BCDebug AND BCDEBUG_MAX Then
DebugOut("Get Server Blade Properties of Blade System " &amp; BladeSystem_i)
End If
If GetBCComponent_Properties(BladeSystem_i, BC_ComponentsGroupList(BC_COMP_SERVERBLADE), Unit_i, SRV + SERVER_MIN, SERVER_MAX) &gt; 0 Then

If Len(PropertyArray(SERVER_ID)) &gt; 0 And Len(PropertyArray(SERVER_CUSTOMERPRODUCTNAME)) &gt; 0 Then

'*** check if component is enabled
If Len(PropertyArray(SERVER_STATUS)) &gt; 0 Then
nStatus = CInt(PropertyArray(SERVER_STATUS))
Else
DebugOut("WARNING: Server " &amp; Unit_i &amp; " STATUS = UNKNOWN!")
nStatus = SERVER_STATUS_UNKNOWN
End If

ViomStr = "N/A"
On Error Resume Next
If Len(PropertyArray(SERVER_VIOMSETTINGSTATUS)) &gt; 0 Then
ViomStr = arrViomSettingTab(PropertyArray(SERVER_VIOMSETTINGSTATUS))
End If
On Error Goto 0

'*** Server is monitored
If insideMP = true Then
If BCDebug AND BCDEBUG_MAX Then
DebugOut("*** Create instance of Serverblade")
End If
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.ServerBlade']$")
Call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", PrincipalName)
Call oInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.MonitorService']/PrincipalName$", PrincipalName)
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure']/SysChassisSerialNumber$", SysChassisSerialNumber)

Call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Server Blade " + PropertyArray(SERVER_MIN + SERVER_ID))
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.BladeDevice']/BladeId$", PropertyArray(SERVER_MIN + SERVER_ID))
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.BladeDevice']/SysChassisSerialNumber$", SysChassisSerialNumber)
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.BladeDevice']/BladeType$", "ServerBlade")
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.BladeDevice']/IpAddress$", BCIpAddress)
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.BladeDevice']/BladeSerialnumber$", PropertyArray(SERVER_MIN + SERVER_SERIALNUMBER))
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.BladeDevice']/ProductName$", PropertyArray(SERVER_MIN + SERVER_CUSTOMERPRODUCTNAME))
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.BladeDevice']/ModelName$", PropertyArray(SERVER_MIN + SERVER_MODELNAME))
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.BladeDevice']/Manufacturer$", PropertyArray(SERVER_MIN + SERVER_MANUFACTURER))
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.BladeDevice']/GUID$", PropertyArray(SERVER_MIN + SERVER_GUID))
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.BladeDevice']/HardwareVersion$", PropertyArray(SERVER_MIN + SERVER_HWVERSION))
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.BladeDevice']/FimwareVersion$", PropertyArray(SERVER_MIN + SERVER_FWVERSION))
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.BladeDevice']/BIOSVersion$", PropertyArray(SERVER_MIN + SERVER_BIOSVERSION))
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.BladeDevice']/OSType$", PropertyArray(SERVER_MIN + SERVER_OSTYPE))
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.BladeDevice']/OSVersion$", PropertyArray(SERVER_MIN + SERVER_OSVERSION))
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.BladeDevice']/AssetTag$", PropertyArray(SERVER_MIN + SERVER_ASSETTAG))
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.BladeDevice']/VIOMSettingStatus$", ViomStr)
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.BladeDevice']/ServerHostName$", PropertyArray(SERVER_MIN + SERVER_HOSTNAME))
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.BladeDevice']/BladeSystemName$", EnclosureName)

Call oDiscoveryData.AddInstance(oInst)
Set oInst = Nothing
End If

'*** store blade ID in config file
arrServerBladesCfg(BladeSystem_i) = arrServerBladesCfg(BladeSystem_i) &amp; PropertyArray(SERVER_MIN + SERVER_ID) &amp; ", "

index = index + 1



End If '*** Len(PropertyArray(SERVER_ID)) &gt; 0 And Len(PropertyArray(SERVER_PRODUCTNAME)) &gt; 0

NoOfUnits = NoOfUnits - 1
Else
If BCDebug AND BCDEBUG_MAX Then
DebugOut("No Properties of SRV Unit: " &amp; Unit_i)
End If
End If

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

NoOfServerBladesMonitored = index
If BCDebug AND BCDEBUG_MIN Then
DebugOut("Number of monitored Serverblades = " &amp; NoOfServerBladesMonitored)
End If
End If

ProcessServerBlades = array(True, NoOfServerBladesMonitored)

End Function


'--------------------------------------------------------------------
' Function ProcessStorageBlades(BladeSystem_i):
' - processes receiving Storageblades COMM4 files
' - instantiates Storageblades
' Note: it is assumed that xmlDoc is already loaded
'--------------------------------------------------------------------

Function ProcessStorageBlades(BladeSystem_i, SysChassisSerialNumber)

Dim NoOfStorageBladesMonitored
Dim Unit_i
Dim NoOfUnits
Dim index
Dim i, j
Dim strValue
Dim BCIpAddress, EnclosureName

If NoOfStorageBlades &gt; 0 Then

If BCDebug AND BCDEBUG_MIN Then
DebugOut("********* Storage Blade Collection *********")
End If

InitNameStatusArray()
BCIpAddress = arrDiscoveryIp(BladeSystem_i)
arrStorageBladesCfg(BladeSystem_i) = ""
EnclosureName = arrEnclosureName(BladeSystem_i) &amp; "_" &amp; SysChassisSerialNumber
Unit_i = 1
index = 0
NoOfStorageBladesMonitored = 0
NoOfUnits = NoOfStorageBlades

Do While NoOfUnits &gt; 0
If BCDebug AND BCDEBUG_MIN Then
DebugOut("********* Check StorageBlade instances")
End If

InitPropertyArray()
nStatus = 0

If BCDebug AND BCDEBUG_MAX Then
DebugOut("Get Storage Blade Properties of Blade System " &amp; BladeSystem_i)
End If
If GetBCComponent_Properties(BladeSystem_i, BC_ComponentsGroupList(BC_COMP_STORAGEBLADE), Unit_i, STR + STORAGE_MIN, STORAGE_MAX) &gt; 0 Then

If Len(PropertyArray(STORAGE_ID)) &gt; 0 And Len(PropertyArray(STORAGE_CUSTOMERPRODUCTNAME)) &gt; 0 Then

'*** check if component is enabled
If Len(PropertyArray(STORAGE_STATUS)) &gt; 0 Then
nStatus = CInt(PropertyArray(STORAGE_STATUS))
Else
DebugOut("WARNING: Storage " &amp; Unit_i &amp; " STATUS = UNKNOWN!")
nStatus = STORAGE_STATUS_UNKNOWN
End If
'*** Storage is monitored
If insideMP = true Then
If BCDebug AND BCDEBUG_MAX Then
DebugOut("*** Create instance of Storageblade")
End If
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.StorageBlade']$")
Call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", PrincipalName)
Call oInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.MonitorService']/PrincipalName$", PrincipalName)
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure']/SysChassisSerialNumber$", SysChassisSerialNumber)
Call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Storage Blade " + PropertyArray(STORAGE_MIN + STORAGE_ID))
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.BladeDevice']/BladeId$", PropertyArray(STORAGE_MIN + STORAGE_ID))
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.BladeDevice']/SysChassisSerialNumber$", SysChassisSerialNumber)
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.BladeDevice']/BladeType$", "StorageBlade")
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.BladeDevice']/IpAddress$", BCIpAddress)
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.BladeDevice']/BladeSerialnumber$", PropertyArray(STORAGE_MIN + STORAGE_SERIALNUMBER))
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.BladeDevice']/ProductName$", PropertyArray(STORAGE_MIN + STORAGE_CUSTOMERPRODUCTNAME))
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.BladeDevice']/ModelName$", PropertyArray(STORAGE_MIN + STORAGE_ID))
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.BladeDevice']/HardwareVersion$", PropertyArray(STORAGE_MIN + STORAGE_HWVERSION))
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.BladeDevice']/BIOSVersion$", PropertyArray(STORAGE_MIN + STORAGE_BIOSVERSION))
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.BladeDevice']/AssetTag$", "N/A")
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.BladeDevice']/BladeSystemName$", EnclosureName)

Call oDiscoveryData.AddInstance(oInst)
Set oInst = Nothing
End If

'*** store blade ID in config file
arrStorageBladesCfg(BladeSystem_i) = arrStorageBladesCfg(BladeSystem_i) &amp; PropertyArray(SERVER_MIN + SERVER_ID) &amp; ", "

index = index + 1


End If '*** Len(PropertyArray(STORAGE_ID)) &gt; 0 And Len(PropertyArray(STORAGE_PRODUCTNAME)) &gt; 0

NoOfUnits = NoOfUnits - 1
Else
If BCDebug AND BCDEBUG_MAX Then
DebugOut("No Properties of Storage Blade: " &amp; Unit_i)
End If
End If

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

NoOfStorageBladesMonitored = index
If BCDebug AND BCDEBUG_MIN Then
DebugOut("Number of monitored Storageblades = " &amp; NoOfStorageBladesMonitored)
End If
End If

ProcessStorageBlades = array(True, NoOfStorageBladesMonitored)

End Function

'--------------------------------------------------------------------
' Sub PostProcessBladeDevices()
'--------------------------------------------------------------------

Sub PostProcessBladeDevicesAndKVM()

Dim i

For i = 1 To NoOfBladeSystem
If (Len(arrServerBladesCfg(i)) &gt; 0) Or (Len(arrStorageBladesCfg(i)) &gt; 0) Then
Call GenerateBladeDeviceCfgFile(arrSysChasSerNo(i), arrServerBladesCfg(i), arrStorageBladesCfg(i), arrKVMCfg(i))
End If
Next

End Sub


'--------------------------------------------------------------------
' Sub PostProcessMissingComponents()
'--------------------------------------------------------------------

Sub PostProcessMissingComponents()

Dim i, j
Dim NoOfConnectUnitsMonitored
Dim BCIpAddress, EnclosureName, SysChassisSerialNumber
Dim strEventLogMsg
Dim enclosureInError, componentOK
Dim CommunicationErrorFailedComp, TimeoutErrorFailedComp
Dim strBladeId
Dim bladeIdStr, bladeIdVec

DebugOut("Start PostProcessMissingComponents()")

For i = 1 To NoOfBladeSystem
NoOfConnectUnitsMonitored = 0
componentNames = "Product Name / Model Name: "
componentInfos = "Admin URLs: "
SysChassisSerialNumber = arrSysChasSerNo(i)

'*** check if the whole enclosure is affected
componentOK = false
For j = 1 To COMPLIST_MAX '*** starting from 1: enclosure is excluded
componentOK = componentOK Or responseMatrix(i,j)
Next

'*** not a single component OK?
enclosureInError = not componentOK

If enclosureInError Then
strEventLogMsg = "Communication failure: enclosure not reachable."
Call oAPI.LogScriptEvent("PYBladeSystemEnclosureDiscovery.vbs/" &amp; SysChassisSerialNumber, 406, ERROR_EVENT, strEventLogMsg)
End If

'*** Missing components
CommunicationErrorFailedComp = ""
TimeoutErrorFailedComp = ""

For j = 0 To COMPLIST_MAX

If (arrDoneMatrix(i,j) = false) Or (responseMatrix(i,j) = false) Then
'*** something to do
ErrorsDetected = true
EnclosureName = arrEnclosureName(i) &amp; "_" &amp; SysChassisSerialNumber
BCIpAddress = arrDiscoveryIp(i)

If j = COMPLIST_ENCLOSURE Then
'*** Add only properties which are needed for creating the instance
Set oInstBC = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure']$")
Call oInstBC.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", PrincipalName)
Call oInstBC.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.MonitorService']/PrincipalName$", PrincipalName)
Call oInstBC.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", EnclosureName)
Call oInstBC.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure']/SysChassisSerialNumber$", SysChassisSerialNumber)
Call oInstBC.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure']/ConnectState$", "not connected")
Call oDiscoveryData.AddInstance(oInstBC)
Set oInstBC = Nothing

If (insideMP = true) And (enclosureInError = false) Then
If arrDoneMatrix(i,j) = false Then
CommunicationErrorFailedComp = CommunicationErrorFailedComp &amp; "enclosure, "
Else
TimeoutErrorFailedComp = TimeoutErrorFailedComp &amp; "enclosure, "
End If
End If

'*** If enclosure is missing then other components cannot exist, so skip component handling
Else
If j = COMPLIST_MMBS Then
'*** Add only properties which are needed for creating the instance
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.MMBSubsystem']$")
Call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", PrincipalName)
Call oInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.MonitorService']/PrincipalName$", PrincipalName)
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure']/SysChassisSerialNumber$", SysChassisSerialNumber)
Call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "MMB Units")
Call oInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/ServerName$", EnclosureName)
'*** Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.HealthCollection']/IpAddress$", "N/A")
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.HealthCollection']/SysChassisSerialNumber$", SysChassisSerialNumber)
'*** Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.MMBSubsystem']/MgmtBladeUnits$", "0")
Call oDiscoveryData.AddInstance(oInst)
Set oInst = Nothing


If insideMP = true And (enclosureInError = false) Then
If arrDoneMatrix(i,j) = false Then
CommunicationErrorFailedComp = CommunicationErrorFailedComp &amp; "MMB, "
Else
TimeoutErrorFailedComp = TimeoutErrorFailedComp &amp; "MMB, "
End If
End If
end If


If j = COMPLIST_POWERSUPPLIES Then
'*** Add only properties which are needed for creating the instance
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.PowerSupplySubsystem']$")
Call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", PrincipalName)
Call oInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.MonitorService']/PrincipalName$", PrincipalName)
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure']/SysChassisSerialNumber$", SysChassisSerialNumber)
Call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Power Supply Units")
'*** Call oInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/ServerName$", EnclosureName)
'*** Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.HealthCollection']/IpAddress$", "N/A")
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.HealthCollection']/SysChassisSerialNumber$", SysChassisSerialNumber)
'*** Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.PowerSupplySubsystem']/PowerSupplyUnits$", 0)
Call oDiscoveryData.AddInstance(oInst)
Set oInst = Nothing

If insideMP = true And (enclosureInError = false) Then
If arrDoneMatrix(i,j) = false Then
CommunicationErrorFailedComp = CommunicationErrorFailedComp &amp; "power supply, "
Else
TimeoutErrorFailedComp = TimeoutErrorFailedComp &amp; "power supply, "
End If
End If
end If

If j = COMPLIST_FANS Then
'*** Add only properties which are needed for creating the instance
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.FanSubsystem']$")
Call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", PrincipalName)
Call oInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.MonitorService']/PrincipalName$", PrincipalName)
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure']/SysChassisSerialNumber$", SysChassisSerialNumber)
Call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Fan Units")
'*** Call oInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/ServerName$", EnclosureName)
'*** Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.HealthCollection']/IpAddress$", "N/A")
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.HealthCollection']/SysChassisSerialNumber$", SysChassisSerialNumber)
'*** Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.FanSubsystem']/FanUnits$", 0)
Call oDiscoveryData.AddInstance(oInst)
Set oInst = Nothing

If insideMP = true And (enclosureInError = false) Then
If arrDoneMatrix(i,j) = false Then
CommunicationErrorFailedComp = CommunicationErrorFailedComp &amp; "fans, "
Else
TimeoutErrorFailedComp = TimeoutErrorFailedComp &amp; "fans, "
End If
End If
end If

If j = COMPLIST_TEMPSENSORS Then
'*** Add only properties which are needed for creating the instance
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.TempSensorSubsystem']$")
Call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", PrincipalName)
Call oInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.MonitorService']/PrincipalName$", PrincipalName)
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure']/SysChassisSerialNumber$", SysChassisSerialNumber)
Call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Temperature Sensors")
'*** Call oInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/ServerName$", EnclosureName)
'*** Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.HealthCollection']/IpAddress$", "N/A")
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.HealthCollection']/SysChassisSerialNumber$", SysChassisSerialNumber)
'*** Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.TempSensorSubsystem']/TempSensors$", 0)
Call oDiscoveryData.AddInstance(oInst)
Set oInst = Nothing

If insideMP = true And (enclosureInError = false) Then
If arrDoneMatrix(i,j) = false Then
CommunicationErrorFailedComp = CommunicationErrorFailedComp &amp; "temperature sensors, "
Else
TimeoutErrorFailedComp = TimeoutErrorFailedComp &amp; "temperature sensors, "
End If
End If
end If

If (j = COMPLIST_CONNECTUNITS) Then
'*** Add only properties which are needed for creating the instance
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.ConnectUnitSubsystem']$")
Call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", PrincipalName)
Call oInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.MonitorService']/PrincipalName$", PrincipalName)
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure']/SysChassisSerialNumber$", SysChassisSerialNumber)
Call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Connection Units")
'*** Call oInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/ServerName$", EnclosureName)
'*** Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.HealthCollection']/IpAddress$", "N/A")
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.HealthCollection']/SysChassisSerialNumber$", SysChassisSerialNumber)
'*** Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.ConnectUnitSubsystem']/ConnectUnits$", 0)
Call oDiscoveryData.AddInstance(oInst)
Set oInst = Nothing


If insideMP = true And (enclosureInError = false) Then
If arrDoneMatrix(i,j) = false Then
CommunicationErrorFailedComp = CommunicationErrorFailedComp &amp; "CCU, "
Else
TimeoutErrorFailedComp = TimeoutErrorFailedComp &amp; "CCU, "
End If
End If
end If

If j = COMPLIST_KVMUNITS Then
If Not IsFileOutOfDate(SysChassisSerialNumber, ComponentsList(COMPLIST_KVMUNITS), FILETYPE_MON_RESPONSE, MONITORING_TIMEOUT) Then
bladeIdStr = GetBladeDeviceCfgValue(SysChassisSerialNumber, "Enclosure", "KVM")
If Len(bladeIdStr) &gt; 0 Then
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.KVMUnitSubsystem']$")
Call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", PrincipalName)
Call oInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.MonitorService']/PrincipalName$", PrincipalName)
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure']/SysChassisSerialNumber$", SysChassisSerialNumber)
Call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "KVM Units")
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.HealthCollection']/SysChassisSerialNumber$", SysChassisSerialNumber)
Call oDiscoveryData.AddInstance(oInst)
Set oInst = Nothing
End If
End If

If insideMP = true And (enclosureInError = false) Then
If arrDoneMatrix(i,j) = false Then
CommunicationErrorFailedComp = CommunicationErrorFailedComp &amp; "KVM, "
Else
TimeoutErrorFailedComp = TimeoutErrorFailedComp &amp; "KVM, "
End If
End If
end If

If j = COMPLIST_SERVERBLADES Then

'*** Check if there are instances for server blades for this enclosure
If Not IsFileOutOfDate(SysChassisSerialNumber, ComponentsList(COMPLIST_SERVERBLADES), FILETYPE_MON_RESPONSE, MONITORING_TIMEOUT) Then
bladeIdStr = GetBladeDeviceCfgValue(SysChassisSerialNumber, "Enclosure", "ServerBlades")
bladeIdVec = Split(bladeIdStr,", ")
For Each strBladeId In bladeIdVec
If Len(strBladeId) &gt; 0 Then
'*** create instance and set key properties
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.ServerBlade']$")
Call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", PrincipalName)
Call oInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.MonitorService']/PrincipalName$", PrincipalName)
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure']/SysChassisSerialNumber$", SysChassisSerialNumber)
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.BladeDevice']/SysChassisSerialNumber$", SysChassisSerialNumber)
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.BladeDevice']/BladeId$", strBladeId)
Call oDiscoveryData.AddInstance(oInst)
Set oInst = Nothing
End If
Next

If insideMP = true And (enclosureInError = false) Then
If arrDoneMatrix(i,j) = false Then
CommunicationErrorFailedComp = CommunicationErrorFailedComp &amp; "server blades, "
Else
TimeoutErrorFailedComp = TimeoutErrorFailedComp &amp; "server blades, "
End If
End If
End If
End If

If j = COMPLIST_STORAGEBLADES Then

'*** Check if there are instances for storage blades for this enclosure
If Not IsFileOutOfDate(SysChassisSerialNumber, ComponentsList(COMPLIST_STORAGEBLADES), FILETYPE_MON_RESPONSE, MONITORING_TIMEOUT) Then
bladeIdStr = GetBladeDeviceCfgValue(SysChassisSerialNumber, "Enclosure", "StorageBlades")
bladeIdVec = Split(bladeIdStr,", ")
For Each strBladeId In bladeIdVec
If Len(strBladeId) &gt; 0 Then
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.StorageBlade']$")
Call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", PrincipalName)
Call oInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.MonitorService']/PrincipalName$", PrincipalName)
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure']/SysChassisSerialNumber$", SysChassisSerialNumber)
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.BladeDevice']/SysChassisSerialNumber$", SysChassisSerialNumber)
Call oInst.AddProperty("$MPElement[Name='Fujitsu.PRIMERGY.BladeSystem.Enclosure.BladeDevice']/BladeId$", strBladeId)
Call oDiscoveryData.AddInstance(oInst)
Set oInst = Nothing
End If
Next
If insideMP = true And (enclosureInError = false) Then
If arrDoneMatrix(i,j) = false Then
CommunicationErrorFailedComp = CommunicationErrorFailedComp &amp; "storage blades, "
Else
TimeoutErrorFailedComp = TimeoutErrorFailedComp &amp; "storage blades, "
End If
End If
End If
End If
End If
End If
Next

If Len(CommunicationErrorFailedComp) &gt; 0 Then
strEventLogMsg = "Communication error while discovery: no information for the following component(s): " &amp; CommunicationErrorFailedComp
Call oAPI.LogScriptEvent("PYBladeSystemEnclosureDiscovery.vbs/" &amp; SysChassisSerialNumber, 417, ERROR_EVENT, strEventLogMsg)
DebugOut(strEventLogMsg &amp; SysChassisSerialNumber)
End If

If Len(TimeoutErrorFailedComp) &gt; 0 Then
strEventLogMsg = "Timeout failure while discovery: no information for the following component(s): " &amp; TimeoutErrorFailedComp
Call oAPI.LogScriptEvent("PYBladeSystemEnclosureDiscovery.vbs/" &amp; SysChassisSerialNumber, 427, ERROR_EVENT, strEventLogMsg)
DebugOut(strEventLogMsg &amp; SysChassisSerialNumber)
End If
Next
End Sub

'--------------------------------------------------------------------
' Function CheckCommunicationFile(FilePath):
'--------------------------------------------------------------------

Function CheckCommunicationFile(FilePath)

CONST ForReading = 1
Dim FSO, hFile, fileFound

fileFound = false

On Error Resume Next

'*** create FSO-Object
Set FSO = CreateObject("Scripting.FileSystemObject")
'*** open file for reading
If (FSO.FileExists(FilePath)) Then
'*** open file for reading
Set hFile = FSO.OpenTextFile(FilePath, ForReading)

If BCDebug AND BCDEBUG_FUNC Then
DebugOut("hFile: [" &amp; hFile &amp; "]")
End If

If Not IsNull(hFile) Then
fileFound = true
hFile.close
End If
End If

On Error Goto 0

If BCDebug AND BCDEBUG_FUNC Then
DebugOut("Communication file '" &amp; FilePath &amp; "' found: " &amp; fileFound)
End If

CheckCommunicationFile = fileFound

End Function


'--------------------------------------------------------------------
' Function IsMonitorAgentRunning():
'--------------------------------------------------------------------

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
If BCDebug AND BCDEBUG_MAX 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
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)
DebugOut("Agent State = " &amp; AgentState)
End If

IsMonitorAgentRunning = AgentState

End Function


'--------------------------------------------------------------------
' Function ProcessEnclosures():
'--------------------------------------------------------------------

Function GetMonSvrRegistryValue(strName)

GetMonSvrRegistryValue = GetBCRegistryValue(KEY_MONITOR_SERVICE, strName)

End Function

'--------------------------------------------------------------------
' Function GetBaseRegistryValue(strName):
'--------------------------------------------------------------------

Function GetBaseRegistryValue(strName)

GetBaseRegistryValue = GetBCRegistryValue(KEY_CURRENT_VERSION, strName)

End Function

'--------------------------------------------------------------------
' Function GetBCRegistryValue(strKeyName, strValueName):
'--------------------------------------------------------------------

Function GetBCRegistryValue(strKeyName, strValueName)

Dim regValue, regKey, strValue

'*** strValue = ""

If IsEmpty(Registry) Then
Set Registry = GetObject("winmgmts:{impersonationLevel=impersonate}\\.\root\default:StdRegProv")
End If

If IsEmpty(Registry) Or Err.Number &lt;&gt; 0 Then
DebugOut("#############")
DebugOut("############# Cannot access registry via WMI!")
DebugOut("#############")
Else
regKey = BL_REG_PATH &amp; "\" &amp; strKeyName
regValue = strValueName
Registry.GetStringValue HKEY_LOCAL_MACHINE, regKey, regValue, strValue
End If

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

GetBCRegistryValue = strValue

End Function

'--------------------------------------------------------------------
' Function GetBladeSystemCommunicationFile():
'--------------------------------------------------------------------

Function GetBladeSystemCommunicationFile()

Dim fileName, filePath, strBladeSystemCommFile

If BCDebug AND BCDEBUG_FUNC Then
DebugOut("GetBladeSystemCommunicationFile()")
End If

fileName = ""
BladeSystemCommunicationFilePath = GetBladeSystemCommunicationFilePath()
filePath = BladeSystemCommunicationFilePath

If simulationMode = true Then
If BCDebug AND BCDEBUG_FUNC Then
DebugOut("Ini file path=[" &amp; strLogIniFileNameAbs &amp; "]")
DebugOut("Communication file in simulation mode:")
End If
fileName = GetOpenIniValue(strLogIniFileNameAbs, INISEC_COMMUNICATIONFILE, KEY_NAME)

If BCDebug AND BCDEBUG_FUNC Then
DebugOut("Path=[" &amp; filePath &amp; "], Name=[" &amp; fileName &amp; "]")
End If
End If

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

If Len(fileName) = 0 Then
fileName = GetMonSvrRegistryValue(REGKEY_MS_MANAGEDFILENAME)
End If

If Len(filePath) &gt; 0 And Len(fileName) &gt; 0 Then
strBladeSystemCommFile = filePath &amp; "\" &amp; fileName
If BCDebug AND BCDEBUG_FUNC Then
DebugOut("Communication file path: " &amp; strBladeSystemCommFile)
End If
Else
strBladeSystemCommFile = ABSBCCOMMFILE
If BCDebug AND BCDEBUG_FUNC Then
DebugOut("Communication file by default: " &amp; strBladeSystemCommFile)
End If
End If

GetBladeSystemCommunicationFile = strBladeSystemCommFile

End Function

'--------------------------------------------------------------------
' Function GetBladeSystemCommunicationFilePath():
'--------------------------------------------------------------------

Function GetBladeSystemCommunicationFilePath()

Dim filePath, strBladeSystemCommFilePath

If BCDebug AND BCDEBUG_FUNC Then
DebugOut("GetBladeSystemCommunicationFilePath()")
End If

filePath = ""
strBladeSystemCommFilePath = ""

If simulationMode = true Then
If BCDebug AND BCDEBUG_FUNC Then
DebugOut("Ini file path=[" &amp; strLogIniFileNameAbs &amp; "]")
DebugOut("Communication file in simulation mode:")
End If
filePath = GetOpenIniValue(strLogIniFileNameAbs, INISEC_COMMUNICATIONFILE, KEY_DIRECTORY)

If BCDebug AND BCDEBUG_FUNC Then
DebugOut("Path=[" &amp; filePath &amp; "]")
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
' *** if we do not have the communication file path, we can do nothing - but abort!
strEventLogMsg = "Could not determine communication file path - script ends here!"
If insideMP = true Then
Call oAPI.LogScriptEvent("PYBladeSystemEnclosureDiscovery.vbs/", 406, ERROR_EVENT, strEventLogMsg)
End If
DebugOut(strEventLogMsg)
Wscript.Quit(-1)
End If


If BCDebug AND BCDEBUG_MIN Then
DebugOut("Communication file path = " &amp; strBladeSystemCommFilePath)
End If

GetBladeSystemCommunicationFilePath = strBladeSystemCommFilePath

End Function

'--------------------------------------------------------------------
' Sub InitPropertyArray():
'--------------------------------------------------------------------

Sub InitPropertyArray()

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

End Sub

'--------------------------------------------------------------------
' Sub InitNameStatusArray():
'--------------------------------------------------------------------

Sub InitNameStatusArray()

'*** 102 (cMAXINDEX) elements in every array available ***

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

componentInfoArray = array("", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", _
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "")

componentNames = ""
componentInfos = ""

End Sub


'--------------------------------------------------------------------
' Function GetBC_Properties(BC_number):
'--------------------------------------------------------------------

Function GetBC_Properties(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, FILETYPE_RESP)

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, FILETYPE_RESP)
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 = CInt(count)

End Function

'------------------------------------------------------------------------------------------------------------------
' Function GetBCComponent_Properties(BC_Number, ComponentName, ComponentNo, key_property_index, property_maxIndex):
'------------------------------------------------------------------------------------------------------------------


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, FILETYPE_RESP)
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, FILETYPE_RESP )

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

'--------------------------------------------------------------------
' Sub GetLogFileIni(FilePathName, Section):
'--------------------------------------------------------------------


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
BCDebug = GetOpenIniValue(FilePathName, Section, INIKEY_DEBUGLEVEL)
End If

End Sub

'--------------------------------------------------------------------
' Function CheckSimulationMode(FilePathName)
'--------------------------------------------------------------------


Function CheckSimulationMode(FilePathName)

Dim simMode, iniVal

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
DebugOut("*** Simulation mode is active ***")
End If

'### On Error Goto 0

CheckSimulationMode = simMode

End Function

'--------------------------------------------------------------------
' Function GetNoOfBladeSystems(xmlDoc)
'--------------------------------------------------------------------


Function GetNoOfBladeSystems(xmlDoc)

Dim xmlDocElement, xmlServerNode, xmlNoOfSystems, xmlServerComponentsNodes
Dim NoOfBladeSystems


Set xmlDocElement = xmlDoc.documentElement
Set xmlServerNode = xmlDoc.selectNodes("*/Server")
'Set xmlServerComponentsNodes = xmlDoc.selectNodes("*/Server/Components")
Set xmlServerComponentsNodes = xmlDoc.selectNodes("*/Server/Group/Components")

'Read element "NoOfSystems"
Set xmlNoOfSystems = xmlDoc.selectNodes("*/NoOfServers")
NoOfBladeSystems = xmlNoOfSystems.item(0).Text

If BCDebug AND BCDEBUG_FUNC Then
DebugOut("No of Blade Systems: " &amp; NoOfBladeSystems)
End If
GetNoOfBladeSystems = NoOfBladeSystems

End Function

'------------------------------------------------------------------------------------------
' Function GetXMLComponentsPropertyValue(xmlDoc, nServerNo, strComponent, strPropertyName, fileType)
'------------------------------------------------------------------------------------------


Function GetXMLComponentsPropertyValue(xmlDoc, nServerNo, strComponent, strPropertyName, fileType)

Dim xmlDocElement, xmlServerNode, xmlServerGroupNode, xmlNoOfSystems, xmlServerComponentsNodes
Dim xmlNameOfComponent, xmlComponentNode, xmlElementListNode
Dim i, j, k, l, xmlName, xmlValue
Dim varPropertyValue
Dim bValueFound, bValueInComponentNode
Dim NodeName, ServerNumber
Dim NoOfBladeSystems
Dim strCompare


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")
Set xmlServerComponentsNodes = xmlDoc.selectNodes("*/Server/Components")

If BCDebug AND BCDEBUG_FUNC Then
DebugOut("No of nodes in Doc: " &amp; xmlDocElement.childNodes.length)
End If

'Read element "NoOfSystems"
'Set xmlNoOfSystems = xmlDoc.selectNodes("*/NoOfServers")
'NoOfBladeSystems = xmlNoOfSystems.item(0).Text
' This was changed. We use 1 file for 1 system. Thus:
NoOfBladeSystems = 1
If BCDebug AND BCDEBUG_FUNC Then
DebugOut("No of Blade Systems: " &amp; NoOfBladeSystems)
End If

bValueFound = false
bValueInComponentNode = true

For i=0 To xmlDocElement.childNodes.length-1

NodeName = xmlDocElement.childNodes.item(i).nodeName
'*** We have different evaluations according file types
If fileType = FILETYPE_MNGD_NODES Then
ServerNumber = xmlDocElement.childNodes.item(i).getAttribute("Number")
End If
If BCDebug AND BCDEBUG_FUNC Then
If NodeName = "Server" Then
DebugOut("Blade System No.: " &amp; ServerNumber)
End If
End If

If NodeName = "Server" Then
If (fileType = FILETYPE_MNGD_NODES And ((nServerNo = ServerNumber) Or (nServerNo = CInt(ServerNumber)))) Or fileType &lt;&gt; FILETYPE_MNGD_NODES 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")
If BCDebug AND BCDEBUG_FUNC Then
DebugOut("Node Components = " &amp; xmlNameOfComponent)
End If
If xmlNameOfComponent = strComponent Then
Set xmlComponentNode = xmlServerNode.childNodes.Item(j)
If BCDebug AND BCDEBUG_FUNC Then
DebugOut("No of Components subelements: " &amp; xmlComponentNode.childNodes.length)
End If

For k=0 To xmlComponentNode.childNodes.length-1
Set xmlElementListNode = xmlComponentNode.childNodes.Item(k)
If BCDebug AND BCDEBUG_FUNC Then
DebugOut("No of ListElements: " &amp; xmlElementListNode.childNodes.length)
End If
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_MAX Then
If bValueFound = false Then
DebugOut("Property value of key '" &amp; strPropertyName &amp; "' not found")
End If
End If


GetXMLComponentsPropertyValue = varPropertyValue

End Function

'--------------------------------------------------------------------
' Function GetOpenIniValue(FilePathName, Section, KeyValue)
'--------------------------------------------------------------------

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
DebugOut("File " &amp; FilePathName &amp; " does not exist!")
End If

'### On Error Goto 0

If BCDebug AND BCDEBUG_FUNC Then
DebugOut("IniValue = " &amp; value )
End If
GetOpenIniValue = value

End Function

'--------------------------------------------------------------------
' Function GetIniValue(FileName, Section, KeyValue)
'--------------------------------------------------------------------

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; FileName &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

'--------------------------------------------------------------------
' Sub CreateLogIniFile(LogIniFileDir)
'--------------------------------------------------------------------

Sub CreateLogIniFile(LogIniFileDir)

CONST SVISCOMBLLogIn_ = "SVISCOM-BL.Log.in_"

Dim oFSO 'As Scripting.FileSystemObject
Dim oTextStream 'As Scripting.TextStream
Dim LogIniFilePath

On Error Resume Next

Set oFSO = CreateObject("Scripting.FileSystemObject")
LogIniFilePath = LogIniFileDir &amp; "\" &amp; SVISCOMBLLogIn_
If Not (oFSO.FileExists(LogIniFilePath)) Then
If Not oFSO.FolderExists(LogIniFileDir) Then
oFSO.CreateFolder(LogIniFileDir)
End If

Set oTextStream = oFSO.OpenTextFile(LogIniFilePath, 2, True) ' 2 = new file for writing
If Not IsNull(oTextStream) Then
oTextStream.WriteLine "[BladeSystemDiscovery]"
oTextStream.WriteLine "DebugMode=yes"
oTextStream.WriteLine "DebugLevel=15" &amp; vbCrLf
oTextStream.WriteLine "[BladeComponentsMonitor]"
oTextStream.WriteLine "DebugMode=yes"
oTextStream.WriteLine "DebugLevel=15" &amp; vbCrLf
oTextStream.Close
End If
End If

On Error Goto 0

End Sub


'--------------------------------------------------------------------
' Function MonitoringOnDemand()
'--------------------------------------------------------------------

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


cmdReturnFile = TEMP &amp; "\PYMonitorReturn.txt"


MonitoringControlCode = GetConfigFileEntry("//*/Monitoring/ControlCode")


If Len(MonitoringControlCode) = 0 Then
' can't help it - try DEFAULT
MonitoringControlCode = CONTROLCODE_MONITORING
End If


If BCDebug AND BCDEBUG_MIN OR BCDebug AND BCDEBUG_FUNC Then
DebugOut("MonitoringOnDemand(), ControlCode = " &amp; MonitoringControlCode)
End If


strQuery = "Select * from Win32_Service Where Name=""" &amp; BLADESYSTEMMONITORSERVICE &amp; """"
If BCDebug AND BCDEBUG_FUNC Then
DebugOut(strQuery)
End If

Set objWMIService = GetObject("winmgmts:" &amp; "{impersonationLevel=impersonate}!\\" &amp; strComputer &amp; "\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery (strQuery)

For Each objService in colListOfServices
result = objService.UserControlService(MonitoringControlCode)
Next

If BCDebug AND BCDEBUG_FUNC Then
DebugOut("Return code from WMI control command" &amp; BLADESYSTEMMONITORSERVICE &amp; ": " &amp; result)
End If

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

CmdBuf = "SC control " &amp; BLADESYSTEMMONITORSERVICE &amp; " " &amp; MonitoringControlCode
If BCDebug AND BCDEBUG_FUNC Then
DebugOut(CmdBuf)
End If

CmdRet = WshShell.Run("cmd /c " &amp; CmdBuf &amp; " &gt;" &amp; cmdReturnFile, 0, true)

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

MonitoringOnDemand = result

End Function

'--------------------------------------------------------------------
' Sub CreateLogFile(strFileName, isLogFile)
'--------------------------------------------------------------------

Sub CreateLogFile(strFileName, 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 = "********** " &amp; Computer &amp; sLogString &amp; strFileName &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(strFileName)) Then
oFSO.CreateFolder(oFSO.GetParentFolderName(strFileName))
End If
Set oTextStream = oFSO.OpenTextFile(strFileName, 2, True) ' 2 = new file for writing
oTextStream.WriteLine sMessage
oTextStream.WriteLine sMPVersion
oTextStream.Close

DebugFile = true

On Error Goto 0

End Sub

'--------------------------------------------------------------------
' Sub DebugOut(Text)
'--------------------------------------------------------------------

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

'--------------------------------------------------------------------
' Sub DebOut(Text)
'--------------------------------------------------------------------

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")
Set oTextStream = oFSO.OpenTextFile(strDebugFilePath, 8, True) ' 8 = append
oTextStream.WriteLine sMessage
oTextStream.Close

On Error Goto 0
End If
End Sub

'--------------------------------------------------------------------
' Sub CreateDiscoveryDoneFile()
'--------------------------------------------------------------------

Sub CreateDiscoveryDoneFile()
Dim strCommand
Dim FSO1

Set FSO1 = CreateObject("Scripting.FileSystemObject")

On Error Resume Next

' '*** create "DISCOVERY done" file to show, DISCOVERY is done
Call CreateLogFile(absDiscoveryDoneFileName, FALSE)
If FSO1.FileExists(absDiscoveryDoneFileName) = FALSE Then
'*** another try ...
Call CreateLogFile(absDiscoveryDoneFileName, FALSE)
If FSO1.FileExists(absDiscoveryDoneFileName) = FALSE Then
DebugOut("HELP and QUIT: Error creating file " &amp; absDiscoveryDoneFileName)
End If
End If

If BCDebug AND BCDEBUG_MAX Then
strCommand = "eventcreate /L " &amp; strBladeSystemErrorLogName &amp; " /T Information /SO " &amp; _
Chr(34) &amp; "SVISCOM-BL Discovery" &amp; Chr(34) &amp; " /ID 498 /D " &amp; Chr(34) &amp; _
"SVISCOM-BL: DISCOVERY cycle done." &amp; Chr(34)

WshShell.Run strCommand
End If

On Error Goto 0

End Sub

'--------------------------------------------------------------------
' Function GetConfigFileEntry(ConfigFileEntry)
'--------------------------------------------------------------------

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

'--------------------------------------------------------------------------------------------------
' Function ComposeFilename(ChassisSN, component, fileType)
'--------------------------------------------------------------------------------------------------

Function ComposeFilename(ChassisSN, component, fileType)

Dim tmpFile

Select Case fileType
Case FILETYPE_RESPONSE
tmpFile = BladeSystemCommunicationFilePath &amp; "\Blade_" &amp; ChassisSN &amp; "_" &amp; component &amp; "_" &amp; "comm.xml"
Case FILETYPE_CMD
tmpFile = BladeSystemCommunicationFilePath &amp; "\CMD_" &amp; ChassisSN &amp; "_" &amp; component &amp; ".xml"
Case FILETYPE_MON_RESPONSE
tmpFile = BladeSystemCommunicationFilePath &amp; "\Blade_" &amp; ChassisSN &amp; "_" &amp; component &amp; "Mon_" &amp; "comm.xml"
Case FILETYPE_CMD_TEMPLATE
tmpFile = BladeSystemCommunicationFilePath &amp; "\TEMPLATE\CMD_Template_" &amp; component &amp; ".xml"
Case FILETYPE_CFG_TEMPLATE
tmpFile = BladeSystemCommunicationFilePath &amp; "\TEMPLATE\CFG_Template_" &amp; component &amp; ".xml"
Case FILETYPE_CFG_OUTPUT
tmpFile = BladeSystemCommunicationFilePath &amp; "\CFG_" &amp; ChassisSN &amp; "_" &amp; component &amp; ".xml"
Case Else
'*** wrong file type
End Select

ComposeFilename = tmpFile

End Function

'--------------------------------------------------------------------------------------------------
' Sub GenerateCmdFile(ChassisSN, component, IPaddress)
'--------------------------------------------------------------------------------------------------

Sub GenerateCmdFile(ChassisSN, component, IPaddress)

Dim templFile, outpFile
Dim xmlCMDDoc
Dim server
Dim tmp

DebugOut("Start: GenerateCmdFile()")

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

templFile = ComposeFilename(ChassisSN, 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 GenerateBladeDeviceCfgFile(SysChassisSerialNumber, serverCfg, storageCfg)
'--------------------------------------------------------------------------------------------------

Sub GenerateBladeDeviceCfgFile(SysChassisSerialNumber, serverCfg, storageCfg, kvmCfg)

Dim templFile, outpFile
Dim xmlCMDDoc
Dim server
Dim tmp

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

templFile = ComposeFilename(SysChassisSerialNumber, "Enclosure", FILETYPE_CFG_TEMPLATE)
xmlCMDDoc.load(templFile)

If xmlCMDDoc.parseError.errorCode &lt;&gt; 0 Then
DebugOut("-- GenerateCfgFile: parse error when updating template")
Else
Set server = xmlCMDDoc.selectSingleNode("//Server")
tmp = "ServerBlades"
Call server.setAttribute(tmp,serverCfg)
tmp = "StorageBlades"
Call server.setAttribute(tmp,storageCfg)
tmp = "KVM"
Call server.setAttribute(tmp,kvmCfg)
outpFile = ComposeFilename(SysChassisSerialNumber, "Enclosure", FILETYPE_CFG_OUTPUT)
xmlCMDDoc.Save(outpFile)
End If
Set xmlCMDDoc = Nothing

End Sub


'--------------------------------------------------------------------------------------------------
' Function GetBladeDeviceCfgValue(SysChassisSerialNumber, valName)
'--------------------------------------------------------------------------------------------------

Function GetBladeDeviceCfgValue(SysChassisSerialNumber, component, valName)

Dim templFile, outpFile
Dim xmlCMDDoc
Dim server
Dim val

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

templFile = ComposeFilename(SysChassisSerialNumber, component, FILETYPE_CFG_OUTPUT)
xmlCMDDoc.load(templFile)

If xmlCMDDoc.parseError.errorCode &lt;&gt; 0 Then
DebugOut("-- GetBladeDeviceCfgValue: parse error when updating template")
Else
Set server = xmlCMDDoc.selectSingleNode("//Server")
val = server.getAttribute(valName)
End If
Set xmlCMDDoc = Nothing

GetBladeDeviceCfgValue = val

End Function



'--------------------------------------------------------------------------------------------------
' Sub GenerateDiscoveryCmdFileForAllComp(ChassisSN, IPaddress)
'--------------------------------------------------------------------------------------------------

Sub GenerateDiscoveryCmdFileForAllComp(ChassisSN, IPaddress)

Call GenerateCmdFile(ChassisSN, "MMBUnitsDis", IPaddress)
Call GenerateCmdFile(ChassisSN, "PowerSupplyUnitsDis", IPaddress)
Call GenerateCmdFile(ChassisSN, "FanUnitsDis", IPaddress)
Call GenerateCmdFile(ChassisSN, "TempSensorsDis", IPaddress)
Call GenerateCmdFile(ChassisSN, "ConnectUnitsDis", IPaddress)
Call GenerateCmdFile(ChassisSN, "KVMUnitsDis", IPaddress)
Call GenerateCmdFile(ChassisSN, "ServerBladesDis", IPaddress)
Call GenerateCmdFile(ChassisSN, "StorageBladesDis", IPaddress)
End Sub


'--------------------------------------------------------------------------------------------------
' Sub GenerateSelectedDiscoveryCmdFile(ChassisSN, IPaddress, CompNum)
'--------------------------------------------------------------------------------------------------

Sub GenerateSelectedDiscoveryCmdFile(ChassisSN, IPaddress, CompNum)

Select Case CompNum
Case COMPLIST_ENCLOSURE
Call GenerateCmdFile(ChassisSN, "EnclosureDis", IPaddress)
Case COMPLIST_MMBS
Call GenerateCmdFile(ChassisSN, "MMBUnitsDis", IPaddress)
Case COMPLIST_POWERSUPPLIES
Call GenerateCmdFile(ChassisSN, "PowerSupplyUnitsDis", IPaddress)
Case COMPLIST_FANS
Call GenerateCmdFile(ChassisSN, "FanUnitsDis", IPaddress)
Case COMPLIST_TEMPSENSORS
Call GenerateCmdFile(ChassisSN, "TempSensorsDis", IPaddress)
Case COMPLIST_CONNECTUNITS
Call GenerateCmdFile(ChassisSN, "ConnectUnitsDis", IPaddress)
Case COMPLIST_KVMUNITS
Call GenerateCmdFile(ChassisSN, "KVMUnitsDis", IPaddress)
Case COMPLIST_SERVERBLADES
Call GenerateCmdFile(ChassisSN, "ServerBladesDis", IPaddress)
Case COMPLIST_STORAGEBLADES
Call GenerateCmdFile(ChassisSN, "StorageBladesDis", IPaddress)
End Select
End Sub





'--------------------------------------------------------------------
' GetBCNumberFromSN(snStr):
'
' Note: it is assumed that xmlDoc li already loaded
'--------------------------------------------------------------------

Function GetChassisSNFromResponeFile(responseFile)

Dim strEventLogMsg
Dim server
Dim sn

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

If (sn = Null) or (Len(sn)) = 0 Then
'*** no valid string found
strEventLogMsg = "XML file invalid, XML-file: " &amp; responseFile
If insideMP = true Then
Call oAPI.LogScriptEvent("PYBladeSystemEnclosureDiscovery.vbs", 409, ERROR_EVENT, strEventLogMsg)
End If
End If

GetChassisSNFromResponeFile = sn
End Function

'--------------------------------------------------------------------
' GetBCNumberFromSN(snStr):
'--------------------------------------------------------------------

Function GetBCNumberFromSN(snStr)

Dim i
Dim done

done = false
i = 0

Do Until (i &gt; BCNUM_MAX_INDEX) or (done = true)
If StrComp(arrSysChasSerNo(i), snStr, 1) = 0 Then
done = true
Else
i = i + 1
End If
Loop

If done = true Then
GetBCNumberFromSN = i
Else
GetBCNumberFromSN = -1
End If

End Function


'--------------------------------------------------------------------
' GetBCNumberFromSN(snStr):
'--------------------------------------------------------------------

Function SetDoneMatrix(bcNumber, componentNumber, value)

Dim i
Dim done

done = false
i = 0

Do Until (i &gt; BCNUM_MAX_INDEX) or (done = true)
If StrComp(arrSysChasSerNo(i), snStr, 1) = 0 Then
done = true
Else
i = i + 1
End If
Loop

If done = true Then
GetBCNumberFromSN = i
Else
GetBCNumberFromSN = -1
End If
End Function


'--------------------------------------------------------------------------------------------------
' Function FileAge(fileObject)
'--------------------------------------------------------------------------------------------------

Function FileAge(fileObject)

Dim diffsec, acc1, mod1

DebugOut("Start: FileAge")

FileAge = 0

On Error Resume Next
acc1 = fileObject.DateLastAccessed
mod1 = fileObject.DateLastModified

If mod1 &gt; acc1 Then
acc1 = mod1
End If
diffsec = acc1 - StartTime
FileAge = Second(diffsec)
On Error Goto 0

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

If BCDebug AND BCDEBUG_FUNC Then
DebugOut("Start: IsFileOutOfDate() ...")
End If

Set FSO = CreateObject("Scripting.FileSystemObject")

tmpFile = ComposeFilename(ChassisSN, component, fileType)
If FSO.FileExists(tmpFile) = false Then
fileOutOfDate = true
Else
On Error Resume Next
Set file1 = FSO.GetFile(tmpFile)
acc1 = file1.DateLastAccessed
mod1 = file1.DateLastModified
On Error Goto 0

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

If BCDebug AND BCDEBUG_FUNC Then
DebugOut("IsFileOutOfDate = " &amp; IsFileOutOfDate)
End If
End Function



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


Main()


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