Besides creating and managing VMs, system administrators are also responsible for
monitoring the performance and health of VMs, just as with physical
machines.
Hyper-V delivers not only improvements in monitoring virtual
environments, but also new features that are worth getting familiar
with.
Resource metering is a new feature that gives you information on the CPU,
memory, storage, and network resources that a VM is consuming. Consider
it a Performance Monitor for virtualization.
Besides giving insight into how well or poorly a virtual
infrastructure is running, resource metering provides another important
purpose: customer billing. As companies increasingly provide services to
customers via cloud deployments, they need a way to bill those customers
for service usage. With resource metering, a business can create an
in-house strategy for billing customers for usage based on metrics
provided. Previously, most companies had to rely solely on third-party
solutions to bill for cloud services.
Resource metering provides:
-
Average CPU usage, measured in megahertz over a period of
time
-
Average physical memory usage, measured in megabytes
-
Minimum memory usage (lowest amount of physical memory)
-
Maximum memory usage (highest amount of physical
memory)
-
Maximum amount of disk space allocated to a virtual
machine
-
Total incoming network traffic, measured in megabytes, for a
virtual network adapter
-
Total outgoing network traffic, measured in megabytes, for a
virtual network adapter
To execute resource metering, run the following cmdlet in
PowerShell (see Figure 1):
Get-VM -ComputerName <name of Hyper-V host machine>|Enable -VMResourceMetering
The default time to collect data for performance metrics is an
hour. You can change this interval. The following cmdlet sets the data
collection time to under a minute:
Set-vmhost –computername <Hyper-V host name>
-ResourceMeteringSaveInterval 00:01:00
To display all the data collected for VMs, run this command (see
Figure 2):
Get-VM –ComputerName <name of Hyper-V host>|Meaure-VM
You can also just get metrics on a specific VM. In the following example, we
specify a VM named Server2012VM on a Hyper-V host, DC10:
Get-VM –ComputerName DC10 –Name "Server2012VM"|Measure-VM
Since cloud computing is at the forefront of Server 2012 and
Hyper-V R3 marketing, there’s a good chance that organizations will take
a close look at the two solutions if they do have billable cloud
services. Resource metering is a good way to see usage within a
virtualized environment, but Microsoft’s options for exporting the data
you get from running these PowerShell commands is rather weak. I would
prefer a GUI component that provides rich reporting and data
visualization capabilities. Currently, the best way I can determine to
extract data when you run resource metering cmdlets is to use the output
command to create a CSV (comma-separated value) file.