Lenovo HwComponentsGroup2 - Provider di rilevamento

IBM.HwComponentsGroup2.DiscoveryProvider (DataSourceModuleType)

Lenovo HwComponentsGroup2 - 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 HwComponentsGroup2 - Secondi intervallo provider di rilevamento
TimeoutSecondsint$Config/TimeoutSeconds$Lenovo HwComponentsGroup2 - Secondi timeout provider di rilevamento

Source Code:

<DataSourceModuleType ID="IBM.HwComponentsGroup2.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>IBMHwComponentsGroup2Discovery.vbs</ScriptName>
<Arguments>"$MPElement$" "$Target/Id$" "$Target/ManagementGroup/Name$" "$Target/Property[Type="IBM.SystemX.BaseSystem"]/HostPrincipalName$" "$Target/Property[Type="IBM.SystemX.BaseSystem"]/SystemUUID$" "$Target/Property[Type="IBM.SystemX.BaseSystem"]/HostPlatformAgentInfo$" "$Target/Host/Property[Type="IBM.SystemX.Platform"]/Licensed$"</Arguments>
<ScriptBody><Script>
' For Power suppley, Cooling fan, Temperature sensor, Voltage sensor and Other device discovering
'

'Const FAN_INSTANCE_NAME = "Cooling Fan"
'Const NETWORK_INSTANCE_NAME = "Network"
'Const POWERSUPPLY_INSTANCE_NAME = "Power Supply"
'Const VOLTAGE_INSTANCE_NAME = "Voltage Sensor"
'Const TEMPERATURE_INSTANCE_NAME = "Temperature Sensor"

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

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

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

EventID = 106
Call HwComponentsGroup2Discovery()

'All Hardware System Discovery
Sub HwComponentsGroup2Discovery()

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


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

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

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

Call oAPI.Return(oDiscoveryData)

End Sub


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

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

Call LogDebugString("Entering CreateAllHwComponentsGroup2", INFO_LEVEL_FUNCTION)

CreateAllHwComponentsGroup2 = -1

Call CreateAllPowerSupplyInstances()
Call CreateAllCoolingFanInstances()
Call CreateAllTemperatureSensorInstances()
Call CreateAllVoltageSensorInstances()
Call CreateAllOtherDeviceInstances()

CreateAllHwComponentsGroup2 = 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 Power Supply =========================

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

'Getting Physical Memory's instance
iResult = GetWMIObjectCollection(IBMSD_NAMESPACE, "IBMPSG_PowerSupply", colInstances)
'If (iResult &gt; 0) and (hwLicense &lt;&gt; "None") Then
If (iResult &gt; 0) Then
For Each oObjectItem in colInstances
CreateOnePowerSupplyInstance(oObjectItem)
Next
'ElseIf (iResult &gt; 0) and (hwLicense = "None") Then
' CreateNonLicensedPS()
Else
Call LogDebugString("Can not get PowerSupply collection instance", WARNING_LEVEL)
End If

CreateAllPowerSupplyInstances = 1
End Function

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

Call oTargetInstance.AddProperty("$MPElement[Name='IBM.SystemX.HWComponent']/InstanceID$", POWERSUPPLY_INSTANCE_NAME)

Call BindHosterKeyProperty(oTargetInstance)

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

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

Call UpdatePowerSupplyProperty(oTargetInstance, oObjectItem)

Call BindHosterKeyProperty(oTargetInstance)

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

CreateOnePowerSupplyInstance = 1
End Function

Function UpdatePowerSupplyProperty(ByRef oTargetInstance, ByVal oObjectItem)
Call LogDebugString("Entering UpdatePowerSupplyProperty", INFO_LEVEL_FUNCTION)
Dim oInstanceID
oInstanceID = oObjectItem.DeviceID

Call oTargetInstance.AddProperty("$MPElement[Name='IBM.SystemX.HWComponent']/InstanceID$", oInstanceID)

End Function

'=========================== Create Instances for All Cooling Fan =========================

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

'Getting Physical CoolingFan's instance (use IBMPSG_Fan for agent prior 6.1.x and later)
If(IsRegExpMatched(agentVersion, "^5\.")) Then
iResult = GetWMIObjectCollection(IBMSD_NAMESPACE, "IBMPSG_Fan", colInstances)
Else
iResult = GetWMIObjectCollection(IBMSD_NAMESPACE, "IBMPSG_Tachometer", colInstances)
End If

'If (iResult &gt; 0) and (hwLicense &lt;&gt; "None") Then
If (iResult &gt; 0) Then
For Each oObjectItem in colInstances
CreateOneCoolingFanInstance(oObjectItem)
Next
'ElseIf (iResult &gt; 0) and (hwLicense = "None") Then
' CreateNonLicensedFan()
Else
Call LogDebugString("Can not get CoolingFan collection instance", INFO_LEVEL)
End If

CreateAllCoolingFanInstances = 1
End Function

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

Call oTargetInstance.AddProperty("$MPElement[Name='IBM.SystemX.HWComponent']/InstanceID$", FAN_INSTANCE_NAME)
Call oTargetInstance.AddProperty("$MPElement[Name='IBM.SystemX.CoolingFan']/SensorLocation$", NA)

Call BindHosterKeyProperty(oTargetInstance)

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

CreateNonLicensedFan = 1
End Function

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

Call UpdateCoolingFanProperty(oTargetInstance, oObjectItem)

Call BindHosterKeyProperty(oTargetInstance)

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

CreateOneCoolingFanInstance = 1
End Function

Function UpdateCoolingFanProperty(ByRef oTargetInstance, ByVal oObjectItem)
Call LogDebugString("Entering UpdateCoolingFanProperty", INFO_LEVEL_FUNCTION)
Dim oInstanceID, sSensorLocation
oInstanceID = "Unknown"
sSensorLocation = "Unknown"
ON ERROR RESUME NEXT ' Skip errors below, some of which may not always exist
oInstanceID = oObjectItem.DeviceID
sSensorLocation = CStr(oObjectItem.Description)
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.CoolingFan']/SensorLocation$", sSensorLocation)

End Function

'=========================== Create Instances for All Temperature Sensor =========================

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

'Getting Physical Memory's instance
iResult = GetWMIObjectCollection(IBMSD_NAMESPACE, "IBMPSG_TemperatureSensor", colInstances)
'If (iResult &gt; 0) and (hwLicense &lt;&gt; "None") Then
If (iResult &gt; 0) Then
For Each oObjectItem in colInstances
CreateOneTemperatureSensorInstance(oObjectItem)
Next
'ElseIf (iResult &gt; 0) and (hwLicense = "None") Then
' CreateNonLicensedTemperature()
Else
Call LogDebugString("Can not get TemperatureSensor collection instance", INFO_LEVEL)
End If

CreateAllTemperatureSensorInstances = 1
End Function

Function CreateNonLicensedTemperature()
Call LogDebugString("Entering CreateNonLicensedTemperature", INFO_LEVEL_FUNCTION)
CreateNonLicensedTemperature = -1
Dim oTargetInstance
Set oTargetInstance = oDiscoveryData.CreateClassInstance("$MPElement[Name='IBM.SystemX.TemperatureSensor']$")
Call oTargetInstance.AddProperty("$MPElement[Name='IBM.SystemX.HWComponent']/InstanceID$", TEMPERATURE_INSTANCE_NAME)
Call oTargetInstance.AddProperty("$MPElement[Name='IBM.SystemX.TemperatureSensor']/SensorLocation$", na)

Call BindHosterKeyProperty(oTargetInstance)

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

CreateNonLicensedTemperature = 1
End Function

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

Call UpdateTemperatureSensorProperty(oTargetInstance, oObjectItem)

Call BindHosterKeyProperty(oTargetInstance)

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

CreateOneTemperatureSensorInstance = 1
End Function

Function UpdateTemperatureSensorProperty(ByRef oTargetInstance, ByVal oObjectItem)
Call LogDebugString("Entering UpdateTemperatureSensorProperty", INFO_LEVEL_FUNCTION)
Dim oInstanceID, sSensorLocation
oInstanceID = "Unknown"
sSensorLocation = "Unknown"
ON ERROR RESUME NEXT ' Skip errors below, some of which may not always exist
oInstanceID = oObjectItem.DeviceID
sSensorLocation = CStr(oObjectItem.Description)
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.TemperatureSensor']/SensorLocation$", sSensorLocation)

End Function

'=========================== Create Instances for All Voltage Sensor =========================

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

'Getting Physical Memory's instance
iResult = GetWMIObjectCollection(IBMSD_NAMESPACE, "IBMPSG_VoltageSensor", colInstances)
'If (iResult &gt; 0) and (hwLicense &lt;&gt; "None") Then
If (iResult &gt; 0) Then
For Each oObjectItem in colInstances
CreateOneVoltageSensorInstance(oObjectItem)
Next
'ElseIf (iResult &gt; 0) and (hwLicense = "None") Then
' CreateNonLicensedVoltage()
Else
Call LogDebugString("Can not get VoltageSensor collection instance", INFO_LEVEL)
End If

CreateAllVoltageSensorInstances = 1
End Function

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

Call oTargetInstance.AddProperty("$MPElement[Name='IBM.SystemX.HWComponent']/InstanceID$", VOLTAGE_INSTANCE_NAME)
Call oTargetInstance.AddProperty("$MPElement[Name='IBM.SystemX.VoltageSensor']/SensorLocation$", NA)

Call BindHosterKeyProperty(oTargetInstance)

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

CreateNonLicensedVoltage = 1
End Function

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

Call UpdateVoltageSensorProperty(oTargetInstance, oObjectItem)

Call BindHosterKeyProperty(oTargetInstance)

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

CreateOneVoltageSensorInstance = 1
End Function

Function UpdateVoltageSensorProperty(ByRef oTargetInstance, ByVal oObjectItem)
Call LogDebugString("Entering UpdateVoltageSensorProperty", INFO_LEVEL_FUNCTION)
Dim oInstanceID, sSensorLocation
oInstanceID = "Unknown"
sSensorLocation = "Unknown"
ON ERROR RESUME NEXT ' Skip errors below, some of which may not always exist
oInstanceID = oObjectItem.DeviceID
sSensorLocation = CStr(oObjectItem.Description)
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.VoltageSensor']/SensorLocation$", sSensorLocation)

End Function

'=========================== Create Instances for All Other Device =========================

Function CreateAllOtherDeviceInstances()
Call LogDebugString("Entering CreateAllOtherDeviceInstances", INFO_LEVEL_FUNCTION)
CreateAllOtherDeviceInstances = -1
Dim oDeviceInstance

Set oDeviceInstance = oDiscoveryData.CreateClassInstance("$MPElement[Name='IBM.SystemX.OtherDevice']$")

Call UpdateOtherDeviceProperty(oDeviceInstance)
Call BindHosterKeyProperty(oDeviceInstance)

Call LogDebugString("Created an other device instance; adding to discovery data", INFO_LEVEL_DETAIL)
Call oDiscoveryData.AddInstance(oDeviceInstance)

CreateAllOtherDeviceInstances = 1
End Function

Function UpdateOtherDeviceProperty(ByRef oOtherInstance)
Call LogDebugString("Entering UpdateOtherDeiveProperty", INFO_LEVEL_FUNCTION)
Call oOtherInstance.AddProperty("$MPElement[Name='IBM.SystemX.HWComponent']/InstanceID$", "Other Devices")
End Function

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


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