How to Display Monitor Thresholds

適用於: Operations Manager 2007

To display monitor thresholds, use the script that is provided 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

Type

The type of objects to which the monitor is targeted

DisplayName

The display name of the monitor

Threshold

The threshold used by the monitor

AlertOnState

Determines whether the monitor generates an alert when the state changes

AutoResolveAlert

Determines whether the generated alert will be resolved automatically when the monitor state goes back to green

AlertSeverity

The severity of the generated alert

Copy the following script to a text file and save the file as a Windows PowerShell script by renaming the file to monitors.ps1. Run the script in Operations Manager Shell. This script creates a .csv file that displays the monitor thresholds:

function GetThreshold ([String] $configuration)

{

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

$threshold = $config.Config.Threshold

if($threshold -eq $null)

{

$threshold = $config.Config.MemoryThreshold

}

if($threshold -eq $null)

{

$threshold = $config.Config.CPUPercentageThreshold

}

if($threshold -eq $null)

{

if($config.Config.Threshold1 -ne $null -and $config.Config.Threshold2 -ne $null)

{

$threshold = "first threshold is: " + $config.Config.Threshold1 + " second threshold is: " + $config.Config.Threshold2

}

}

if($threshold -eq $null)

{

if($config.Config.ThresholdWarnSec -ne $null -and $config.Config.ThresholdErrorSec -ne $null)

{

$threshold = "warning threshold is: " + $config.Config.ThresholdWarnSec + " error threshold is: " + $config.Config.ThresholdErrorSec

}

}

if($threshold -eq $null)

{

if($config.Config.LearningAndBaseliningSettings -ne $null)

{

$threshold = "no threshold (baseline monitor)"

}

}

return $threshold

}

$perfMonitors = get-monitor -Criteria:"IsUnitMonitor=1 and Category='PerformanceHealth'"

$perfMonitors | select-object @{name="Target";expression={foreach-object {(Get-MonitoringClass -Id:$_.Target.Id).DisplayName}}},DisplayName, @{name="Threshold";expression={foreach-object {GetThreshold $_.Configuration}}}, @{name="AlertOnState";expression={foreach-object {$_.AlertSettings.AlertOnState}}}, @{name="AutoResolveAlert";expression={foreach-object {$_.AlertSettings.AutoResolve}}}, @{name="AlertSeverity";expression={foreach-object {$_.AlertSettings.AlertSeverity}}} | sort Target, DisplayName | export-csv "c:\monitor_thresholds.csv"

注意

If you receive an error message indicating that access to the path is denied, modify the line export-csv “C\monitor_thresholds.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\monitor_thresholds.csv”.