How to Display Monitor Thresholds

Applies To: Operations Manager 2007, Operations Manager 2007 R2

To display monitor thresholds, use the script described in this section. This script works for the majority of monitors. It creates a comma-separated values (.csv) file that includes the following columns and that can be viewed by using Microsoft Office Excel.

Column Description

Type

The type of objects the monitor is targeted to.

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 automatically resolved when the monitor state changes back to green.

AlertSeverity

The severity of the generated alert.

Run the following script to create the .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"