TEE14 Scripted Demo 3 – Resource Metering

My third demo at TechEd Europe 2014 focused on Resource Metering, enabling granular reporting of per-VM resource utilisation, primarily for the purposes of show-back reporting or cross-charging/billing. This feature can be used to satisfy one of the traits of a cloud, as defined by NIST: measured usage.

In this demo, I:

  1. Clean up the demo
  2. Enable metering on a VM
  3. Modify the reporting interval from 1 hour to 10 seconds to suit the demo
  4. Use memory in the VM
  5. Copy a file to the VM (I might also run some network consuming process in the VM)
  6. Report on resource usage
  7. Dive deeper into network metering
  8. Clean up the demo

$DemoVM = "Metering"
$DemoFile = "C:\Scripts\TechEd\ResourceMeteringDemoFile.exe"

CLS
Get-VM $DemoVM | Disable-VMResourceMetering
Set-VMHost –ComputerName Demo-Host2 –ResourceMeteringSaveInterval 00:00:10

#Enable metering
Read-Host "`nEnable Resource Metering on the VM"
Write-Host "`nGet-VM $DemoVM | Enable-VMResourceMetering"
Get-VM $DemoVM | Enable-VMResourceMetering
Write-Host "`nResource Metering is enabled on $DemoVM" -foregroundcolor red -backgroundcolor yellow

#Use some resources
Sleep 1
Write-Host "`nUsing RAM in the VM $DemoVM" -foregroundcolor red -backgroundcolor yellow
#Loop to consume RAM in the VM
Invoke-Command -ComputerName $DemoVM -ScriptBlock {1..28|%{$x=1}{[array]$x+=$x}} -ErrorAction SilentlyContinue
#Copy a file to the VM
Write-Host "`nCopying a file to the VM $DemoVM" -foregroundcolor red -backgroundcolor yellow
Remove-Item "\\Metering\C$\ResourceMeteringDemoFile.exe" -ErrorAction SilentlyContinue
Copy-Item -Path $DemoFile -Destination "\\Metering\C$\ResourceMeteringDemoFile.exe"
Remove-Item "\\Metering\C$\ResourceMeteringDemoFile.exe" -ErrorAction SilentlyContinue
Copy-Item -Path $DemoFile -Destination "\\Metering\C$\ResourceMeteringDemoFile.exe"
Remove-Item "\\Metering\C$\ResourceMeteringDemoFile.exe" -ErrorAction SilentlyContinue

#Check usage data
Read-Host "`nCheck usage data"
Write-Host "`nMeasure-VM –VMName $DemoVM"
Measure-VM –VMName $DemoVM | Out-Host

#Check network usage data
Read-Host "`nCheck network usage data"
Write-Host "`n(Measure-VM –VMName $DemoVM).NetworkMeteredTrafficReport"
(Measure-VM –VMName $DemoVM).NetworkMeteredTrafficReport | Out-Host

 

Read-Host "`nEnd the demo"
Get-VM $DemoVM | Disable-VMResourceMetering
Set-VMHost –ComputerName Demo-Host2 –ResourceMeteringSaveInterval 01:00:00

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.