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


 

Comments (4)

  1. Volker says:

    the script says "The ‘Path’ paramter is empty or the required provider location is not set." How come?

  2. Michael says:

    I am getting the same prompt as Volker, when trying to run this script. It is probably related to how I saved and ran the script. I copied and pasted the entire contents to a .ps1 file and then called this file from the OpsMgr Command Shell.

    Can someone please help? Thanks.

  3. CluelessWithPShell says:

    I am getting the same prompt as Volker, when trying to run this script. It is probably related to how I saved and ran the script. I copied and pasted the entire contents to a .ps1 file and then called this file from the OpsMgr Command Shell.

    Can someone please help? Thanks.

  4. Paul Bendall says:

    I had the same issue with regard to "The ‘Path’ paramter is empty or the required provider location is not set."

    When you start Ops Manager Shell DON’T change to the directory where you saved the script file to. Instead just type the full path to the script, i.e I copied the script and pasted into a file called Get-Thresholds.ps1 which I saved to C:Temp. Therefore, I typed c:tempGet-Threshold.ps1. In so doing the path is taken as the current location in the Ops Manager Shell

    HTH

    Paul