Resource Metering in Hyper-V allows you to monitor the resources a virtual machine is consuming on the host and is primarily for use in chargebacks.
All of the Hyper-V Exam Guide and Notes are available.
The following PowerShell commands are used in the notes below:
- Enable-VMResourceMetering – Starts collecting resource utilization data for a virtual machine or resource pool;
- Set-VMHost – Configures a Hyper-V Host;
- Measure-VM – Reports resource utilization data for one or more virtual machines;
- Not enabled by default;
- Can be configured with PowerShell or Hyper-V WMI API;
- Enabled using the Enable-VMResourceMetering PowerShell Hyper-V Cmdlet:
# Enable resource metering on virtual machine 'TESTVM-1'
Enable-VMResourceMetering -ComputerName TESTVM-1
- If no network adapter ACL’s are configured when metering is enabled then they are automatically configured to measure total network traffic;
- Moving a virtual machine between hosts – through migration – does not affect the collected data;
- Having resource metering configured has no noticeable performance hit;
- Data collection settings are applied per host to all virtual machines running on it;
- By default the data is collected once per hour;
- You can change the data collection frequency for the host using the Set-VMHost PowerShell Hyper-V Cmdlet:
# Set the collection frequency to 1 hour, 15 minutes and 30 seconds
# for the Hyper-V host 'HVHOST-1'
Set-VMHost -ComputerName HVHOST-1 -ResourceMeteringSaveInterval 1:15:30
- To view the resource usage of a virtual machine use the Measure-VM PowerShell Hyper-V Cmdlet:
# Shows the resource usage for virtual machine 'TESTVM-1'
Measure-VM -ComputerName TESTVM-1
What can be measured?
- Average CPU (in MHz) over a period of time;
- Average physical memory usage in MB (this includes the time the VM is off);
- Minimum memory usage in MB while the VM was running (this is the lowest memory value that was used);
- Maximum memory usage in MB while the VM was running (this is the highest memory value that was used);
- Total incoming traffic for a network adapter in MB;
- Total outgoing traffic for a network adapter in MB;
- Network metering ACL’s are used to measure traffic between IP ranges so you could exclude all internal IP ranges and only focus on internet traffic for billing;