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:
- Clean up the demo
- Enable metering on a VM
- Modify the reporting interval from 1 hour to 10 seconds to suit the demo
- Use memory in the VM
- Copy a file to the VM (I might also run some network consuming process in the VM)
- Report on resource usage
- Dive deeper into network metering
- 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