How to Display Performance Collection Rules

適用於: Operations Manager 2007, Operations Manager 2007 R2, Windows 2000 Server, Windows Server 2003, Windows Server 2008

To display performance collection rules, use the script in this topic. This script works for the majority of monitors. The script creates a .csv file that includes the following columns. You can view the script by using Microsoft Excel.

 

Column Description

WriteAction

Contains information about where the performance counter is written

WriteToDB or CollectionPerformanceData

Writes to the Operations Manager database

WriteToDW or CollectPerfDataWarehouse

Writes to the data warehouse

WC

Stores baseline data for a performance counter in the operational database

Copy the following script to a text file, and then save the file as a Windows PowerShell script by renaming the file to monitors.ps1. Run the script in Operations Manager Shell. The script creates a .csv file that displays the performance collection rules that are present in the management group.

function GetPerfCounterName ([String] $configuration)

{

$config = [xml] ("<config>" + $configuration + "</config>")

return ($config.Config.ObjectName + "\" + $config.Config.CounterName)

}

function GetFrequency ([String] $configuration)

{

$config = [xml] ("<config>" + $configuration + "</config>")

$frequency = $config.Config.Frequency;

if($frequency -eq $null)

{

$frequency = $config.Config.IntervalSeconds;

}

return ($frequency)

}

function GetDisplayName($performanceRule)

{

if($performanceRule.DisplayName -eq $null)

{

return ($performanceRule.Name);

}

else

{

return ($performanceRule.DisplayName);

}

}

function GetWriteActionNames($performanceRule)

{

$writeActions = "";

foreach($writeAction in $performanceRule.WriteActionCollection)

{

$writeActions += " " + $writeAction.Name;

}

return ($writeActions);

}

$perf_collection_rules = get-rule -criteria:"Category='PerformanceCollection'"

$perf_collection_rules | select-object @{name="Type";expression={foreach-object {(Get-MonitoringClass -id:$_.Target.Id).DisplayName}}},@{name="RuleDisplayName";expression={foreach-object {GetDisplayName $_}}} ,@{name="CounterName";expression={foreach-object {GetPerfCounterName $_.DataSourceCollection[0].Configuration}}},@{name="Frequency";expression={foreach-object {GetFrequency $_.DataSourceCollection[0].Configuration}}},@{name="WriteActions";expression={foreach-object {GetWriteActionNames $_}}} | sort Type,RuleDisplayName,CounterName | export-csv "c:\perf_collection_rules.csv"

note附註
If you receive an error message indicating that access to the path is denied, modify the line export-csv “C\perf_collection_rules.csv” to use a path to which the user account has access. For example, user accounts should have access to their profile path. From a command prompt, you can run the command echo %userprofile% to find out the physical path to the user profile (for example, C:\Users\ALyon). When you have the user profile path, use that instead of c:\ in the script, for example, export-csv “c:\users\ALyon\perf_collection_rules.csv”.

社群新增項目

顯示: