So what thresholds do my monitors have?

One of the things people have been asking about is what thresholds are used by various monitors. There is no bullet proof way to do this, but here is a script I wrote that would answer this question for the majority of monitors:

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"

The output of this script is a csv file with the following columns:

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 - whether the monitor generates an alert when its state changes

AutoResolveAlert - whether the generated alert will be autoresolved when the monitor state goes back to green

AlertSeverity - the severity of the generated alert