How to Use Hyper-V Resource Metering

“Resource Metering” is a brand new feature in Hyper-V 3.0, included with Windows Server 2012. It allows Hyper-V administrators to track CPU usage, RAM and the network utilization of VMs working on a host. Since more companies are providing users with an Infrastructure as a Service (IaaS) and Platform as a Service (PaaS) plans, Hyper-V’s resource metering may be helpful for analyzing VM impact on a system and for calculating chargebacks to VM’s end-users accordingly.

Today, I’m going to talk about practical examples of resource metering and how it can provide you with better visibility into Hyper-V resources.

Note 1: Keep in mind that enabled resource metering might make some insignificant impact on disk and CPU performance as the data is saved to the configuration file.

Note 2: Don’t mix it up with a “metered connection” in Windows 8/8.1.

Unlike the majority of Hyper-V features, there is no GUI to play with. This feature will primarily use PowerShell cmdlets instead. Not a problem, right? Open a PowerShell console in elevated mode and use the Enable-VMResourceMetering Windows PowerShell cmdlet to get started (as resource metering is not enabled by default):

Get-VM -Name vmname | Enable-VMResourceMetering

where vmname is a name of a desired VM.

Figure 1. Enabling resource metering

There will be no indication that it’s enabled, which I, personally, find rather confusing. So double check everything is alright. Next command lists all VMs with enabled resource metering:

Get-VM | Format-Table Name, State, ResourceMeteringEnabled

Figure 2. Checking whether resource metering is enabled for VMs

As you can see, win10 VM is shown as one with enabled metering.

In general, resource metering allows you to record the following information:

Let’s run the Measure-VM cmdlet now and check the measured values in my lab. Following command lists all VMs on this host and displays resource metering, when enabled:

Get-VM | Measure-VM

Figure 3. List all VMs on a host and show resource metering, when enabled

Win10 VM has recently got new updates, consumed some traffic and I can clearly see that from the listed output. To show only this VM data execute:

Get-VM -Name win10 | Measure-VM

Figure 4. Show resource metering for a specified VM

To check only preconfigured VM metrics:

Get-VM -ComputerName localhost -Name “win10” | Measure-VM | Select-Object VMname, AvgCPU, AvgRAM

Figure 5. Show selected metrics for a specified VM

To get an extended list of VM metrics:

Get-VM -ComputerName localhost -Name “win10” | Measure-VM | Select-Object *

Figure 6. Show extended list of VM metrics

There is a default interval of an hour when the Hyper-V host saves the metering information. You can’t decrease this interval, but can increase it by using the following cmdlet

Set-VMHost -ResourceMeteringSaveInterval hh:mm:ss

where “hh:mm:ss” is the desired time frame

In the following example, I tried to set up 30-minute, 1-hour 1-minute 1-second and 2-hour intervals. See what happened:

Figure 7. Changing resource metering save interval

Once you enable resource metering, the Hyper-V host is gathering data unless you reset it. That can be done by running:

Get-VM -Name vmname | Reset-VMResourceMetering

After that, all the previously collected data is purged.

As soon as you played enough with resource metering, don’t forget to disable it:

Get-VM | Disable-VMResourceMetering

Although you can extract data using the Measure-VM cmdlet, you need to use another solution to output this data into a visual form like a graph or use any 3rd party tool like Veeam Task Manager for Hyper-V.

Veeam Task Manager for Hyper-V

If you feel, what was described above wasn’t that easy for you or you’re not a scripting person and like to see things more clear, here’s another tool worth checking out: Veeam Task Manager for Hyper-V. It gathers a bit less information to present to the administrator, but it has a small size (1Mb) and doesn’t require installation (portable), so it can work right from an attached USB drive.

This program displays real-time CPU and RAM utilization of all VMs working on a Hyper-V host and can gather information from a remote host as well. With this, it is much easier for you to manage VM consumption dynamics and oversee the trend.

Figure 8. Veeam Task Manager for Hyper-V

To conclude, resource metering in Hyper-V and Veeam Task Manager for Hyper-V both allow you to bring some value to your business, calculate charges for resource utilization and manage virtual resources in a better way. No VM activity will come through them undiscovered.

Got advanced scripts for resource metering? Share with the community in the comments, so we all can benefit.

To find out how more about how Veeam Backup & Replication works as a Hyper-V backup and disaster recovery solution, download a trial!

Related Content

Exit mobile version