5. Monitoring virtual machines
Although the best tools for monitoring virtual machines running
on Hyper-V hosts are those of the System Center family of products,
you can monitor certain aspects of virtual machines using Hyper-V
Manager or Windows PowerShell. For example, Figure 6 shows the bottom
center pane in Hyper-V Manager when a virtual machine named SRV-B is
selected in the upper center Virtual Machines pane. By selecting the
Memory tab on this pane, you can view the current values for assigned
memory and memory demand for virtual machines on which Dynamic Memory
has been enabled.
You can also monitor virtual machines by using resource
metering, a new feature of Hyper-V in Windows Server 2012 that allows
you to use PowerShell to collect and report on historical resource
usage of the following metrics:
-
Average CPU usage by a virtual machine
-
Average physical memory usage by a virtual machine
-
Minimum physical memory usage by a virtual machine
-
Maximum physical memory usage by a virtual machine
-
Maximum amount of disk space allocated to a virtual
machine
-
Total incoming network traffic for a virtual network
adapter
-
Total outgoing network traffic for a virtual network
adapter
In addition, these metrics can be collected in a consistent
fashion even when the virtual machines are moved between hosts using
live migration or when their storage is moved using storage migration.
Organizations that use Hyper-V to build cloud-computing solutions can
also use resource metering for such purposes as tracking how much
resources business units or customers are consuming in order to bill
them for their use of these resources.
For example, you can use the Enable-VMResourceMetering cmdlet to
enable resource metering on a virtual machine as follows:
PS C:\> Enable-VMResourceMetering -VMName SRV-B
Use the Get-VM cmdlet to verify the result:
PS C:\> Get-VM SRV-B | Format-List ResourceMeteringEnabled
ResourceMeteringEnabled : True
You can now use the Measure-VM cmdlet to display real-time
resource usage by the virtual machine:
PS C:\> Measure-VM -Name SRV-B
VMName AvgCPU(MHz) AvgRAM(M) MaxRAM(M) MinRAM(M) TotalDisk(M) NetworkIn... NetworkOut...
------ ----------- --------- --------- --------- ------------ ------------ -------------
SRV-B 176 512 512 512 130469 2 1
For more information on using these cmdlets, use the Get-Help
cmdlet.