07Hyper-V includes resource metering which is a feature that will track VM resources such as:
- CPU usage,
- RAM,
- Network utilization,
- Disks.
To configure this feature, you can’t use the Hyper-V console , so you must use Windows PowerShell!
Resource Metering cmdlets:
- Enable-VMResourceMetering
- Disable-VMResourceMetering
- Reset-VMResourceMetering
- Measure-VM
- Measure-VMResourcePool
First, you must check if Resource Metering is enable or not:
PS > Get-VM -Name Test | Measure-VM measure-vm : Resource metering is not enabled for this virtual machine. Use the Enable-VMResourceMetering cmdlet to enable data collection for this virtual machine. At line:1 char:21 + Get-VM -Name Test | measure-vm + ~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (:) [Measure-VM], VirtualizationException + FullyQualifiedErrorId : ObjectNotFound,Microsoft.HyperV.PowerShell.Commands.MeasureVM
Another option:
PS > Get-VM | Format-Table Name, State, ResourceMeteringEnabled Name State ResourceMeteringEnabled ---- ----- ----------------------- test Running False VMTest Running False
So, use the following command to enable this feature:
PS > Get-VM -Name Test | Enable-VMResourceMetering
OK, now run the previous command again:
PS > Get-VM -Name Test | Measure-VM VMName AvgCPU(MHz) AvgRAM(M) MaxRAM(M) MinRAM(M) TotalDisk(M) NetworkInbound(M) NetworkOutbound(M) ------ ----------- --------- --------- --------- ------------ ----------------- ------------------ test 0 0 0 0 0 0 0
As you can see, Hyper-V collects and reports VM resource data.
PS > Get-VM -Name Test | Measure-VM VMName AvgCPU(MHz) AvgRAM(M) MaxRAM(M) MinRAM(M) TotalDisk(M) NetworkInbound(M) NetworkOutbound(M) ------ ----------- --------- --------- --------- ------------ ----------------- ------------------ Test 11 509 1024 1024 30732 0 0
To disable Resource Metering on single VM:
PS > Get-VM -Name Test | Disable-VMResourceMetering
Windows server 2012 R2 does not include a graphical reporting tool.
Thanks for reading! You can follow me on Twitter @PrigentNico