Lenovo WinSw HwMgmt - Provider di rilevamento

IBM.WinSw.HwMgmt.DiscoveryProvider (DataSourceModuleType)

Lenovo WinSw HwMgmt - Provider di rilevamento

Element properties:

TypeDataSourceModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
OutputTypeSystem.Discovery.Data

Member Modules:

ID Module Type TypeId RunAs 
DS DataSource IBM.WinComputer.DiscoveryBase.Repository Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
IntervalSecondsint$Config/IntervalSeconds$Lenovo WinSw HwMgmt - Secondi intervallo provider di rilevamento
TimeoutSecondsint$Config/TimeoutSeconds$Lenovo WinSw HwMgmt - Secondi timeout provider di rilevamento

Source Code:

<DataSourceModuleType ID="IBM.WinSw.HwMgmt.DiscoveryProvider" Accessibility="Internal">
<Configuration>
<xsd:element name="IntervalSeconds" type="xsd:integer"/>
<xsd:element name="TimeoutSeconds" type="xsd:integer"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" ParameterType="int" Selector="$Config/IntervalSeconds$"/>
<OverrideableParameter ID="TimeoutSeconds" ParameterType="int" Selector="$Config/TimeoutSeconds$"/>
</OverrideableParameters>
<ModuleImplementation>
<Composite>
<MemberModules>
<DataSource ID="DS" TypeID="IBM.WinComputer.DiscoveryBase.Repository">
<IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
<SyncTime/>
<ScriptName>IBMHwMgmtSoftwareDiscovery.vbs</ScriptName>
<Arguments>"$MPElement$" "$Target/Id$" "$Target/ManagementGroup/Name$" "$Target/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$" "$Target/Property[Type="IBM.WinComputer"]/BMCDetected$" "$Target/Property[Type="IBM.WinComputer"]/RSAIIDetected$"</Arguments>
<ScriptBody><Script>

' [d504936/byou: added]
Const INTERNAL_ID_IBM_DA = "IBM Director Platform Agent (Core Services, or Level-1 Agent)"
Const INTERNAL_ID_OSA_IPMI = "Avocent/OSA IPMI Driver"
Const INTERNAL_ID_IBM_IPMILAYER = "IBM IPMI Mapping Layer"
Const INTERNAL_ID_MS_IPMI = "Microsoft IPMI Stack"
Const INTERNAL_ID_IBM_RSA = "IBM RSA-II Daemon"
Const INTERNAL_ID_IBM_SERVERAID = "ServeRAID-8x/7x/6x Manager Level-1 Agent"
Const INTERNAL_ID_IBM_MEGARAID = "ServeRAID-MR/BR/IR CIM/WMI Provider"
SetLocale("en-us")
Dim oArgs
Set oArgs = WScript.Arguments
WScript.Echo oArgs.Count
if oArgs.Count &lt; 6 Then
'Wscript.Quit -1
End If

Dim sourceID, managedEntityID, managementGroupName, targetComputerPrincipalName, isBMCPresented, isRSAPresented

sourceID = oArgs(0)
managedEntityID = oArgs(1)
managementGroupName = oArgs(2)
targetComputerPrincipalName = oArgs(3)
isBMCPresented = oArgs(4)
isRSAPresented = oArgs(5)

EventID = 102

Call LogDebugString("IBMHwMgmtSoftwareDiscovery.vbs " &amp; sourceID &amp; " " &amp; _
managedEntityID &amp; " " &amp; _
managementGroupName &amp; " " &amp; _
targetComputerPrincipalName &amp; " " &amp; _
isBMCPresented &amp; " " &amp; _
isRSAPresented, INFO_LEVEL_DETAIL)

Call SoftwareDiscovery()

Sub SoftwareDiscovery()

Dim oBag

'Set oAPI = SCOMCreateObject("MOM.ScriptAPI")


Call LogDebugString("Entering SoftwareDiscovery (targetComputer:'" + targetComputerPrincipalName + "')", INFO_LEVEL_FUNCTION)

Set oDiscoveryData = oAPI.CreateDiscoveryData(0, sourceID, managedEntityID)

If (CreateHwMgmtSoftwareInstances() &gt; 0) Then
Call LogDebugString("Created Management Software", INFO_LEVEL_DETAIL)
End If

Call oAPI.Return(oDiscoveryData)
End Sub

Function CreateHwMgmtSoftwareInstances()
Call LogDebugString("Entering CreateHwMgmtSoftwareInstances", INFO_LEVEL_FUNCTION)
Dim osVersion, spVersion, iOSAIPMICreated

CreateHwMgmtSoftwareInstances = 0
iOSAIPMICreated = -1

'Create instance for Director Core Service all the time
If (CreateSoftwareInstance(SW_IBM_DA) &gt; 0) Then
Call LogDebugString("Created instance of Director Core Services", INFO_LEVEL_DETAIL)
CreateHwMgmtSoftwareInstances = CreateHwMgmtSoftwareInstances + 1
End If
' [d504936/byou: moved it down for Adaptec SR agent and LSI IR/MR provider] -- If IsSoftwareRunning(SW_IBM_DA) &gt; 0 Then
'Create instance for BMC Enablement(OSA IPMI, Lenovo Mapping Layer, Microsoft IPMI)
If Instr(isBMCPresented, "None") = 0 Then
If GetOSInfo(osVersion, spVersion) &lt; 0 Then
Call LogDebugString("Could not get OS Info", WARNING_LEVEL_DEV)
Exit Function
End If
'Create OSA IPMI
' Earlier than win2k3, or Win2k3 but not R2.
If (StrComp(osVersion, "5.2.0000") &lt; 0) or (IsRegExpMatched(osVersion, "^5\.2\.") and ( 1 &lt;&gt; IsWin2k3r2())) Then
'Early than win2003 R2
Call LogDebugString("Early than win2003 R2", INFO_LEVEL)
If (CreateSoftwareInstance(SW_OSA_IPMI) &gt; 0) Then
Call LogDebugString("Created OSA IPMI Stack", INFO_LEVEL)
CreateHwMgmtSoftwareInstances = CreateHwMgmtSoftwareInstances + 1
iOSAIPMICreated = 1
End If
ElseIf (StrComp(osVersion, "6.0.0000") &lt; 0 and (IsSoftwareRunning(SW_MS_IPMI) &lt; 0)) Then
'later than win2003 R2 but early than win2008, without Microsoft IPMI enabled
Call LogDebugString("later than win2003 R2 but early than win2008, without Microsoft IPMI enabled", INFO_LEVEL)
If (CreateSoftwareInstance(SW_OSA_IPMI) &gt; 0) Then
Call LogDebugString("Created OSA IPMI Stack", INFO_LEVEL_DETAIL)
CreateHwMgmtSoftwareInstances = CreateHwMgmtSoftwareInstances + 1
iOSAIPMICreated = 1
End If
End If
'Create OSA Mappling Layer
If iOSAIPMICreated = 1 Then
If (CreateSoftwareInstance(SW_IBM_IPMILAYER) &gt; 0) Then
Call LogDebugString("Created OSA Mapping Layer", INFO_LEVEL_DETAIL)
CreateHwMgmtSoftwareInstances = CreateHwMgmtSoftwareInstances + 1
End If
End If
'Create MS IPMI
If ( IsWin2k3r2() and (iOSAIPMICreated = -1)) Then
'later than win2003 R2 but early than win2008, without OSA IPMI
If (CreateSoftwareInstance(SW_MS_IPMI) &gt; 0) Then
Call LogDebugString("Created Microsoft IPMI Stack", INFO_LEVEL_DETAIL)
CreateHwMgmtSoftwareInstances = CreateHwMgmtSoftwareInstances + 1
End If
End If
End If
'Create instance for RSA daemon
If Instr(IsRSAPresented, "None") = 0 Then
If (CreateSoftwareInstance(SW_IBM_RSA) &gt; 0) Then
Call LogDebugString("Created RSA Daemon", INFO_LEVEL)
CreateHwMgmtSoftwareInstances = CreateHwMgmtSoftwareInstances + 1
End If
End If
If IsSoftwareRunning(SW_IBM_DA) &gt; 0 Then ' [d504936/byou: moved it down from far above]
'Create instance for ServeRAID Agent
Dim tempStr
tempStr = "None"
If ServeRAIDPresented(tempStr) &gt; 0 Then
If (CreateSoftwareInstance(SW_IBM_SERVERAID) &gt; 0) Then
Call LogDebugString("Created Lenovo ServeRAID Agent", INFO_LEVEL_DETAIL)
CreateHwMgmtSoftwareInstances = CreateHwMgmtSoftwareInstances + 1
End If
End If

'Create instance for MegaRAID Provider
tempStr = "None"
If MegaRAIDPresented(tempStr) &gt; 0 Then
If (CreateSoftwareInstance(SW_IBM_MEGARAID) &gt; 0) Then
Call LogDebugString("Created Lenovo ServeRAID-MR Provider", INFO_LEVEL)
CreateHwMgmtSoftwareInstances = CreateHwMgmtSoftwareInstances + 1
End If
End If

End If

End Function

Function IsSoftwareRunning(ByVal swID)
Call LogDebugString("Entering IsSoftwareRunning", INFO_LEVEL_FUNCTION)
IsSoftwareRunning = -1

Dim iResult, oSWCollection, swNamespace, swClass, oObjectItem, swServiceName, swName

If swID = SW_IBM_DA Then
swNamespace = CIMV2_NAMESPACE
swClass = SERVICE_CIMV2_CLASS
swServiceName = "wmicimserver"
swName = INTERNAL_ID_IBM_DA ' [d504936/byou: changed]
ElseIf swID = SW_OSA_IPMI Then
swNamespace = CIMV2_NAMESPACE
swClass = DRIVER_CIMV2_CLASS
swServiceName = "IPMI"
swName = INTERNAL_ID_OSA_IPMI ' [d504936/byou: changed]
ElseIf swID = SW_MS_IPMI Then
swNamespace = CIMV2_NAMESPACE
swClass = DRIVER_CIMV2_CLASS
swServiceName = "IPMIDRV"
swName = INTERNAL_ID_MS_IPMI ' [d504936/byou: changed]
End If
'Detect if Director Agent is running or not
iResult = GetWMIObjectCollection(swNamespace, swClass, oSWCollection)
If (iResult &gt; 0) Then
For Each oObjectItem in oSWCollection
'If InStr(oObjectItem.Name, swServiceName) &lt;&gt; 0 Then
If StrComp(Trim(oObjectItem.Name), swServiceName,1) = 0 Then
If Instr(oObjectItem.State, "Running") &lt;&gt; 0 Then
Call LogDebugString(swName + " is running!", INFO_LEVEL_DETAIL)
IsSoftwareRunning = 1
Exit For
End If
End If
Next
End If
If IsSoftwareRunning = -1 Then
Call LogDebugString(swName + " is not running!", INFO_LEVEL)
End If
End Function

Function CreateSoftwareInstance(ByVal swID)
Call LogDebugString("Entering CreateSoftwareInstance()", INFO_LEVEL_FUNCTION)
CreateSoftwareInstance = -1
Dim oHwMgmtSoftwareInstance, oPropertyValue, swName


If swID = SW_IBM_DA Then
swName = INTERNAL_ID_IBM_DA ' [d504936/byou: changed]
'swInternalID = "Director_Core_Services"
ElseIf swID = SW_OSA_IPMI Then
swName = INTERNAL_ID_OSA_IPMI ' [d504936/byou: changed]
'swInternalID = "OSA_IPMI_Driver"
ElseIF swID = SW_IBM_IPMILAYER Then
swName = INTERNAL_ID_IBM_IPMILAYER ' [d504936/byou: changed]
'swInternalID = "IBM_IPMI_Mapping_Layer"
ElseIF swID = SW_MS_IPMI Then
swName = INTERNAL_ID_MS_IPMI ' [d504936/byou: changed]
'swInternalID = "Microsoft_IPMI_Stack"
ElseIF swID = SW_IBM_RSA Then
swName = INTERNAL_ID_IBM_RSA ' [d504936/byou: changed]
'swInternalID = "IBM_RSA_Daemon"
ElseIF swID = SW_IBM_SERVERAID Then
swName = INTERNAL_ID_IBM_SERVERAID ' [d504936/byou: changed]
'swInternalID = "IBM_ServeRAID_Agent"
ElseIF swID = SW_IBM_MEGARAID Then
swName = INTERNAL_ID_IBM_MEGARAID ' [d504936/byou: changed]
'swName = "ServeRAID-MR Provider"
End If
Call LogDebugString("Entering CreateSoftwareInstance: " + swName, INFO_LEVEL_FUNCTION)
Set oHwMgmtSoftwareInstance = oDiscoveryData.CreateClassInstance("$MPElement[Name='IBM.WinSw.HwMgmt']$")

Call oHwMgmtSoftwareInstance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", targetComputerPrincipalName)
Call oHwMgmtSoftwareInstance.AddProperty("$MPElement[Name='IBM.WinSw.HwMgmt']/Name$", swName)

Call UpdateSoftwareProperty(oHwMgmtSoftwareInstance, swID)
Call oDiscoveryData.AddInstance(oHwMgmtSoftwareInstance)
CreateSoftwareInstance = 1
Call LogDebugString("End of CreateSoftwareInstance(): " + swName, INFO_LEVEL_FUNCTION)
End Function


Function UpdateSoftwareProperty(ByRef oHwMgmtSoftwareInstance, ByVal swID)
Dim iResult, oServiceCollection, oObjectItem, svTargetFile, svVersion, oFso, oFile, svNamespace, svClass, svServiceName, isvFlag, oSystemDrive, oTargetFile1, oTargetFile2, swName
Call LogDebugString("Entering UpdateSoftwareProperty()" , INFO_LEVEL_FUNCTION)
isvFlag = -1
If swID = SW_IBM_DA Then
svNamespace = CIMV2_NAMESPACE
svClass = SERVICE_CIMV2_CLASS
svServiceName = "wmicimserver"
swName = INTERNAL_ID_IBM_DA ' [d504936/byou: changed]
'swName = "Director Core Services"
ElseIf swID = SW_OSA_IPMI Then
svNamespace = CIMV2_NAMESPACE
svClass = DRIVER_CIMV2_CLASS
svServiceName = "IPMI"
swName = INTERNAL_ID_OSA_IPMI ' [d504936/byou: changed]
'swName = "OSA IPMI Driver"
ElseIF swID = SW_IBM_IPMILAYER Then
svNamespace = CIMV2_NAMESPACE
svClass = OS_CIMV2_CLASS
swName = INTERNAL_ID_IBM_IPMILAYER ' [d504936/byou: changed]
ElseIF swID = SW_MS_IPMI Then
svNamespace = CIMV2_NAMESPACE
svClass = DRIVER_CIMV2_CLASS
svServiceName = "IPMIDRV"
swName = INTERNAL_ID_MS_IPMI ' [d504936/byou: changed]
ElseIF swID = SW_IBM_RSA Then
svNamespace = CIMV2_NAMESPACE
svClass = SERVICE_CIMV2_CLASS
svServiceName = "ibmspsvc"
swName = INTERNAL_ID_IBM_RSA ' [d504936/byou: changed]
'swName = "IBM RSA Daemon"
ElseIF swID = SW_IBM_SERVERAID Then
'For Lenovo ServeRAID Agent, there are no target files/version info
svServiceName = ""
swName = INTERNAL_ID_IBM_SERVERAID ' [d504936/byou: changed]
'swName = "Lenovo ServeRAID Agent"
ElseIF swID = SW_IBM_MEGARAID Then
'For Lenovo MegaRAID Agent, there are no target files/version info
svServiceName = ""
swName = INTERNAL_ID_IBM_MEGARAID ' [d504936/byou: changed]
'swName = "ServeRAID-MR Provider"
Else
svServiceName = ""
swName = "Unknown"
End If

oFile = "Unknown"
svVersion = "Unknown"
Call LogDebugString("Entering UpdateSoftwareProperty: " + swName, INFO_LEVEL_FUNCTION)
If svServiceName &lt;&gt; "" Then
'Search for the IBM Director Agent WIM CIM Server process
iResult = GetWMIObjectCollection(svNamespace, svClass, oServiceCollection)
If (iResult &gt; 0) Then
If swID = SW_IBM_IPMILAYER Then
For Each oObjectItem in oServiceCollection
oSystemDrive = oObjectItem.SystemDrive
oTargetFile1 = oSystemDrive + "\WINDOWS\system32\ibmsp6w.dll"
oTargetFile2 = oSystemDrive + "\WINDOWS\SysWOW64\ibmsp6w.dll"
Set oFso = CreateObject("Scripting.FileSystemObject")
If oFso.FileExists(oTargetFile1) Then
oFile = oTargetFile1
isvFlag = 1
ElseIf oFso.FileExists(oTargetFile2) Then
oFile = oTargetFile2
isvFlag = 1
End If
If isvFlag &gt; 0 Then
Call LogDebugString("TargetFile:" + oFile, INFO_LEVEL_DETAIL)
Call oHwMgmtSoftwareInstance.AddProperty("$MPElement[Name='IBM.WinSw.HwMgmt']/TargetFile$", CStr(oFile))
If oFso.FileExists(oFile) Then
svVersion = oFso.GetFileVersion(oFile)
Else
svVersion = "Version undetermined - file '" + oFile + "' does not exist!!" ' see "XB047042/byou:" below
End IF
Call LogDebugString("Version:" + svVersion, INFO_LEVEL_DETAIL)
Call oHwMgmtSoftwareInstance.AddProperty("$MPElement[Name='IBM.WinSw.HwMgmt']/Version$", CStr(svVersion))
Exit For
End If
Next
Else
For Each oObjectItem in oServiceCollection
If InStr(oObjectItem.Name, svServiceName) &lt;&gt; 0 Then
Call LogDebugString(svServiceName +" Service Presented", INFO_LEVEL)
isvFlag = 1
svTargetFile = oObjectItem.PathName
If Instr(svTargetFile, """") &lt;&gt; 0 Then
oFile = GetAccurateName(svTargetFile)
Else
oFile = svTargetFile
End If
Call LogDebugString("TargetFile:" + oFile, INFO_LEVEL)
Call oHwMgmtSoftwareInstance.AddProperty("$MPElement[Name='IBM.WinSw.HwMgmt']/TargetFile$", CStr(oFile))
Set oFso = CreateObject("Scripting.FileSystemObject")
' XB047042/byou: x86 RSA-II daemon has the Pathname pointing to %SystemDrive%\system32, but actually
' it gets placed onto %SystemDrive%\SysWOW64 on x64 Windows.
If oFso.FileExists(oFile) Then
svVersion = oFso.GetFileVersion(oFile)
Else
' XB047042/byou: In AddIncompatibleBag(), it will look for "undetermined" in the Version,
' and it will report an error if so.
svVersion = "Version undetermined - file '" + oFile + "' does not exist!!"
End If

Call LogDebugString("Version:" + svVersion, INFO_LEVEL_DETAIL)
Call oHwMgmtSoftwareInstance.AddProperty("$MPElement[Name='IBM.WinSw.HwMgmt']/Version$", CStr(svVersion))
Exit For
End If
Next
End If
End If
End If
If isvFlag = -1 Then
Call LogDebugString(svServiceName + " Service not Presented", WARNING_LEVEL_DEV)
Call oHwMgmtSoftwareInstance.AddProperty("$MPElement[Name='IBM.WinSw.HwMgmt']/TargetFile$", "Unknown")
Call oHwMgmtSoftwareInstance.AddProperty("$MPElement[Name='IBM.WinSw.HwMgmt']/Version$", "Unknown")
End If
End Function


</Script></ScriptBody>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
</DataSource>
</MemberModules>
<Composition>
<Node ID="DS"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.Discovery.Data</OutputType>
</DataSourceModuleType>