Processor.DiscoveryRule (DataSourceModuleType)

Element properties:

TypeDataSourceModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
OutputTypeSystem.Discovery.Data

Member Modules:

ID Module Type TypeId RunAs 
DsProcessorPs DataSource Microsoft.Windows.TimedPowerShell.DiscoveryProvider Default

Overrideable Parameters:

IDParameterTypeSelector
IntervalSecondsint$Config/IntervalSeconds$

Source Code:

<DataSourceModuleType ID="Processor.DiscoveryRule" Accessibility="Internal" Batching="false">
<Configuration>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="IntervalSeconds" type="xsd:integer"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="computerName" type="xsd:string"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<DataSource ID="DsProcessorPs" TypeID="Windows!Microsoft.Windows.TimedPowerShell.DiscoveryProvider">
<IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
<SyncTime/>
<ScriptName>DiscoverProcessor.PS1</ScriptName>
<ScriptBody><Script>

# **********************************************************************************
# Script Name : DiscoverProcessor
# Authored by : MphasiS Corporation
# Description : Discovers Lenovo Servers Processor Properties
#
# Copyright (c) 2013 Lenovo Group. All rights reserved.
# Redistribution and use in source and binary forms, with or without modification,
# is not permitted without specific prior written permission from Lenovo.
# **********************************************************************************
param($sourceId,$managedEntityId,$computerName)

#--------------Inventory Logging--------------#
Function LogEntry($LogContent)
{
Try
{
$LoggingFlag_Reg = (New-Object -ComObject WScript.Shell).RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\LenovoPartnerPack\SCOMServer\Log")
if( $LoggingFlag_Reg -eq 1)
{
$SetLogging = $true
}
else
{
$SetLogging = $false
}
}
Catch
{
$SetLogging = $true
}

if ($SetLogging -eq $true)
{
$LogPath = ${Env:LENOVOPARTNERPACK_HOME} + "\Log"

if(![IO.Directory]::Exists($LogPath))
{
New-Item -ItemType directory -Path $LogPath
}

##$LogFileName = "ThinkServerPartnerPack_Inventory_"+ (Get-Date -Format "dd-MMM-yyyy")+".log"
$LogFileName = "ThinkServerPartnerPack_Inventory.log"
$LogFile = $LogPath + "\" + $LogFileName

$LogTime = Get-Date -Format "dd-MMM-yyyy HH:mm:ss"
$LogEntryContent = $LogTime + " : " + $LogContent

$LogEntryContent | Out-File $LogFile -Append -Force
}
}
#--------------Inventory Logging--------------#


$api = new-object -comObject 'MOM.ScriptAPI'
$discoveryProcessor = $api.CreateDiscoveryData(0, $SourceId, $ManagedEntityId)

$Processor_Query = "Select * from Win32_Processor"

$ProcessorModules = Get-WmiObject -namespace "root\cimv2" -Query $Processor_Query

foreach ($ProcessorModule in $ProcessorModules)
{
if($ProcessorModule.Manufacturer.Trim())
{
$Manufacturer = $ProcessorModule.Manufacturer
}
else
{
$Manufacturer = "Not Available"
}
if($ProcessorModule.Name.Trim())
{
$ModelName = $ProcessorModule.Name
}
else
{
$ModelName = "Not Available"
}
if($ProcessorModule.MaxClockSpeed -ge 0)
{
$Speed = [System.Math]::Round(($ProcessorModule.MaxClockSpeed/1000),2)
}
else
{
$Speed = "Not Available"
}
if($ProcessorModule.SocketDesignation.Trim())
{
$SocketNumber = $ProcessorModule.SocketDesignation
}
else
{
$SocketNumber = "Not Available"
}
if($ProcessorModule.NumberOfLogicalProcessors -ge 0)
{
$NumberOfLogicalProcessors = $ProcessorModule.NumberOfLogicalProcessors
}
else
{
$NumberOfLogicalProcessors = "Not Available"
}
if($ProcessorModule.NumberOfCores -ge 0)
{
$NumberOfCores = $ProcessorModule.NumberOfCores
}
else
{
$NumberOfCores = "Not Available"
}
if($ProcessorModule.L2CacheSize -ge 0)
{
$L2CacheSize = $ProcessorModule.L2CacheSize
}
else
{
$L2CacheSize = "Not Available"
}
if($ProcessorModule.L3CacheSize -ge 0)
{
$L3CacheSize = $ProcessorModule.L3CacheSize
}
else
{
$L3CacheSize = "Not Available"
}
if($ProcessorModule.Status.Trim())
{
$ProcessorStatus = $ProcessorModule.Status

if($ProcessorStatus -eq 'OK')
{
$DisplayProcessorStatus = "Normal"
}
elseif ( ($ProcessorStatus -eq 'Error') -or
($ProcessorStatus -eq 'Pred Fail') -or
($ProcessorStatus -eq 'NonRecover') -or
($ProcessorStatus -eq 'NoContact') -or
($ProcessorStatus -eq 'LostComm')
)
{
$DisplayProcessorStatus = "Error"
}
else
{
$DisplayProcessorStatus = "Warning"
}
}
else
{
$DisplayProcessorStatus = "Warning"
}

$instance = $discoveryProcessor.CreateClassInstance("$MPElement[Name='Lenovo.TMM.Server.MP.Inventory.Processor.Class']$")

$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $Manufacturer)

$instance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", $computerName)

$instance.AddProperty("$MPElement[Name='Lenovo.TMM.Server.MP.Inventory.Processor.Class']/Manufacturer$",$Manufacturer)
$instance.AddProperty("$MPElement[Name='Lenovo.TMM.Server.MP.Inventory.Processor.Class']/ModelName$",$ModelName)
$instance.AddProperty("$MPElement[Name='Lenovo.TMM.Server.MP.Inventory.Processor.Class']/Speed$",$Speed)
$instance.AddProperty("$MPElement[Name='Lenovo.TMM.Server.MP.Inventory.Processor.Class']/SocketNumber$",$SocketNumber)
$instance.AddProperty("$MPElement[Name='Lenovo.TMM.Server.MP.Inventory.Processor.Class']/NumberOfLogicalProcessors$",$NumberOfLogicalProcessors)
$instance.AddProperty("$MPElement[Name='Lenovo.TMM.Server.MP.Inventory.Processor.Class']/NumberOfCores$",$NumberOfCores)
$instance.AddProperty("$MPElement[Name='Lenovo.TMM.Server.MP.Inventory.Processor.Class']/L2CacheSize$",$L2CacheSize)
$instance.AddProperty("$MPElement[Name='Lenovo.TMM.Server.MP.Inventory.Processor.Class']/L3CacheSize$",$L3CacheSize)

LogEntry("Processor details for the host " + $computerName + " has been retrived")

$discoveryProcessor.AddInstance($instance)
}
$discoveryProcessor

</Script></ScriptBody>
<Parameters>
<Parameter>
<Name>sourceID</Name>
<Value>$MPElement$</Value>
</Parameter>
<Parameter>
<Name>managedEntityID</Name>
<Value>$Target/Id$</Value>
</Parameter>
<Parameter>
<Name>computerName</Name>
<Value>$Config/computerName$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>120</TimeoutSeconds>
</DataSource>
</MemberModules>
<Composition>
<Node ID="DsProcessorPs"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.Discovery.Data</OutputType>
</DataSourceModuleType>