Fragmentation level

QND.Hyperv.2012R2.VHDFragmentation.Monitor (UnitMonitor)

Knowledge Base article:

Summary

Dynamic and differencing VHDs can be fragmented over time. This monitor checks the VHD fragmentation level. This monitor is disabled by deafult since it can be very noisy. VHD(x) fragmentation is related to the intenrla logical structure of the virtual disk, there are other two posssibile fragmenetations: at the hyper-v host file system level and at the guest file system level.

Configuration

A warning alert is raised when the fragmentation level has reached the threshold of 30% and a critical alert is raised when it has reached 50%.

Resolutions

The easiest way to defrag the VHD is to perform a storage migration.

Additional

When a VHD(x) gets fragmentated the performance are affected. From first informal tests it appears that random reads are particularly affected with a penality of more than 50% in trhoughput for a 100% fragmented VHD.

http://blogs.msdn.com/b/virtual_pc_guy/archive/2015/03/04/checking-and-correcting-virtual-hard-disk-fragmentation.aspx

Element properties:

TargetQND.HyperV.2012R2.VirtualDrive
Parent MonitorSystem.Health.PerformanceState
CategoryPerformanceHealth
EnabledFalse
Alert GenerateTrue
Alert SeverityMatchMonitorHealth
Alert PriorityNormal
Alert Auto ResolveTrue
Monitor TypeQND.Hyperv2012R2.VHDFragmentation.MT
RemotableTrue
AccessibilityPublic
Alert Message
Hyper-V - VHD fragmentation level high
VHD Fragmentation is {0}. Higher than the threshold set.
RunAsDefault

Source Code:

<UnitMonitor ID="QND.Hyperv.2012R2.VHDFragmentation.Monitor" Accessibility="Public" Enabled="false" Target="QND.HyperV.2012R2.VirtualDrive" ParentMonitorID="Health!System.Health.PerformanceState" Remotable="true" Priority="Normal" TypeID="QND.Hyperv2012R2.VHDFragmentation.MT" ConfirmDelivery="false">
<Category>PerformanceHealth</Category>
<AlertSettings AlertMessage="QND.Hyperv.2012R2.VHDFragmentation.Monitor.AlertMessage">
<AlertOnState>Warning</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>MatchMonitorHealth</AlertSeverity>
<AlertParameters>
<AlertParameter1>$Data/Context/Property[@Name="FragPerc"]$</AlertParameter1>
</AlertParameters>
</AlertSettings>
<OperationalStates>
<OperationalState ID="Healthy" MonitorTypeStateID="Healthy" HealthState="Success"/>
<OperationalState ID="OverThreshold1" MonitorTypeStateID="Warning" HealthState="Warning"/>
<OperationalState ID="OverThreshold2" MonitorTypeStateID="Error" HealthState="Error"/>
</OperationalStates>
<Configuration>
<IntervalSeconds>14200</IntervalSeconds>
<SyncTime/>
<TimeoutSeconds>600</TimeoutSeconds>
<TraceLevel>2</TraceLevel>
<VirtualDiskId>$Target/Property[Type='QND.HyperV.VMHardwareComponent']/DeviceId$</VirtualDiskId>
<FragmentationWarningThreshold>30</FragmentationWarningThreshold>
<FragmentationErrorThreshold>50</FragmentationErrorThreshold>
</Configuration>
</UnitMonitor>