Using resource metering

In hybrid cloud environments, you might have different scenarios for each department, location, business unit, or even client in the case of service providers. One of the benefits a cloud can offer is the ability to measure and bill your clients based on the current consumption of services. Tracking utilization for these resources can be difficult and complex and requires proper applications and systems.

Hyper-V makes that simple with Resource Metering. This allows you to track and measure the current usage for virtual machines and resources pools, helping the IT department to bill clients based on the usage of cloud resources.

These are some examples of metrics that can be collected with Resource Metering:

  • Average, minimum, and maximum VM memory usage
  • Average VM processor usage
  • Total VM disk allocation
  • Network traffic reports (incoming and outgoing)
  • Resource pool measurement for all types of resources within a pool

With Resource Metering, companies can implement advanced billing strategies, creating a cost-effective way to track resource utilization, based on virtual machines and resource pools.

You will see in this recipe how Resource Metering can be enabled for virtual machines and resource pools and how to extract its results.

Getting ready

Although it is not configured by default, Resource Metering can be enabled on every virtual machine in Windows Server 2012 and higher versions using PowerShell. Make sure you have a PowerShell console opened as administrator before you begin.

How to do it…

The following steps will walk you through the Resource Metering PowerShell commandlets.

  1. To enable Resource Metering for all virtual machines in a host, type the following command:
    Enable-VMResourceMetering –VMName *
    
  2. If you want to enable it for a particular virtual machine, type the following command, replacing 2012R2 with the virtual machine name:
    Enable-VMResourceMetering –VMName 2012R2
    
  3. To extract the measurement details for a virtual machine, use the Measure-VM command, as shown in the following screenshot:
    How to do it…

    Resource Metering – Extracting Measurement Data with PowerShell

  4. To see more Resource Metering details for a virtual machine, use the command shown in the following screenshot:
    How to do it…

    Resource Metering – Extracting Detailed Measurement Data with PowerShell

  5. To verify which virtual machine has Resource Metering enabled, type the following command:
    Get-VM * | Format-List Name,ResourceMeteringEnabled
    
  6. For more details about inbound and outbound network utilization traffic, type the command shown in the following screenshot:
    How to do it…

    Resource Metering – Extracting Network Metered Traffic with PowerShell

  7. To enable Resource Metering for a resource pool, type the following command to change the resource pool name to Primordial and the resource pool type to Memory:
    Enable-VMResourceMetering –ResourcePoolName Primordial–ResourcePoolType Memory
    
  8. To measure the resource pool data, use the command Measure-VMResourcePool, as shown in the following screenshot:
    How to do it…

    Resource Metering – Measuring a Memory Resource Pool with PowerShell

  9. Use the commandlet Reset-VMResourceMetering to reset the resource utilization data collected by Resource Metering. The following command shows how to reset the data for a virtual machine called 2012R2:
    Reset-VMResourceMetering –VMName 2012R2
    
  10. To disable Resource Metering, use the Disable-VMResourceMetering command. The following command shows how to disable Resource Metering for a virtual machine called 2012R2:
    Disable-VMResourceMetering –VMName 2012R2
    

How it works…

Although there is no graphical interface to configure it, Resource Metering is quite easy to manage using PowerShell. The commands let you enable, measure, reset, and disable the counters for virtual machines and resource pools. It is also easy to create reports with measurement outputs using the output values to create advanced methods to charge your clients based on utilization of resources.

The four resources that can be monitored on a VM are processor (in megahertz) and memory, network, and disk (in megabytes).

The results can be collected and reset at any time, helping you to measure the virtual machine or resource pool usage based on your company's needs.

Now, with resource utilization details, you can create your billing system or simply track the resource information from your virtual machines and resource pools.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.61.142