Fan.DiscoveryRule (DataSourceModuleType)

Element properties:

TypeDataSourceModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
OutputTypeSystem.Discovery.Data

Member Modules:

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

Overrideable Parameters:

IDParameterTypeSelector
IntervalSecondsint$Config/IntervalSeconds$

Source Code:

<DataSourceModuleType ID="Fan.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="DsFanPs" TypeID="Windows!Microsoft.Windows.TimedPowerShell.DiscoveryProvider">
<IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
<SyncTime/>
<ScriptName>DiscoverFan.PS1</ScriptName>
<ScriptBody><Script>

# **********************************************************************************
# Script Name : DiscoverFan
# Authored by : MphasiS Corporation
# Description : Discovers Lenovo Servers Fan Properties thru Out-Of Band
#
# 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'
$discoveryFan = $api.CreateDiscoveryData(0, $SourceId, $ManagedEntityId)

$SCOMServer_Reg = (New-Object -ComObject WScript.Shell).RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Machine Settings\DefaultSDKServiceMachine")

$LocalHostName = [System.Net.Dns]::GetHostByName('localhost').HostName

IF ($SCOMServer_Reg -eq $LocalHostName)
{
#Import-Module OperationsManager
$ServersList = Get-SCOMClass -Name 'Lenovo.TMM.Server.MP.Host.Class' | Get-SCOMClassInstance | Select *.HostName, *.BMCIP

foreach($Server in $ServersList)
{
$ServerName = $Server.'[Lenovo.TMM.Server.MP.Host.Class].HostName'.Value
$BMCIPAddress = $Server.'[Lenovo.TMM.Server.MP.Host.Class].BMCIP'.Value

$BMCData = Get-SCOMClass -Name 'Lenovo.TMM.Server.MP.LenovoBMC.Class' | Get-SCOMClassInstance | where {$_.DisplayName -eq $ServerName } | Select *.UserName, *.Password
$BMCUserName = $BMCData.'[Lenovo.TMM.Server.MP.LenovoBMC.Class].UserName'.Value
$BMCPassword = $BMCData.'[Lenovo.TMM.Server.MP.LenovoBMC.Class].Password'.Value

#Enc - Code#
$dllPath = ${Env:LENOVOPARTNERPACK_HOME} + "\bin\LenovoCryptoLib.dll"
[Reflection.Assembly]::LoadFile($dllPath)
$EncInstance = New-Object LenovoCryptoLib.LenovoAsymmetricEncryption
$EncInstance.CheckKeyAndSet();
$BMCUserName = $EncInstance.DecryptText($BMCUserName, $EncInstance.PrivateKey, 1024);
$BMCPassword = $EncInstance.DecryptText($BMCPassword, $EncInstance.PrivateKey, 1024);
$JavaFilePath = ${Env:LENOVOPARTNERPACK_HOME}+ '\Lib\jre8\bin\java.exe'
#Enc - Code#

if (($BMCUserName -ne $null) -and ($BMCPassword -ne $null))
{
$FanJarFilePath = "${Env:LENOVOPARTNERPACK_HOME}"+ "\Lib\VeraxIPMIWrapper.jar"

Try
{
$ServiceId = &amp; $JavaFilePath -jar $FanJarFilePath "service-id" $BMCIPAddress $BMCUserName $BMCPassword
if (($ServiceId -ne $null) -and ($ServiceId.Trim() -ne '') -and ($ServiceId.indexof("AMI") -ge 0))
{
$FanJarFilePath = "${Env:LENOVOPARTNERPACK_HOME}"+ "\Lib\LenovoHAPI.jar"
}
$FansList = &amp; $JavaFilePath -jar $FanJarFilePath fan $BMCIPAddress $BMCUserName $BMCPassword | ConvertFrom-Json
}
Catch
{
LogEntry("Error while fetching Fan details using Out of band for "+ $computerName)
}

if ($FansList.result.Count -gt 0)
{
foreach ($Fan in $FansList.result)
{
if ($Fan.name -ne $null)
{
if( $Fan.speed -eq 0)
{
$FanText = "Not Available"
}
else
{
$FanText = $Fan.speed
}
$instance = $discoveryFan.CreateClassInstance("$MPElement[Name='Lenovo.TMM.Server.MP.Inventory.Fan.Class']$")
$Description = $Fan.name
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $Description)
$instance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", $ServerName)
$instance.AddProperty("$MPElement[Name='Lenovo.TMM.Server.MP.Inventory.Fan.Class']/FanDescription$", $Description)
$instance.AddProperty("$MPElement[Name='Lenovo.TMM.Server.MP.Inventory.Fan.Class']/RotationalSpeed$", $FanText )
$instance.AddProperty("$MPElement[Name='Lenovo.TMM.Server.MP.Inventory.Fan.Class']/LowerCriticalThreshold$", [int]$Fan.lowerCriticalThreshold)
$instance.AddProperty("$MPElement[Name='Lenovo.TMM.Server.MP.Inventory.Fan.Class']/LowerNonCriticalThreshold$", [int]$Fan.lowerNonCriticalThreshold )
$instance.AddProperty("$MPElement[Name='Lenovo.TMM.Server.MP.Inventory.Fan.Class']/LowerNonRecoverableThreshold$", [int]$Fan.lowerNonRecoverableThreshold)
$discoveryFan.AddInstance($instance)
}
}
}
}
}
}
$discoveryFan

</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>3600</TimeoutSeconds>
</DataSource>
</MemberModules>
<Composition>
<Node ID="DsFanPs"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.Discovery.Data</OutputType>
</DataSourceModuleType>