Share via


20 Days of Server Virtualization: Keeping an Eye (Monitoring) your Hyper-V Servers (Part 20 of 20ish)

imageWhen you are working with Windows Server 2012 and Hyper-V you will want to keep an eye on your servers to make sure they are running properly and they are maintained.  In this post I am going to show some of the things that are built-in the server, specifically with PowerShell.  More importantly you are going to learn about what are some of the capabilities with when you introduce System Center 2012 into the mix as well.  This post is focused on monitoring the Hyper-V hosts and the virtual machines on the hosts.  When you think about monitoring of what is running on the virtual machines (guests), remember these are servers just like other servers in your network.  So whatever tools you use to monitor the OS, services or applications that are running on those virtualization guests will still apply.

The Hyper-V role in Windows Server 2012 has built-in a couple of ways to monitor your virtualization environment.  One way is via the gui, which will offer a quick peak at what is happening to a particular virtual server, there is a tab for memory, networking, you may also see a replication tab:

image

PowerShell Hyper-V Monitoring

However, you want to find out more, and that is where PowerShell steps in to the equation to help you.  In Windows Server 2012, and Windows 8 there is rich support for Hyper-V in PowerShell, with a lot of cmdlets at your disposal.  There are even some specifically for monitoring.  You can find the horde of cmdlets for Hyper-V here: Hyper-V Cmdlets in Windows PowerShell Here are some of the basic cmdlets for looking at your virtualization environment (make sure you are in an Administrative PowerShell session for all the following cmdlets to run):

To get a quick look at your host you have two cmdlets to leverage Get-VMHost (shows you the basic settings and properties of your Hyper-V host) and Get-VM (shows you a quick status, state, memory all the virtual machines on your host).  You can see an example below (this example is from my Windows 8 production system):

image

Like most Hyper-V cmdlets there is a ton more detail behind the scenes and you may need this detail to effective monitor your servers, try this cmdlet, and look at all the detail:

Get-VMHost | Format-List *

image

Even more detail on the individual virtual machine take a look at the following cmdlet (which will give you all the details for a virtual machine called dc):

Get-VM -Name dc | Format-List *

image

 

While those two cmdlets offer bare minimum (similar to the GUI) there is another great cmdlet under the covers to help with monitoring your virtual machines.  It is the Measure-VM cmdlet.  This cmdlet reports data on processor usage, memory usage, network traffic, and disk capacity for one or more virtual machines.  However, before you can run the cmdlet you need to enable resource metering for each virtual machine you want to monitor.  To enable resource metering you need to run the Enable-VMResourceMetering cmdlet.  This will allow to start collecting resource utilization data for a virtual machine or resource pool.  Also to note if you want to turn off resource monitoring you can use the Disable-VMResourceMetering cmdlet. You can enable resource metering selectively, like the following example for a virtual machine called dc:

Enable-VMResourceMetering –VMName dc

If you wanted to enable it for all of your virtual machines:

Get-VM | Enable-VMResourceMetering

After you have enabled resource metering you can then measure each vm selectively, like the following example for a virtual machine called dc:

Measure-VM -VMName dc

If you wanted to see this for all your virtual  machines, which gives a great consolidated view of your virtual machines:

Get-VM | Measure-VM

image

As you can see this cmdlet is very useful and just like Get-VM in the previous example, there is a little more data that is not viewed by default (the following example is for a virtual machine called dc):

Measure-VM -VMName dc | Format-List *

 

image

 

If you wanted to collect new data, like maybe after you made changes to hardware (like a new NIC) you reset your resource metering statistics with the Reset-VMResourceMetering cmdlet.  Which will clear existing data so that Hyper-V begins collecting new data.  One last note on monitoring resources with PowerShell is resource pools.  If you have a large number of virtual machines on a Hyper-V host you can create resource pools to help organize your virtual machine resources, like memory, cpu, network, vhd locations…etc.  These pools allow you logical organize your resources as well as monitor them.  In another post I will take a little deeper look into resource pools.  In the meantime if you want to see the existing pools on your server take a look at this cmdlet:

Get-VMResourcePool

image

You will notice the primordial pool, this just master pool and all the other pools you create after here are considered children pools.  You will also notice that you see which components of the pool have resource metering enabled.

System Center and Monitoring

You may want to take your monitoring to the next level, and maybe need a dashboard to monitor your virtual systems.  Maybe you have a large infrastructure with 1000’s of virtual machines, where can you turn.  The answer is System Center and the combination of System Center  Virtual Machine Manager (SCVMM) and System Center Operations Manager (SCOM).  SCVMM allows you to monitor your virtualization hosts, including VMware and Citrix hosts in addition to Hyper-V.  There have been a ton of enhancements to what SCVMM can do to help with your virtualization environment.  You can learn more here: What's New in System Center 2012 - Virtual Machine Manager.  In SCOM you have a management pack that will allow to monitor your workloads, not only for your virtualization hosts, but also the virtual machines running on the hosts.  Also do not forget if you want to monitor your workloads inside of your virtual machines, then SCOM can help there too.  Here are some of the specific scenarios that the Hyper-V monitoring pack can look at:

Monitoring scenario

Description

Associated rules and monitors

Essential monitoring of the host computer that is running Hyper-V.

Monitors critical services to ensure the health of the Hyper-V role. Critical services include networking and storage components.

  • Monitor: Virtual Machine Management Service
  • Rule: Virtual Network Sent Throughput
  • Rule: Virtual Network Received Throughput

Essential monitoring of the virtual machines and their virtual components that are running on the host computer.

Monitors events that result in critical errors.

  • Monitor: Virtual Hard Disk Free Disk Space

Monitoring related to RemoteFX. RemoteFX is integrated with the RDP protocol.

Monitors the configuration of hosts that are using Microsoft RemoteFX technologies.

  • Monitor: Hyper-V 2012 RemoteFX Capable GPU
  • Monitor: Server GPU Configuration
  • Monitor: Hyper-V 2012 RemoteFX Virtual Machine Display Resolution

Monitoring related to virtual machine replication.

Monitors the availability and configuration of hosts that are using Microsoft Hyper-V Replica technology.

  • Monitor: Hyper-V 2012 Replica Network Listener
  • Monitor: Hyper-V 2012 Replication - Reverse Replication Not Initiated
  • Monitor: Hyper-V 2012 Replica Out of Sync
  • Monitor: Hyper-V 2012 Replication Critical Suspended State
  • Monitor: Hyper-V 2012 Replication Resync Required State
  • Monitor: Hyper-V 2012 Replication Not Started
  • Monitor: Hyper-V 2012 Replica Broker Configuration
  • Monitor: Hyper-V 2012 Replica Windows Firewall Rule
  • Monitor: Hyper-V 2012 Replication Count Percent

One last thing is that you can intergrate SCVMM with SCOM.  Integration of the two System Center components together allow you to:

  • Ability to use Operations Manager to view information related to application hosts, load balancers, and user roles while also being able to monitor virtual machines, services, host systems, network adapters, and other elements of the fabric.
  • Receive notifications from Operations Manager if the load on a cloud has exceeded a chosen threshold of fabric capacity. Concurrently review other clouds for available excess capacity that can be reallocated to meet the demand.
  • Generate reports that track the resource usage of each configured service or service user, to aid in capacity planning.

To learn more about the integration take a look here: Configuring Operations Manager Integration with VMM 

We hope you enjoy the series, and if you have any suggestions let us know.  If you missed any part of the series you can find them here:  20 Days of Server Virtualization