Lenovo HwComponentsGroup3 Discovery Provider

IBM.HwComponentsGroup3.DiscoveryProvider (DataSourceModuleType)

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 HwComponentsGroup3 Discovery Provider Interval Seconds
TimeoutSecondsint$Config/TimeoutSeconds$Lenovo HwComponentsGroup3 Discovery Provider Timeout Seconds

Source Code:

<DataSourceModuleType ID="IBM.HwComponentsGroup3.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>IBMHwComponentsGroup3Discovery.vbs</ScriptName>
<Arguments>"$MPElement$" "$Target/Id$" "$Target/ManagementGroup/Name$" "$Target/Property[Type="IBM.SystemX.BaseSystem"]/HostPrincipalName$" "$Target/Property[Type="IBM.SystemX.BaseSystem"]/SystemUUID$" "$Target/Host/Property[Type="IBM.SystemX.Platform"]/Licensed$" </Arguments>
<ScriptBody><Script>
' For Physical processor discovering
'
'Const PROCESSOR_INSTANCE_NAME = "Physical Processor"

SetLocale("en-us")
Dim oArgs
Set oArgs = WScript.Arguments
WScript.Echo oArgs.Count
if oArgs.Count &lt; 5 Then
'Wscript.Quit -1
End If

'Getting Parameters from MP
Dim sourceID, managedEntityID, managementGroupName, systemUUID, platformPrincipalName,hwLicense

sourceID = oArgs(0)
managedEntityID = oArgs(1)
managementGroupName = oArgs(2)
platformPrincipalName = oArgs(3)
systemUUID = oArgs(4)
hwLicense = oArgs(5)

EventID = 107
Call HwComponentsGroup3Discovery()

'All Hardware System Discovery
Sub HwComponentsGroup3Discovery()

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


Call LogDebugString("Entering HwComponentsGroup3Discovery..." +vbCrlf+ _
" sourceID:'" + CStr(sourceID) + "'" +vbCrlf+ _
" mgdEntityID:'" + CStr(managedEntityID) + "'" +vbCrlf+ _
" mgmtGroup:'" + CStr(managementGroupName) + "'" +vbCrlf+ _
" platformPrin..Name:'" + CStr(platformPrincipalName)+ "'" +vbCrlf+ _
" systemUUID:'" + CStr(systemUUID) + "'", INFO_LEVEL_DETAIL)

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

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

Call oAPI.Return(oDiscoveryData)

End Sub


'===========================================================================================
' Base Hardware Components
'===========================================================================================

'Create Instances for All Base Hardware Components
Function CreateAllHwComponentsGroup3()

Call LogDebugString("Entering CreateAllHwComponentsGroup3", INFO_LEVEL_FUNCTION)

CreateAllHwComponentsGroup3 = -1

Call CreateAllPhysicalProcessorInstances()

CreateAllHwComponentsGroup3 = 1
End Function

'Bind Hoster Key Property
Function BindHosterKeyProperty( ByVal oHWComponentInstance )
Call LogDebugString("Entering BindHosterKeyProperty", INFO_LEVEL_FUNCTION)
Dim oPropertyValue
oPropertyValue = CStr(platformPrincipalName)
Call oHWComponentInstance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", oPropertyValue)

oPropertyValue = CStr(platformPrincipalName)
Call oHWComponentInstance.AddProperty("$MPElement[Name='IBM.SystemX.Platform']/HostPrincipalName$", oPropertyValue)
Call oHWComponentInstance.AddProperty("$MPElement[Name='IBM.SystemX.BaseSystem']/HostPrincipalName$", oPropertyValue)

End Function

'=========================== Create Instances for All Physical Processor =========================

Function CreateAllPhysicalProcessorInstances()
Call LogDebugString("Entering CreateAllPhysicalProcessorInstances", INFO_LEVEL_FUNCTION)
Dim oObjectItem, colInstances, iResult
CreateAllPhysicalProcessorInstances = -1

'Getting Physical Processor's instance
iResult = GetWMIObjectCollection(IBMSD_NAMESPACE, "IBMPSG_Processor", colInstances)
'If (iResult &gt; 0) and (hwLicense &lt;&gt; "None") Then
If (iResult &gt; 0) Then
For Each oObjectItem in colInstances
CreateOnePhysicalProcessorInstance(oObjectItem)
Next
'ElseIf (iResult &gt; 0) and (hwLicense = "None") Then
' CreateNonLicensedProcessor()
Else
Call LogDebugString("Can not get PhysicalProcessor collection instance", WARNING_LEVEL)
End If

CreateAllPhysicalProcessorInstances = 1
End Function

Function CreateNonLicensedProcessor()
Call LogDebugString("Entering CreateNonLicensedProcessor", INFO_LEVEL_FUNCTION)
CreateNonLicensedProcessor = -1
Dim oTargetInstance
Set oTargetInstance = oDiscoveryData.CreateClassInstance("$MPElement[Name='IBM.SystemX.PhysicalProcessor']$")

Call oTargetInstance.AddProperty("$MPElement[Name='IBM.SystemX.HWComponent']/InstanceID$", PROCESSOR_INSTANCE_NAME)
Call oTargetInstance.AddProperty("$MPElement[Name='IBM.SystemX.PhysicalProcessor']/InternalID$", PROCESSOR_INSTANCE_NAME)
Call oTargetInstance.AddProperty("$MPElement[Name='IBM.SystemX.PhysicalProcessor']/SocketLocation$", NA)
Call oTargetInstance.AddProperty("$MPElement[Name='IBM.SystemX.PhysicalProcessor']/ProcessorName$", NA)
Call oTargetInstance.AddProperty("$MPElement[Name='IBM.SystemX.PhysicalProcessor']/ClockSpeed$", NA)
Call oTargetInstance.AddProperty("$MPElement[Name='IBM.SystemX.PhysicalProcessor']/DataWidth$", NA)
Call oTargetInstance.AddProperty("$MPElement[Name='IBM.SystemX.PhysicalProcessor']/NumOfCores$", NA)

Call BindHosterKeyProperty(oTargetInstance)

Call LogDebugString("Created a NonLicensed PhysicalProcessor instance; adding to discovery data", INFO_LEVEL_DETAIL)
Call oDiscoveryData.AddInstance(oTargetInstance)

CreateNonLicensedProcessor = 1
End Function

Function CreateOnePhysicalProcessorInstance(ByVal oObjectItem)
Call LogDebugString("Entering CreateOnePhysicalProcessorInstance", INFO_LEVEL_FUNCTION)
CreateOnePhysicalProcessorInstance = -1
Dim oTargetInstance
Set oTargetInstance = oDiscoveryData.CreateClassInstance("$MPElement[Name='IBM.SystemX.PhysicalProcessor']$")

Call UpdatePhysicalProcessorProperty(oTargetInstance, oObjectItem)

Call BindHosterKeyProperty(oTargetInstance)

Call LogDebugString("Created a PhysicalProcessor instance; adding to discovery data", INFO_LEVEL_DETAIL)
Call oDiscoveryData.AddInstance(oTargetInstance)

CreateOnePhysicalProcessorInstance = 1
End Function

Function UpdatePhysicalProcessorProperty(ByRef oTargetInstance, ByVal oObjectItem)
Call LogDebugString("Entering UpdatePhysicalProcessorProperty", INFO_LEVEL_FUNCTION)
Dim oInstanceID, sSocketLocation, sProcessorName, sDataWidth, sClockSpeed, sNumOfCores, oInternalID
oInstanceID = oObjectItem.DeviceID
oInternalID = GetProcessorInteralID(oInstanceID)

sSocketLocation = "Unknown"
sProcessorName = "Unknown"
sDataWidth = "Unknown"
sClockSpeed = "Unknown"
sNumOfCores = "Unknown"
ON ERROR RESUME NEXT ' Skip errors below, some of which may not always exist
sSocketLocation = CStr(oObjectItem.DeviceID)
sProcessorName = CStr(oObjectItem.Name)
sDataWidth = CStr(oObjectItem.DataWidth)
sClockSpeed = CStr(oObjectItem.CurrentClockSpeed)
sNumOfCores = CStr(oObjectItem.NumberOfEnabledCores)
ON ERROR GOTO 0 ' Break on errors here on.

Call oTargetInstance.AddProperty("$MPElement[Name='IBM.SystemX.HWComponent']/InstanceID$", oInstanceID)
Call oTargetInstance.AddProperty("$MPElement[Name='IBM.SystemX.PhysicalProcessor']/InternalID$", oInternalID)
Call oTargetInstance.AddProperty("$MPElement[Name='IBM.SystemX.PhysicalProcessor']/SocketLocation$", sSocketLocation)
Call oTargetInstance.AddProperty("$MPElement[Name='IBM.SystemX.PhysicalProcessor']/ProcessorName$", sProcessorName)
Call oTargetInstance.AddProperty("$MPElement[Name='IBM.SystemX.PhysicalProcessor']/ClockSpeed$", sClockSpeed)
Call oTargetInstance.AddProperty("$MPElement[Name='IBM.SystemX.PhysicalProcessor']/DataWidth$", sDataWidth)
Call oTargetInstance.AddProperty("$MPElement[Name='IBM.SystemX.PhysicalProcessor']/NumOfCores$", sNumOfCores)

End Function

'=============================================================================================================

Function GetProcessorInteralID(ByVal targetStr)
'This function will add a space between the last letter and the first Arabic numeral if there is no initial space between them.
'Input-&gt;Output
'CPU12-&gt;CPU 12
'Cpu 12-&gt;Cpu 12
'C P U1-&gt;C P U 1
'c p u 1-&gt;c p u 1
GetProcessorInteralID = "Unknown"
Dim iRet, re, patten, matches, matchValue, match, strTemp, strNewTemp
Dim oMatch
Dim oMatches

patten = "^\D+\d+$"
Set re = New RegExp
re.IgnoreCase = False
re.Pattern = patten

If (re.Test(targetStr)) Then
'The target string starts with letter and end with Arabic numeral
re.Pattern = "[a-zA-Z][0-9]"
If (re.Test(targetStr)) Then
'There is no initial space between them
re.Pattern = "[0-9]+"
Set oMatches = re.Execute(targetStr)
For Each oMatch In oMatches
strTemp = oMatch.Value
WScript.echo strTemp
strNewTemp = " " + strTemp
targetStr = Replace(targetStr, strTemp, strNewTemp)
Next
End If
End If
GetProcessorInteralID = targetStr
End Function



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