Resource Metering in Hyper-V

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

About Nicolas 279 Articles
I work as an IT Production Manager, based in Paris (France) with a primary focus on Microsoft technologies. I have 10 years experience in administering Windows Servers. . I am a Microsoft MVP for Cloud & Datacenter Management. I also received the PowerShell Hero 2016 award by PowerShell.0rg. And finally, I am "MCSE: Cloud Platform and Infrastructure", "MCSA: Windows Servers", "Administering & Deploying SCCM", and CheckPoint CCSA certified.