Clustered Data ONTAP: Storage Efficiency Rule

DataONTAP.Cluster.Monitoring.StorageEfficiency.Rule (Rule)

The Storage Efficiency Rule inserts the Cluster Storage Efficiency counter into the System Center Operations Manager database and puts it into the System Center Operations Manager Data Warehouse.

Knowledge Base article:

Summary

The Storage Efficiency Rule inserts the Cluster Storage Efficiency counter into the System Center Operations Manager database and puts it into the System Center Operations Manager Data Warehouse. This rule works in conjunction with all the other performance collection counter rules in this management pack.

Configuration

Three overrides are available for this rule. Sync Time and Interval Seconds determine when and how often the rule runs. Timeout Seconds determines how long System Center Operations Manager waits for the rule to complete.

If you want to override parameters for any of the performance rules, ensure that all rules use the same override parameter values.

Resolutions

If you suspect a problem with this rule, check the OnCommand and System Center Operations Manager event logs on the management server running the rule.

Element properties:

TargetDataONTAP.Cluster.Vserver
CategoryAvailabilityHealth
EnabledTrue
Alert GenerateFalse
RemotableTrue

Member Modules:

ID Module Type TypeId RunAs 
SimpleSchedulerDataSource DataSource System.SimpleScheduler Default
RunMonitoringWriteAction WriteAction Microsoft.Windows.PowerShellWriteAction DataONTAP.SecureReference.RunAsProfile

Source Code:

<Rule ID="DataONTAP.Cluster.Monitoring.StorageEfficiency.Rule" Target="DataONTAP.Cluster.Vserver" Enabled="true" ConfirmDelivery="false" Remotable="true" Priority="Normal" DiscardLevel="100">
<Category>AvailabilityHealth</Category>
<DataSources>
<DataSource ID="SimpleSchedulerDataSource" TypeID="System!System.SimpleScheduler">
<!-- IntervalSeconds specifies how often we will run the rule - once per day -->
<IntervalSeconds>86400</IntervalSeconds>
<!-- SyncTime specifies the minutes after the hour to synchronize execution of the rule. -->
<SyncTime>00:55</SyncTime>
</DataSource>
</DataSources>
<WriteActions>
<WriteAction ID="RunMonitoringWriteAction" TypeID="Windows!Microsoft.Windows.PowerShellWriteAction" RunAs="DS!DataONTAP.SecureReference.RunAsProfile">
<ScriptName>StorageEfficiency.ps1</ScriptName>
<ScriptBody><Script>##############################################################################
# Copyright (c) 2013 NetApp.
#
# StorageEfficiency.ps1
#
# This script to collect storage efficiency statistics.
#
##############################################################################
Param($VserverUUID)

##############################################################################
#Script utilities
function GetInstallPath
{
$netappRegPath = "HKLM:\SOFTWARE\NetApp\OnCommand\MS_Plugin"
$ibmRegPath = "HKLM:\SOFTWARE\IBM\OnCommand\MS_Plugin"

if (Test-Path -path $netappRegPath)
{
# Check for the registry key value of the install location for NetApp
$key = get-itemproperty $netappRegPath
}
elseif (Test-Path -path $ibmRegPath)
{
# Check for IBM registry key since can't find NetApp
$key= get-itemproperty $ibmRegPath
}
else
{
throw ("OnCommand Plug-in for Microsoft is not installed on " + $env:COMPUTERNAME + "`r`n")
}

return $key.InstallPath
}

function CreateAppDomain
{
$setup = [AppDomain]::CurrentDomain.SetupInformation;
$setup.ShadowCopyFiles = $true
return [AppDomain]::CreateDomain("OC.Cluster.OM.Powershell.NonDefaultAppDomain",
$null,
$setup);
}

function InvokeMethodInAppDomain([AppDomain]$appDomain,
[string]$assemblyPath,
[string]$typename,
[array]$contructorParameters,
[string]$methodName,
[array]$methodParameters)
{
#In SCOM a Powershell script is executed in a MonitoringHost.exe process.
#Lifetime of a MonitoringHost.exe is not controlled by us and it continues to run after the script is done, possibly
#running other scripts or the same script again. A script is executed in a default AppDomain (by SCOM design) and
#as a result any assemblies loaded by script can not be unloaded because the defualt AppDomain can not be unloaded.
#Impossibility of unloading an assembly becomes a problem when then the assembly DLL is being updated
#(i.e. during an istallation), the problem is that even after the assembly DLL is updated,
#the new assembly code is not loaded if the assembly is already loaded.
#The solution for this problem is to load an assembly to a non-default domain which can be unloaded when the script is done.

#The OC.Cluster.OM.AppDomainInvoker assembly has to be in the GAC
$AppDomainInvokerAssembly = [System.Reflection.Assembly]::LoadWithPartialName('OC.Cluster.OM.AppDomainInvoker')

$result = [OC.Cluster.OM.AppDomainInvoker.AppDomainInvoker]::InvokeMethod($appDomain,
$assemblyPath,
$typename,
$contructorParameters,
$methodName,
$methodParameters)

return $result
}
##############################################################################

import-module operationsmanager

$Error.Clear();

$scriptName = "StorageEfficiency.ps1"

try
{

$api = new-object -comObject 'MOM.ScriptAPI'

$api.LogScriptEvent($scriptName, 4000, 0, "Getting storage efficiency for Clustered Data ONTAP storage.")

$nonDefaultAppDomain = CreateAppDomain

$installPath = GetInstallPath

$taskOutput = InvokeMethodInAppDomain $nonDefaultAppDomain `
(Join-Path $installPath 'OC.Cluster.OM.Server.dll') `
"OC.Cluster.OM.Server.Monitoring.StorageEfficiency" `
@("localhost") `
"GetStorageEfficiency" `
@($VserverUUID)

#Write task output to the script output
$taskOutput

$api.LogScriptEvent($scriptName, 4001, 0, "Getting storage efficiency for Clustered Data ONTAP storage succeeded.`r`n" + $taskOutput)
}
catch
{
if ($api)
{
$api.LogScriptEvent($scriptName, 4002, 1, "Getting storage efficiency for Clustered Data ONTAP storage failed.`r`n" + $Error)
}

#throw the current error so that it will be displayed in the SCOM task output and status of the task will be set as failed
throw
}
finally
{
if ($nonDefaultAppDomain)
{
[AppDomain]::Unload($nonDefaultAppDomain)
$nonDefaultAppDomain = $null
}
}</Script></ScriptBody>
<Parameters>
<Parameter>
<Name>VserverUUID</Name>
<Value>$Target/Property[Type="DataONTAP.Cluster.Vserver"]/VserverUUID$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>1200</TimeoutSeconds>
</WriteAction>
</WriteActions>
</Rule>