如何部署監視器閾值
適用於: Operations Manager 2007, Operations Manager 2007 R2, Virtual Machine Manager
若要顯示監視器閾值,請使用本節描述的指令碼。大部分監視器均可使用這個指令碼。所建立的 .csv 檔包括下列欄位而且可以使用 Excel 檢視。
欄位 | 描述 |
---|---|
類型 |
監視器指定的物件類型 |
DisplayName |
檢視器的顯示名稱 |
Threshold |
監視器使用的閾值 |
AlertOnState |
判斷監視器在狀態變更時是否要產生警示 |
AutoResolveAlert |
判斷監視器狀態恢復成綠色時是否要自動解決產生的警示 |
AlertSeverity |
所產生警示的嚴重性 |
執行下列指令碼即可產生顯示監視器閾值的 .csv 檔:
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"