' Create/Open a log file for writing error logs
If logLevel <> 0 Then
Dim fileSize, strOutFile
Const strFileName = "DellServerHWComponent.log"
Const ForAppending = 8
Const ForWriting = 2
Const MaxFileSize = 524288 'File Size is limited to 512 KB
dim wsShell : Set wsShell = Createobject("WScript.Shell")
dim wshSysEnv : Set wshSysEnv = wsShell.Environment
dim tFolder : tFolder = wshSysEnv("TEMP")
dim wshPrcEnv : Set wshPrcEnv = wsShell.Environment("Process")
tFolder = Replace(tFolder, "%SystemRoot%", wshPrcEnv("SYSTEMROOT"), 1, -1, vbTextCompare)
Set objLogFSO = CreateObject("Scripting.FileSystemObject")
If Not objLogFSO.FolderExists(tFolder) Then
objLogFSO.CreateFolder(tFolder)
End If
strOutFile = tFolder &"\"& strFileName
If Not objLogFSO.FileExists(strOutFile) Then
Set objLogTextFile = objLogFSO.CreateTextFile(strOutFile)
objLogTextFile.Close
End If
fileSize = objLogFSO.GetFile(strOutFile).Size
If (fileSize > MaxFileSize) Then
Set objLogTextFile = objLogFSO.OpentextFile(strOutFile, ForWriting, True)
Else
Set objLogTextFile = objLogFSO.OpentextFile(strOutFile, ForAppending, True)
End If
logMessage = Now & " DEBUG: Script - Dell Server HardwareComponent Discovery : Start()"
MOMDebugLog 1, logMessage
Err.Clear
End If
set objDellConnection = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2\Dell")
If IsEmpty(objDellConnection) Or (Err.Number <> 0) Then
logMessage = "Unable to open WMI Namespace root-cimv2-dell. Check to see if the WMI service is enabled and running, and Install/Re-Install ServerAdministrator to ensure this WMI namespace exists. " & Err
MOMDebugLog 1, logMessage
Else
DiscoverProc procFlag
DiscoverMem memFlag
DiscoverPS psFlag
MOMDebugLog 1, "Calling DiscoverStorage()"
DiscoverStorage()
DiscoverLCC()
End If
If procFlag = 1 Then
set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Dell.WindowsServer.Processors']$")
call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", targetComputer)
call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.LogicalDevice']/DeviceID$", targetComputer)
call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Processors")
call oDiscoveryData.AddInstance(oInst)
End If
If memFlag = 1 Then
set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Dell.WindowsServer.Memory']$")
call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", targetComputer)
call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.LogicalDevice']/DeviceID$", targetComputer)
call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Memory")
call oDiscoveryData.AddInstance(oInst)
End If
If psFlag = 1 Then
set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Dell.WindowsServer.PowerSupply']$")
call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", targetComputer)
call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.LogicalDevice']/DeviceID$", targetComputer)
call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Power Supply")
call oDiscoveryData.AddInstance(oInst)
End If
MOMDebugLog 1, "adding the storage component"
If storageFlag = 1 Then
set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Dell.WindowsServer.Storage']$")
call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", targetComputer)
call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.LogicalDevice']/DeviceID$", targetComputer)
call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Storage")
call oDiscoveryData.AddInstance(oInst)
End If
MOMDebugLog 1, "finished adding the storage component"
Dim variDRACFirmwareVersion
GetiDRACFirmwareVersion variDRACFirmwareVersion
' For LCCStorageCycle
If lccFlag = 1 Then
If ((varOMSAVersion >= BASE_OMSA_VERSION_IDRAC_DISCOVERY)) Then
set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Dell.WindowsServer.LifeCycleController']$")
call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", targetComputer)
call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.LogicalDevice']/DeviceID$", targetComputer)
call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "iDRAC")
call oInst.AddProperty("$MPElement[Name='Dell.WindowsServer.LifeCycleController']/CardDeviceStorageSize$", varCardDeviceStorageSize)
call oInst.AddProperty("$MPElement[Name='Dell.WindowsServer.LifeCycleController']/FirmwareVersion$", variDRACFirmwareVersion)
call oDiscoveryData.AddInstance(oInst)
End If
End If
' For LCCStorageCycle
' Submit the data
Call oAPI.Return(oDiscoveryData)
logMessage = Now & " DEBUG: Script - Dell Server HardwareComponent Discovery : End()"
MOMDebugLog 1, logMessage
Set oDiscoveryData = Nothing
Set oAPI = Nothing
Set objDellConnection = Nothing
' Close file used for logs
If logLevel <> 0 Then
objLogTextFile.Close
Set objLogTextFile = Nothing
Set objLogFSO = Nothing
End If
' **********************************************
' End Main
' **********************************************
'*****************************************************************
'GetiDRACFirmwareVersion
'Routine to determine current iDRAC Firmware version
'*****************************************************************
Public Function GetiDRACFirmwareVersion (ByRef variDRACFirmwareVersion)
On Error Resume Next
Dim WbemServices, wbemObjectSet, logMessage
Dim strComputer: strComputer = "."
Const IDRAC_STRING = "DRAC"
Set WbemServices = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2\dell")
If (WbemServices is Nothing) Or (IsEmpty(WbemServices)) Or (Err.Number <> 0) Then
logMessage = " ERROR: Unable to open WMI Namespace root-cimv2. Check to see if the WMI service is enabled and running, and ensure this WMI namespace exists." & Err.Description
MOMDebugLog 1, logMessage
Err.Clear
else
Set wbemObjectSet = GetObjectSet(wbemServices, "Select * from Dell_Firmware", "Version", "Dell_Firmware")
If Err.Number <> 0 Then
logMessage = " ERROR: Unable to retrieve Dell_Firmware . Err Number:" & Err.Number & "Description:" & Err.Description
MOMDebugLog 1, logMessage
Err.Clear
End If
If wbemObjectSet is Nothing Then
logMessage = "INFO: Unable to retrieve Dell_Firmware Attributes"
MOMDebugLog 1, logMessage
Err.Clear
Else
logMessage = "INFO: Dell_Firmware attributes retrieved successfully"
MOMDebugLog 1, logMessage
Dim objItem
For Each objItem in wbemObjectSet
'Error checking
If Err.Number <> 0 Then
logMessage = " ERROR: Object loop retrieval error. ErrNumber:" & Err.Number & "Description:" & Err.Description
MOMDebugLog 1, logMessage
Err.Clear
End If
'Object Retrieval
If not objItem is nothing Then
If (InStr(objItem.Name,IDRAC_STRING) <> 0) Then
variDRACFirmwareVersion = objItem.Version
End If
End If
Next
logMessage = " iDRAC Firmware Version : " & variDRACFirmwareVersion
MOMDebugLog 1, logMessage
End If
End If
Set wbemObjectSet = Nothing
Set WbemServices = nothing
End Function
'*************************************************************************
' Function : DiscoverMem()
' Desc : To return flag whether to create Memory Group for HardwareComponentDiscovery
' Arguments : memFlag byreference
'*************************************************************************
Function DiscoverMem(ByRef memFlag)
On Error Resume Next
Dim sQuery, colItems, objItemMem, count1
sQuery = "Select * from CIM_PhysicalMemory"
Set colItems = GetObjectSet(objDellConnection, sQuery, "Name", "CIM_PhysicalMemory")
If Err.Number <> 0 Then
logMessage = sQuery & " Error Number:" & Err.Number & "Description:" & Err.Description
MOMDebugLog 1, logMessage
If Err.Number = -2147023169 Then
logMessage = "RPC Failure occurred for namespace root-cimv2-dell"
MOMDebugLog 1, logMessage
End If
Err.Clear
End If
If (colItems is Nothing) or (IsNull(colItems)) Then
logMessage = "Unable to retrieve Mem Unit"
MOMDebugLog 1, logMessage
Err.Clear
Else
logMessage = "Mem Unit query retrieved successfully"
count1 = colItems.count
If count1 > 0 Then
memFlag = 1
End If
End If
Set colItems = Nothing
End Function
'*************************************************************************
' Function : DiscoverLCC()
' Desc : To determine the existence of iDRAC6
' Arguments : None
'*************************************************************************
Public Function DiscoverLCC ()
'Checking the existence of iDRAC6
On Error Resume Next
Dim sQuery, colItems, objItem, device, count1
ExecRacCmd ""
if lccFlag = 1 Then
varCardDeviceStorageSize = "Not Available"
End If
sQuery = "Select * from DELL_ManagedSystemServicesDevice"
Set colItems = GetObjectSet(objDellConnection, sQuery, "deviceSize", "DELL_ManagedSystemServicesDevice")
If Err.Number <> 0 Then
logMessage = " ERROR: Unable to retrieve DELL_ManagedSystemServicesDevice for LCC. Err Number:" & Err.Number & "Description:" & Err.Description
MOMDebugLog 1, logMessage
Err.Clear
End If
If (colItems is Nothing) or (IsNull(colItems)) Then
logMessage = " ERROR: Unable to retrieve DELL_ManagedSystemServicesDevice for LCC"
MOMDebugLog 1, logMessage
Err.Clear
Else
logMessage = "INFO: DELL_ManagedSystemServicesDevice for LCC retrieved successfully"
MOMDebugLog 1, logMessage
count1 = colItems.count
If count1 > 0 Then
lccFlag = 1
'Object Retrieval
For Each objItem in colItems
If not objItem is nothing Then
varCardDeviceStorageSize = objItem.deviceSize
device = objItem.deviceType
If device = 0 Then
varCardDeviceStorageSize = varCardDeviceStorageSize & " MB (Base managed device)"
ElseIf device = 1 Then
varCardDeviceStorageSize = varCardDeviceStorageSize & " MB (Optional managed device)"
End if
End If
Next
'*************************************************************************
' Function : DiscoverPS()
' Desc : To return flag whether to create PowerSupplyGroup for HardwareComponentDiscovery
' Arguments : psFlag byreference
'*************************************************************************
Function DiscoverPS(ByRef psFlag)
'Retrieving PS Units
On Error resume next
Dim sQuery, colItems, objItemPS, count1
sQuery = "Select * from CIM_PowerSupply"
Set colItems = GetObjectSet(objDellConnection, sQuery, "Name", "CIM_PowerSupply")
If Err.Number <> 0 Then
logMessage = sQuery & " Error Number:" & Err.Number & "Description:" & Err.Description
MOMDebugLog 1, logMessage
If Err.Number = -2147023169 Then
logMessage = "RPC Failure occurred for namespace root-cimv2-dell"
MOMDebugLog 1, logMessage
End If
Err.Clear
End If
If (colItems is Nothing) or (IsNull(colItems)) Then
logMessage = "Unable to retrieve PS Unit"
MOMDebugLog 1, logMessage
Err.Clear
Else
logMessage = "PS Unit query retrieved successfully"
count1 = colItems.count
If count1 > 0 Then
psFlag = 1
End If
End If
Set colItems = Nothing
End Function
'*************************************************************************
' Function : DiscoverProc()
' Desc : To return flag whether to create ProcessorGroup for HardwareComponentDiscovery
' Arguments : procFlag byreference
'*************************************************************************
Function DiscoverProc(ByRef procFlag)
On Error resume next
Dim sQuery, colItems, objItemProc, procCheck
sQuery = "Select * from CIM_Processor"
Set colItems = GetObjectSet(objDellConnection, sQuery, "Name", "CIM_Processor")
If Err.Number <> 0 Then
logMessage = sQuery & " Error Number:" & Err.Number & "Description:" & Err.Description
MOMDebugLog 1, logMessage
If Err.Number = -2147023169 Then
logMessage = "RPC Failure occurred for namespace root-cimv2-dell"
MOMDebugLog 1, logMessage
End If
Err.Clear
End If
If (colItems is Nothing) or (IsNull(colItems)) Then
logMessage = "Unable to retrieve Proc Unit"
MOMDebugLog 1, logMessage
Err.Clear
Else
logMessage = "Proc Unit query retrieved successfully"
For Each objItemProc in colItems
'Error checking
If Err.Number <> 0 Then
logMessage = "Number:" & Err.Number & "Description:" & Err.Description
MOMDebugLog 1, logMessage
Err.Clear
End If
'Object Retrieval
If not objItemProc is nothing Then
procCheck = objItemProc.Status
If Not IsNull(procCheck) Then 'CR194360 Required for Empty slot Processor check
procFlag = 1
Exit Function
End If
End If
Next
End If
Set colItems = Nothing
End Function
'*************************************************************************
' Function : DiscoverStorage()
' Desc : To return flag whether to create StorageGroup for HardwareComponentDiscovery
' Arguments : memFlag byreference
'*************************************************************************
Function DiscoverStorage()
On Error Resume Next
Dim OMSABinPath ' Store Path from Registry key
Dim drive ' Drive letter
Dim version, regError, rc
regError = 0
MOMDebugLog 1, "Entered DiscoverStorage()"
' Get OMSA Lib Path
rc = GetOMABinPath(OMSABinPath, regError)
If rc <> 0 Then
logMessage = "GetOMSAHealth:GetOMABinPath Error"
MOMDebugLog 1, logMessage
Err.Clear
WScript.Quit()
End If
' Get Install root path
rc = GetOMInstallRoot(drive, OMSABinPath) ' return the current absolute path or the root path for the OMSA Install
If rc <> 0 Then
logMessage = "GetOMSAHealth:GetOMInstallRoot Error"
MOMDebugLog 1, logMessage
Err.Clear
WScript.Quit()
End If
If regError = 1 Then
logMessage = "Task Fail: OMSA not installed / OMSA Registry Value not found."
MOMDebugLog 1, logMessage
Err.Clear
WScript.Quit()
End If
' Check VBScript engine version
version = CheckVBScriptEngine()
If version = True OR version = False Then
MOMDebugLog 1, "Calling RunCLI()"
RunCLI drive, OMSABinPath
Else
logMessage = "Error: VBScript corrupted/absent. Please Re-Install Windows Script 5.6 on the Agent"
MOMDebugLog 1, logMessage
Err.Clear
WScript.Quit()
End If
MOMDebugLog 1, "Exiting DiscoverStorage()"
End Function
'*****************************************************************
'Function RunCLI
'Routine For CLI VB.Run (For Version < 5.6)
'*****************************************************************
Function RunCLI(ByVal targetDrive, ByVal strOMSABinPath)
On Error Resume Next
Dim guid1,guid3, wintemp_path
GetTempFolderPath wintemp_path, targetDrive
GetOMReportFileGUID guid1
MOMDebugLog 1, "Calling RunStorageCLI()"
RunStorageCLI targetDrive, strOMSABinPath
End Function
'*****************************************************************
'GetOMABinPath
'Routine to read the registry to query the OMA Install Path
'*****************************************************************
Function GetOMABinPath(o_sPath, ByRef regError)
On Error Resume Next
Dim strOMAKey
Dim oShell, tmp
Set oShell = CreateObject ("WScript.Shell")
o_sPath = ""
On Error Resume Next
o_sPath = oShell.RegRead(OMSA_REG_INTALL_PATH)
If o_sPath = "" Then
o_sPath = oShell.RegRead(OMSA64_REG_INTALL_PATH)
End If
If o_sPath = "" Then
tmp = DEF_OMSA_BIN_PATH & "\omreport.exe"
If(bFileExists(tmp)) Then
o_sPath = DEF_OMSA_BIN_PATH
logMessage = "GetOMABinPath - OMSABinPath is empty, Using Default Existing Path" & DEF_OMSA_BIN_PATH
MOMDebugLog 1, logMessage
Else
regError = 1
End If
Else
o_sPath = o_sPath & "\bin"
End If
If Err <> 0 Then
GetOMSABinPath = Err.Number
Err.Clear
End If
End Function
'*****************************************************************
'GetOMInstallRoot
'Routine to determine the Drive letter where OMSA is installed
'*****************************************************************
Private Function GetOMInstallRoot(ByRef path, ByVal OMSAInstallPath)
On Error Resume Next
' Return the root drive of the OMInstall Path
path = Left(OMSAInstallPath, 2)
End Function
'*****************************************************************
'bFileExists
'Routine to determine if the OMSA Report file is created
'*****************************************************************
Function bFileExists(ByVal filespec1)
On Error Resume Next
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
bFileExists = (fso.FileExists(filespec1))
Set fso = Nothing
End Function
'*****************************************************************
'DelFile
'Routine to delete the OMSA Report file
'*****************************************************************
Function DelFile(ByVal filespec2)
On Error Resume Next
Dim fso, oFile
If bFileExists(filespec2) Then
Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFile filespec2, True
Set fso = Nothing
End If
If Err <> 0 Then
DelFile = Err.Number
Err.Clear
End If
End Function
'**********************************************************
' CheckVBScriptEngine()
' Check VBScript engine version:
'**********************************************************
Function CheckVBScriptEngine()
On Error Resume Next
Dim bIsCompatV, var
Const VBSCRIPT_MIN_VERSION = 56
var = ((ScriptEngineMajorVersion * 10) + ScriptEngineMinorVersion)
If ((var) < VBSCRIPT_MIN_VERSION) Then
bIsCompatV = False
Else
bIsCompatV = True
End If
If Err <> 0 Then
CheckVBScriptEngine = Err.Number
Err.Clear
Else
CheckVBScriptEngine = bIsCompatV
End If
End Function
'*****************************************************************
'Function RunStorageCLI - Called from RunCLI If StorageArrayManagerFlag = 0
'Routine For VB.Run (For Version < 5.6)
'*****************************************************************
Function RunStorageCLI (ByVal Drive2, ByVal OMSABinPath)
On Error Resume Next
Dim guid22, timer, filespec, rc, oShell, strCommand, strRepFilePath, wintemp_path
Const TIMEOUT = 20
Const OM_REPORT_STORAGE_CONTR = "Storage"
MOMDebugLog 1, "Calling RunStorageCLI():"
GetTempFolderPath wintemp_path, Drive2
GetOMReportFileGUID guid22
strRepFilePath = wintemp_path & "\" & OM_REPORT_STORAGE_CONTR & guid22 & ".xml"
strCommand = "cmd /C " & chr(34) & OMSABinPath & "\" & "omreport.exe" & Chr(34) & " storage controller -fmt xml -outc " & strRepFilePath
filespec = strRepFilePath
Set oShell = CreateObject ("WScript.Shell")
rc = oShell.run (strCommand,0,true)
If rc <> 0 Then
DelFile(strRepFilePath)
Err.Clear
Else
' Infinite Loop Until file OM_REPORT_FILE_NAME is created
timer = 0
Do While bFileExists(filespec) <> -1
WScript.Sleep(1000)
timer = timer + 1
if (timer > TIMEOUT) Then
MOMDebugLog 1, "Exit RunCmd. Reason: OMREPORT STORAGE not responding"
Exit Do
End If
Loop
' Parse XML File
MOMDebugLog 1, "Calling ParseStorageXML():"
ParseStorageXML filespec
' Clean up the CLI Output : Delete OM_REPORT_FILE_NAME for STORAGE
DelFile(strRepFilePath)
End If ' End of If Condition for rc<>0 for oshell.run(omreport storage controller)
Set strRepFilePath = Nothing
Set strCommand = Nothing
Set oShell = Nothing
Set filespec = Nothing
End Function
'*************************************************************************
' Function : ExecRacCmd()
' Desc : To determine RAC Url for DRAC hardware
' Arguments : pass ByReference RACURL string
'*************************************************************************
Function ExecRacCmd (racCmd)
On Error Resume Next
Dim strLaunchRACURL, racAgentExist, strAlertDesc
Dim version, rc, rac
Dim logMessage, Message, RacExitFlag
racAgentExist = 0
RacExitFlag = 0
Dim version1
version1 = CheckVBScriptEngine() 'Check VBScript engine version
Message = " version1" & version1
If version1 = True Then
' Exec Optimization for Read from Standard Output (VBScript > 5.3)
rc = ExecuteRacCommand (racAgentExist, strLaunchRACURL, racCmd)
If rc <> 0 Then
Message = " ERROR: Main: ExecuteRacCommand error : " & rc
RacExitFlag = 1
MOMDebugLog 1, Message
Err.Clear
Exit Function
End If
ElseIf version1 = False Then
' Run , Redirect to file and Read from File (VBScript < 5.3, StdOut not supported)
rc = RunRacCommand (racAgentExist, strLaunchRACURL, racCmd)
Message = " RunRacCommand " & rc
If rc <> 0 Then
Message = " ERROR: Main: RunRACURL error : " & rc
RacExitFlag = 1
MOMDebugLog 1, Message
Err.Clear
Exit Function
End If
Else
Message = " ERROR: CheckVBScriptEngine Error : " & version1
RacExitFlag = 1
MOMDebugLog 1, Message
Err.Clear
Exit Function
End If
End Function
Dim RacExitFlag, Message, RegError
Const RacError= "Error"
'*****************************************************************
' ExecuteRacCommand
' Routine to Exec Cmd and Read From Standard Output
'*****************************************************************
Function ExecuteRacCommand(ByRef RacAgent, ByRef RacUrl, RacadmCmd)
On Error Resume Next
Dim blsRacInstalled, blsRacGen4Plus
Dim RacPath, drive, WshShell
Dim blsRacType
blsRacInstalled = 0 ' IP address Existence
blsRacGen4Plus = 0 ' Port Existence (subset of RacInstalled)
RegError = 0
Dim GetLanNetworking, CurLanNetworking, GetIDString, CommandString
GetPathParameter RacPath, drive
If RacExitFlag = 1 Then
ExecuteRacCommand = -1
Err.Clear
Exit Function
End If
Dim IPStr: IPStr = ""
Dim CmdPrefix: CmdPrefix = "cmd /c """ & RacPath & "\racadm.exe"" " & IPStr
GetIDString = CmdPrefix & " getconfig -g idRacInfo"
GetLanNetworking = CmdPrefix & " getconfig -g cfgLanNetworking"
RacadmCmd = CmdPrefix & " " & RacadmCmd
CurLanNetworking = CmdPrefix & " getconfig -g cfgCurrentLanNetworking"
Set WshShell = CreateObject("WScript.Shell")
CommandString = GetIDString
Message = "ExecuteRacCommand: Cmd for RACType - " & CommandString
MOMDebugLog 1, Message
Dim timer, oShell, objStdOut, strLine, nPos, strRacType
Const TIMEOUT = 20
timer = 0
Set oShell = WshShell.Exec(CommandString)
Do While oShell.Status = 0
WScript.Sleep(1000)
timer = timer + 1
if (timer > TIMEOUT) Then
Message = "Exit ExecCmd. Reason: RACADM not responding"
MOMDebugLog 1, Message
oShell.Terminate()
Exit Do
End If
Loop
Set objStdOut = oShell.StdOut
If Not oShell.StdErr.AtEndOfStream Then
RacadmErrStream = "STDERR: " + oShell.StdErr.ReadAll
Message = "RACADM Standard Error - " & RacadmErrStream
MOMDebugLog 1, Message
ExecuteRacCommand = -1
Err.Clear
Exit Function
Else
Do While Not objStdOut.AtEndOfStream
strLine = objStdOut.ReadLine
If Instr(Lcase(strLine),RacError) Then
RacAgent = 0
Message = "Error in Racadm Output for RACType " & strLine
MOMDebugLog 1, Message
ExecuteRacCommand = -1
Err.Clear
Exit Function
ElseIf Instr(LCase(strLine),Lcase("idRacType")) Then
nPos = Instr(LCase(strLine), "=")
strRacType = Trim(strLine)
strRacType = Mid(strRacType,nPos+1,5)
strRacType = Trim(strRacType)
blsRacType = 1
Message = "Detected DRAC Type (hex)= " & strRacType
End If
Loop
End If
MOMDebugLog 1, Message
oShell.Terminate()
Set oShell = Nothing
Set WshShell = Nothing
MOMDebugLog 1, "blsRacType=" & blsRacType & ", strRacType=" & strRacType
If blsRacType = 1 Then
If Instr(Lcase(strRacType),"6") OR Instr(Lcase(strRacType),"8") OR Instr(Lcase(strRacType),"10") OR Instr(Lcase(strRacType),"11") OR Instr(Lcase(strRacType),"16") OR Instr(Lcase(strRacType),"17") OR Instr(Lcase(strRacType),"32") OR Instr(Lcase(strRacType),"33") OR Instr(Lcase(strRacType),"34") Then
Message = "iDRAC Type = " & strRacType
MOMDebugLog 1, Message
lccFlag = 1
Else
Message = "Not an iDRAC Type = " & strRacType
MOMDebugLog 1, Message
End If
End If
'''
Set oShell = Nothing
Set objStdOut = Nothing
If Err <> 0 Then
ExecuteRacCommand = Err.Number
Message = "ExecuteRacCommand ErrorNo= " & Err.No & ", Description: " & Err.Desc
MOMDebugLog 1, Message
Err.Clear
End If
End Function
'*****************************************************************
' RunRacCommand
'Routine to use Run - Redirect to file and Read from File,Del File
' Arguments: RacAgent for existence of RAC, RACUrl
'*****************************************************************
Function RunRacCommand(ByRef RacAgent, ByRef RacUrl, RacadmCmd)
On Error Resume Next
RegError = 0
Const ForReading = 1
Dim guid1, guid2, guid3, guid4
Dim GetLanNetworking, CurLanNetworking, GetIDString, CommandString
Dim strRacIpAddress
Dim IPStr: IPStr = ""
GetIDString = IPStr & " getconfig -g idRacInfo"
GetLanNetworking = IPStr & " getconfig -g cfgLanNetworking"
RacadmCmd = IPStr & " " & RacadmCmd
CurLanNetworking = IPStr & " getconfig -g cfgCurrentLanNetworking"
Dim blsRacInstalled, RacPath, drive, wintemp_path, filespec
Dim oShell3, rc
If RacExitFlag = 1 Then
RunRacCommand = -1
Exit Function
End If
filespec = wintemp_path & "\" & guid1 & ".txt"
GetIDString = "cmd /c " & chr(34) & RacPath & "\racadm.exe" & Chr(34) & GetIDString & " > " & filespec
Message = "Run: Command for DRAC Type - " & GetIDString
MOMDebugLog 1, Message
Set oShell3 = CreateObject ("WScript.Shell")
rc = oShell3.run(GetIDString,0,true)
if (rc <> 0) OR (bFileExists(filespec) = False) Then
Message = " ERROR: PORT: RunRacCommand: OShellRun ERROR: " & rc & " for " & GetIDString
MOMDebugLog 1, Message
rc = DelFile(filespec)
If rc <> 0 Then
Message = "WARNING: - DelFile " & filespec
MOMDebugLog 1, Message
End If
RunRacCommand = -1
Err.Clear
Exit Function
end if
Dim strLine, nPos, strRacType, blsRacType
Dim fso: Set fso = CreateObject("Scripting.FileSystemObject")
Dim oFile: Set oFile = fso.OpenTextFile(filespec, ForReading, False)
Do While Not oFile.AtEndOfStream
strLine = Trim(oFile.ReadLine)
If Instr(Lcase(strLine),RacError) Then
RacAgent = 0
Message = " ERROR: Error in Racadm Output for idRacInfo " & strLine
MOMDebugLog 1, Message
rc = DelFile(filespec)
If rc <> 0 Then
Message = "WARNING: - DelFile " & filespec
MOMDebugLog 1, Message
End If
RunRacCommand = -1
Err.Clear
Exit Function 'Add MP22UT.X01
End If
If Instr(LCase(strLine),Lcase("idRacType")) Then
nPos = Instr(LCase(strLine), "=")
strRacType = Trim(strLine)
strRacType = Mid(strRacType,nPos+1,5)
strRacType = Trim(strRacType)
Message = " INFO: Detected DRAC Type (hex)= " & strRacType
blsRacType = 1
End If
Loop
MOMDebugLog 1, "blsRacType " & blsRacType & ", strRacType="& strRacType
Set oShell3 = Nothing
'Set objStdOut = Nothing
oFile.close
'Clean up the CLI Output : Delete %WINTEMP% \ %Guid1% .txt
rc = DelFile(filespec)
If rc <> 0 Then
Message = " WARNING:! - DelFile " & filespec
MOMDebugLog 1, Message
End If
Set filespec = Nothing
If blsRacType = 1 Then
GetRACFileGUID guid3, guid4
If Instr(Lcase(strRacType),"10") OR Instr(Lcase(strRacType),"11") Then
lccFlag = 1
End If
Else
Message = "DRAC Type not found via idRacInfo command. "
MOMDebugLog 1, Message
End If ' End of blsRacType IF clause
' Output OMSA CLI to file RACGuid1.txt, wait until RUN Command is completed
' RAC5+ cfgLanNetworking in place of cfgCurrentLanNetworking (Invalid Group)
If Err <> 0 Then
RunRacCommand = Err.Number
Err.Clear
End If
End Function
'*****************************************************************
'GetPathParameter - Common to RunRacCommand and ExecRacUrl
'Routine to get RACADM path and drive letter
' Arguments: Racadm path for executable and drive letter of installation
'*****************************************************************
Function GetPathParameter(ByRef o_racpath, ByRef o_drive)
On Error Resume Next
Dim rac_path, drive_letter, rc
rc = GetRACADMPath(rac_path)
If rc <> 0 Then
Message = "GetPathParameter:GetRACADMPath Error - " & rc
MOMDebugLog 1, Message
RacExitFlag = 1
Err.Clear
Exit Function
Else
Message = "GetPathParameter:GetRACADMPath - " & rac_path
End If
rc = GetRACInstallRoot(drive_letter, rac_path)
If rc <> 0 Then
Message = "GetPathParameter:GetRACInstallRoot Error - " & rc
MOMDebugLog 1, Message
RacExitFlag = 1
Err.Clear
Exit Function
Else
Message = "GetPathParameter:GetRACInstallRoot - " & drive_letter
End If
If RegError = 1 Then
Message = "RAC Hardware / Agent not installed on Server"
MOMDebugLog 1, Message
RacExitFlag = 1
Err.Clear
Exit Function
End If
o_racpath = rac_path
o_drive = drive_letter
If Err <> 0 Then
GetPathParameter = Err.Number
Err.Clear
End If
End Function
'*************************************************************************
' Function : GetRACInstallRoot()
' Desc : To determine RAC Install Drive
' Arguments : ByRef, driveletter and RACadmPath
'*************************************************************************
Function GetRACInstallRoot(ByRef path, ByVal RACInstallPath)
On Error Resume Next
' Return the root drive of the OMInstall Path
path = Left(RACInstallPath, 2)
If Err <> 0 Then
GetRACInstallRoot = Err.Number
Err.Clear
End If
End Function
'*****************************************************************
'GetTempFolderPath
'Routine to Get Win Temp Folder path
'*****************************************************************
Function GetTempFolderPath(ByRef WinTempFolder, ByVal drive_letter)
On Error Resume Next
Dim FldrExistFlag, fso
FldrExistFlag = False
dim wshShell : Set wshShell = Createobject("WScript.Shell")
dim wshSysEnv : Set wshSysEnv = wshShell.Environment
dim strSysTempFolder : strSysTempFolder = wshSysEnv("TEMP")
dim wshPrcEnv : Set wshPrcEnv = wshShell.Environment("Process")
strSysTempFolder = Replace(strSysTempFolder, "%SystemRoot%", wshPrcEnv("SYSTEMROOT"), 1, -1, vbTextCompare)
WinTempFolder = strSysTempFolder
Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FolderExists(WinTempFolder)) Then
FldrExistFlag = True
Else
FldrExistFlag = False
End If
If WinTempFolder = "" OR FldrExistFlag = False Then
WinTempFolder = drive_letter
End If
Message = "Current CLI output will be stored in Folder - " & WinTempFolder
Set wshShell = Nothing
Set wshSysEnv = Nothing
Set strSysTempFolder = Nothing
Set wshPrcEnv = Nothing
If Err <> 0 Then
GetTempFolderPath = Err.Number
Err.Clear
End If
End Function
'*****************************************************************
'GetRACFileGUID
'Routine to generate 2 unique GUIDs for ip and port info files
' Used to serve concurrency file access by different modules
'*****************************************************************
Function GetRACFileGUID(ByRef guid3, ByRef guid4)
On Error Resume Next
Dim TypeLib, NewGUID
Set TypeLib = CreateObject("Scriptlet.TypeLib")
NewGUID = TypeLib.Guid
guid3 = (left(NewGUID, len(NewGUID)-2))
Set TypeLib = Nothing
Set TypeLib = CreateObject("Scriptlet.TypeLib")
NewGUID = TypeLib.Guid
guid4 = (left(NewGUID, len(NewGUID)-2))
Set TypeLib = Nothing
End Function
'*****************************************************************
'GetRacadmPath
'Routine to read the registry to query the OMSA Install Path
'*****************************************************************
Function GetRACADMPath(ByRef o_sPath)
On Error Resume Next
Const DEF_RACADM_PATH = "C:\Program Files\Dell\OpenManage\RAC\MN"
Const RACADM_REG_INTALL_PATH = "HKEY_LOCAL_MACHINE\SOFTWARE\Dell Computer Corporation\OpenManage\Remote Access Card Managed Node\PATH"
Const RACADM64_REG_INTALL_PATH = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432node\Dell Computer Corporation\OpenManage\Remote Access Card Managed Node\PATH"
Const REM_RACADM_REG_INTALL_PATH = "HKEY_LOCAL_MACHINE\SOFTWARE\Dell Computer Corporation\OpenManage\Remote Access Card Management Station\Path"
Const REM_RACADM64_REG_INTALL_PATH = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Dell Computer Corporation\OpenManage\Remote Access Card Management Station\Path"
Dim oShell, strRacadmKey, tmp
If o_sPath = "" Then
o_sPath = oShell.RegRead(RACADM64_REG_INTALL_PATH)
If Err <> 0 Then
Err.Clear
End If
End If
If o_sPath = "" Then
o_sPath = oShell.RegRead(REM_RACADM_REG_INTALL_PATH)
If Err <> 0 Then
Err.Clear
End If
End If
If o_sPath = "" Then
o_sPath = oShell.RegRead(REM_RACADM64_REG_INTALL_PATH)
If Err <> 0 Then
Err.Clear
End If
End If
If o_sPath = "" Then
tmp = DEF_RACADM_PATH & "\racadm.exe"
If(bFileExists(tmp)) Then
o_sPath = DEF_RACADM_PATH
Message = "RACADM Registry is empty, Using Default Path" & DEF_RACADM_PATH
MOMDebugLog 1, Message
Err.Clear
Else
RegError = 1
End If
End If
If Err <> 0 Then
GetRACADMPath = Err.Number
Err.Clear
End If
Set oShell = Nothing
End Function
'*****************************************************************
' Function ParseStorageXML
' Get the Controller data from OMSS StorageController XML Output
'*****************************************************************
Function ParseStorageXML(ByVal storagefilepath)
Dim StorageHealth, contr_health, controller_arr, contrName, contrNameVal
Dim firmwareVerVal, driverVerVal, pciSlotVal, targetIdVal
Dim reqFwVerVal,channelVal,slotIdVal,reqDrvrVerVal,globalNoVal
Dim xmlDoc, i, str, TopNode, TopNodelist, root, len, slotId
If(bFileExists(storagefilepath)) Then
Set xmlDoc = CreateObject("Microsoft.XMLDOM")
If (IsObject(xmlDoc) = True) Then
xmlDoc.async = "false"
xmlDoc.load(storagefilepath)
If (xmlDoc.parseError.errorCode <> 0) Then
Dim myErr
Set myErr = xmlDoc.parseError
Message = "XML Parse Error Reason: " & myErr.reason
MOMDebugLog 1, Message
Message = "XML Parse Error Line: " & myErr.line
MOMDebugLog 1, Message
Message = "XML Parse Error Character: " & myErr.linepos
MOMDebugLog 1, Message
Message = "XML Parse Error Text: " & myErr.srcText
MOMDebugLog 1, Message
DelFile(storagefilepath)
Exit Function
End If
Set root = xmlDoc.documentElement
MOMDebugLog 1, "Root Node is " & root.nodeName
Set TopNodeList = root.selectNodes("Controllers/DCStorageObject")
For Each TopNode In TopNodeList
If TopNode.hasChildNodes Then
MOMDebugLog 1, "node has child nodes:" & TopNode.nodeName
contrNameVal = GetTagValue(TopNode, "Name")
pciSlotVal = GetTagValue(TopNode, "PCISlot")
firmwareVerVal = GetTagValue(TopNode, "FirmwareVer")
driverVerVal = GetTagValue(TopNode, "CurrentDriverVersion")
reqFwVerVal = GetTagValue(TopNode, "RequiredFirmwareVersion")
channelVal = GetTagValue(TopNode, "Channels")
globalNoVal = GetTagValue(TopNode, "GlobalNo")
reqDrvrVerVal = GetTagValue(TopNode, "RequiredDriverVersion")
targetIdVal = GetTagValue(TopNode, "TargetID")
If ((StrComp(Trim(pciSlotVal),"0") = 0) Or (StrComp(Trim(pciSlotVal),"-1") = 0) Or (StrComp(Trim(pciSlotVal),"2147483648") = 0 )) Then
slotId = "Embedded"
ElseIf ( StrComp(Trim(pciSlotVal),"2147483649") = 0 ) Then
slotId = "Slot Not Available"
Else
slotId = "PCI Slot" & Trim(pciSlotVal)
End If
MOMDebugLog 1, "slotId:" & slotId
set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Dell.WindowsServer.StorageController']$")
MOMDebugLog 1, "Adding Dell.WindowsServer.StorageController class"
call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", TargetComputer)
MOMDebugLog 1, "Adding TargetComputer:" & TargetComputer
call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.LogicalDevice']/DeviceID$", TargetComputer)
call oInst.AddProperty("$MPElement[Name='Dell.WindowsServer.StorageController']/DeviceID$", globalNoVal)
MOMDebugLog 1, "Adding globalNoVal:" & globalNoVal
call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", contrNameVal)
MOMDebugLog 1, "Adding contrNameVal:" & contrNameVal
call oInst.AddProperty("$MPElement[Name='Dell.WindowsServer.StorageController']/DriverVer$", driverVerVal)
MOMDebugLog 1, "Adding driverVerVal:" & driverVerVal
call oInst.AddProperty("$MPElement[Name='Dell.WindowsServer.StorageController']/FirmwareVer$", firmwareVerVal)
MOMDebugLog 1, "Adding firmwareVerVal:" & firmwareVerVal
call oInst.AddProperty("$MPElement[Name='Dell.WindowsServer.StorageController']/MinReqFirmwareVer$", reqFwVerVal)
MOMDebugLog 1, "Adding reqFwVerVal:" & reqFwVerVal
call oInst.AddProperty("$MPElement[Name='Dell.WindowsServer.StorageController']/NumOfConnectors$", channelVal)
MOMDebugLog 1, "Adding channelVal:" & channelVal
call oInst.AddProperty("$MPElement[Name='Dell.WindowsServer.StorageController']/SlotID$", slotId)
MOMDebugLog 1, "Adding slotId:" & slotId
call oInst.AddProperty("$MPElement[Name='Dell.WindowsServer.StorageController']/MinReqDriverVer$", reqDrvrVerVal)
MOMDebugLog 1, "Adding reqDrvrVerVal:" & reqDrvrVerVal
call oInst.AddProperty("$MPElement[Name='Dell.WindowsServer.StorageController']/SCSIInitiatorID$", targetIdVal)
MOMDebugLog 1, "Adding targetIdVal:" & targetIdVal
call oDiscoveryData.AddInstance(oInst)
MOMDebugLog 1, "Adding the instance:"
storageFlag = 1
MOMDebugLog 1, "Adding storageFlag=:" & storageFlag
end if
Next
Else
Message = "Error: DOM object not created using CreateObject - Microsoft.XMLDOM"
MOMDebugLog 1, Message
End If
Else
Message = "Storage CLI XML Output File does not exist - " & storagefilepath
MOMDebugLog 1, Message
End If
End Function
'*****************************************************************
Function GetTagValue(ByRef TopNode, ByVal tagName)
Dim value, NodeList, Node, len
Set NodeList = TopNode.selectNodes(tagName)
len = Nodelist.Length
if len > 0 then
Set Node = NodeList.item(0)
value = Node.text
else
value = "Not Available"
end if
MOMDebugLog 1, "Name:" & tagName & ", value:" & value
GetTagValue = value
End Function
'*****************************************************************
Sub MOMDebugLog (ByVal debugLevel, ByVal Message)
On Error Resume Next
If (debugLevel > 0) and (debugLevel <= logLevel) Then
objLogTextFile.WriteLine(Now() & " ---- " & Message)
Err.Clear
End If
End Sub
'*****************************************************************
'GetTempFolderPath
'Routine to Get Win Temp Folder path
'*****************************************************************
Function GetTempFolderPath(ByRef WinTempFolder, ByVal drive_letter)
On Error Resume Next
Dim FldrExistFlag, fso
FldrExistFlag = False
dim wshShell : Set wshShell = Createobject("WScript.Shell")
dim wshSysEnv : Set wshSysEnv = wshShell.Environment
dim strSysTempFolder : strSysTempFolder = wshSysEnv("TEMP")
dim wshPrcEnv : Set wshPrcEnv = wshShell.Environment("Process")
strSysTempFolder = Replace(strSysTempFolder, "%SystemRoot%", wshPrcEnv("SYSTEMROOT"), 1, -1, vbTextCompare)
WinTempFolder = strSysTempFolder
Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FolderExists(WinTempFolder)) Then
FldrExistFlag = True
Else
FldrExistFlag = False
End If
If WinTempFolder = "" OR FldrExistFlag = False Then
WinTempFolder = drive_letter
End If
Set wshShell = Nothing
Set wshSysEnv = Nothing
Set strSysTempFolder = Nothing
Set wshPrcEnv = Nothing
If Err <> 0 Then
GetTempFolderPath = Err.Number
Err.Clear
End If
End Function
'*****************************************************************
'GetOMReportFileGUID
'Routine to generate unique GUIDs for OMREPORT FILE
'*****************************************************************
Function GetOMReportFileGUID(ByRef o_guid)
On Error Resume Next
Dim TypeLib, NewGUID
Set TypeLib = CreateObject("Scriptlet.TypeLib")
NewGUID = TypeLib.Guid
o_guid = (left(NewGUID, len(NewGUID)-2))
Set TypeLib = Nothing
End Function
' *** Add double query fix
' Function to retrieve the object
Function GetObjectSet(ByRef objDellConnection, SelectQuery, Attribute, objName)
Dim retry, retryFlag
Dim objItem, arrURL, logMessage
On Error Resume Next
RetryFlag = False
For retry = 0 To 1
MOMDebugLog 1, "Retrying for " & retry & " time..."
Set GetObjectSet = objDellConnection.ExecQuery(SelectQuery)
LogErrorNumber(objName)
If (GetObjectSet is Nothing) Or (IsNull(GetObjectSet)) Then
logMessage = "INFO: Unable to retrieve " & objName & " Attributes"
MOMDebugLog 1, logMessage
WScript.Sleep(1000)
RetryFlag = True
Else
logMessage= "INFO: " & objName & " attributes retrieved successfully"
MOMDebugLog 1, logMessage
If Attribute = "__COUNT__" Then
Exit For
End If
For Each objItem in GetObjectSet
If LogErrorNumber(objName) = 0 Then
If Not objItem is nothing Then
Dim attrVal : attrVal = objItem.Properties_.Item(Attribute)
If IsNull(attrVal) Or Len(attrVal) <= 0 Then
MOMDebugLog 1, Attribute & " value is null or empty"
RetryFlag = True
WScript.Sleep(500)
Exit For
Else
Exit Function
End If
End If
End If
Next
If RetryFlag = False Then
Exit For
End If
End If
Next
End Function
Function LogErrorNumber(objName)
Dim logMessage
LogErrorNumber = Err.Number
If Err.Number <> 0 Then
Select Case Err.Number
Case -2147749904
logMessage = "CIM Object not found"
Case -2147749902
logMessage = "Dell CIM object not found"
Case -2147023169
logMessage = "RPC Failure occurred for namespace root-cimv2-dell"
Case -2147217389
logMessage = "Please Install/Re-Install ServerAdministrator on Dell Server!"
Case -2147217394 '0x8004100E
logMessage = "Not able to find Dell CIM object"
Case -2147217392 '0x8004100C
logMessage = "Not able to find the collection"
Case -2147749890
logMessage = "Object cannot be found"
Case -2147749892
logMessage = "Object cannot be found"
Case Else
logMessage = "Unable to retrieve " & objName
logMessage = logMessage & " Err Number:" & Err.Number
logMessage = logMessage & " Err Descr:" & Err.Description
End Select
MOMDebugLog 1, "ERROR: " & logMessage
End If
End Function </Script></ScriptBody>
<TimeoutSeconds>300</TimeoutSeconds>
</DataSource>
</MemberModules>
<Composition>
<Node ID="DS"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.Discovery.Data</OutputType>
</DataSourceModuleType>