System Center 2016 Virtual Machine Manager 호스트 CPU 사용률

Microsoft.SystemCenter.VirtualMachineManager.2016.HostCPUUtilizationMonitor (UnitMonitor)

호스트 CPU 사용률을 모니터링합니다.

Knowledge Base article:

요약

이모니터는호스트의 CPU 성능을추적합니다. CPU 사용률이임계값을초과했습니다.

원인

호스트에서실행중인가상컴퓨터가호스트 CPU 리소스를위험수준으로사용하고있습니다.

해결 방법

CPU 리소스를 확보하려면 가상 컴퓨터를 다른 호스트로 마이그레이션합니다. Virtual Machine Manager가 동적 최적화 기능을 사용하여 호스트 클러스터를 자동으로 최적화할 수도 있습니다. 동적 최적화에 대한 자세한 내용은 Virtual Machine Manager 설명서를 참조하십시오.

Element properties:

TargetMicrosoft.SystemCenter.VirtualMachineManager.2016.HyperVHost
Parent MonitorSystem.Health.AvailabilityState
CategoryAvailabilityHealth
EnabledTrue
Alert GenerateTrue
Alert SeverityMatchMonitorHealth
Alert PriorityNormal
Alert Auto ResolveTrue
Monitor TypeMicrosoft.SystemCenter.VirtualMachineManager.2016.Performance.PowershellBasedConsecutiveSamplesTwoThresholdsMonitorType
RemotableTrue
AccessibilityPublic
Alert Message
호스트 CPU 사용률 높음
호스트 CPU 사용률이 {1}이고 {0}에 대한 경고 또는 위험 수준을 초과했습니다.
RunAsDefault

Source Code:

<UnitMonitor ID="Microsoft.SystemCenter.VirtualMachineManager.2016.HostCPUUtilizationMonitor" Accessibility="Public" Target="VMM2016Discovery!Microsoft.SystemCenter.VirtualMachineManager.2016.HyperVHost" ParentMonitorID="SystemHealth!System.Health.AvailabilityState" Remotable="true" TypeID="Microsoft.SystemCenter.VirtualMachineManager.2016.Performance.PowershellBasedConsecutiveSamplesTwoThresholdsMonitorType">
<Category>AvailabilityHealth</Category>
<AlertSettings AlertMessage="Microsoft.SystemCenter.VirtualMachineManager.2016.HostCPUUtilizationMonitor.AlertMessage">
<AlertOnState>Warning</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>MatchMonitorHealth</AlertSeverity>
<AlertParameters>
<AlertParameter1>$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$</AlertParameter1>
<AlertParameter2>$Data/Context/SampleValue$</AlertParameter2>
</AlertParameters>
</AlertSettings>
<OperationalStates>
<OperationalState ID="HostCPUUtilizationReachedWarning" MonitorTypeStateID="ConditionWarn" HealthState="Warning"/>
<OperationalState ID="HostCPUUtilizationReachedError" MonitorTypeStateID="ConditionError" HealthState="Error"/>
<OperationalState ID="HostCPUUtilizationIsSuccess" MonitorTypeStateID="ConditionSuccess" HealthState="Success"/>
</OperationalStates>
<Configuration>
<IntervalSeconds>180</IntervalSeconds>
<TimeoutSeconds>180</TimeoutSeconds>
<WarningThreshold>90</WarningThreshold>
<CriticalThreshold>95</CriticalThreshold>
<NumSamples>3</NumSamples>
<hostComputerName>$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$</hostComputerName>
<ScriptBody><Script>#This Script is used to check the Host CPU utilization
# which includes parent partition and CPU utilizations caused by the vms
# Alert when the utilization of this partition is high:
# Warning: WarningThreshold%, like 80%
# Critical: CriticalThreshold, like 90%
#SetLocale("en-us")
#Please check this link to get understanding http://blogs.msdn.com/b/tvoellm/archive/2008/07/14/how-to-get-processor-utilization-for-hyper-v-via-wmi.aspx

$momApi = new-Object -comObject "Mom.ScriptAPI"
$momBag = $momApi.CreatePropertyBag()
$timePeriodSeconds = 10
#$strLPTotalQuery = "SELECT * FROM Win32_PerfRawData_HvStats_HyperVHypervisorLogicalProcessor where Name='_Total'"
#$strLPCountQuery = "SELECT * FROM Win32_PerfRawData_HvStats_HyperVHypervisorLogicalProcessor"
$logicalProcessorStats=Get-CimInstance -ClassName "Win32_PerfRawData_HvStats_HyperVHypervisorLogicalProcessor" -Namespace "root\cimv2" -Computername "localhost"
$logicalProcessorStatsCount=$logicalProcessorStats.Count
if($logicalProcessorStatsCount -lt 1)
{
exit
}
$totalLogicalProcessorStats=Get-CimInstance -ClassName "Win32_PerfRawData_HvStats_HyperVHypervisorLogicalProcessor" -Namespace "root\cimv2" -ComputerName "localhost" -Filter "Name='_Total'"
ForEach ($item in $totalLogicalProcessorStats)
{
$percentTotalRunTime_First= $item.PercentTotalRunTime
$timestamp_PerfTime_First = $item.Timestamp_PerfTime
}

Start-Sleep $timePeriodSeconds

$totalLogicalProcessorStats=Get-CimInstance -ClassName "Win32_PerfRawData_HvStats_HyperVHypervisorLogicalProcessor" -Namespace "root\cimv2" -ComputerName "localhost" -Filter "Name='_Total'"
ForEach ($item in $totalLogicalProcessorStats)
{
$frequency_PerfTime = $item.Frequency_PerfTime
$percentTotalRunTime_Second= $item.PercentTotalRunTime
$timestamp_PerfTime_Second = $item.Timestamp_PerfTime
}

if($percentTotalRunTime_Second - $percentTotalRunTime_First -eq 0)
{
$momApi.LogScriptEvent("HostCPUUtilizationProvider.ps1", 101, 0, "The readings were not taken properly and hence the script could not be executed.")
exit 1
}

#Calculate CPU readings with formula
$CPU = ($timestamp_PerfTime_Second - $timestamp_PerfTime_First) / ( $percentTotalRunTime_Second - $percentTotalRunTime_First)
$CPU = ($frequency_PerfTime * $CPU) / $logicalProcessorStatsCount
$CPU = [int]($CPU / 100000)

if( $CPU -gt 100)
{
$CPU = 100
}
if( $CPU -lt 0)
{
$CPU = 0
}

$CPU = [int]($CPU)
$momBag.AddValue("Utilization", $CPU)
$momBag

</Script></ScriptBody>
<ObjectName>Win32_PerfRawData_HvStats_HyperVHypervisorLogicalProcessor</ObjectName>
<CounterName>PercentTotalRunTime</CounterName>
<InstanceName>_Total</InstanceName>
<Value>$Data/Property[@Name='Utilization']$</Value>
</Configuration>
</UnitMonitor>