DISK IOPS for VM's on VMware
Hello Folks,
A Couple weeks ago, I have worked on the enhancement of the VMware environment and a task to limit the iops for better performance. The following PowerCLI script will collect the Microsoft Server class VM's metrics from the a datacenter and limits IO to 500.
# script by Shankar Jadapa 28/01/2015
###############################
######## LOAD PLUGINS #########
###############################
if (-not (Get-PSSnapin VMware.VimAutomation.Core -ErrorAction SilentlyContinue)) {
Add-PSSnapin VMware.VimAutomation.Core
}
#Connecting to the desired vCenter
Connect-viserver -server vCenter01.local -user shankar -password jadapa
# Collecting the information of all the required Machines
$vms = Get-Datacenter "Dynamic" |Get-VM | Where {$_.Guest.OSFullName -match "Microsoft Windows Server*"}
Write-Host " Gathering informaiton is completed"
Write-Host "Going to execute the IOPs change on the machines"
Foreach ($vm in $vms)
{
$DiskLimitIOPerSecond = 500
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$vm.ExtensionData.Config.Hardware.Device |
where {$_ -is [VMware.Vim.VirtualDisk]} | %{
$dev = New-Object VMware.Vim.VirtualDeviceConfigSpec
$dev.Operation = "edit"
$dev.Device = $_
$dev.Device.StorageIOAllocation.Limit = $DiskLimitIOPerSecond
$spec.DeviceChange += $dev
}
$vm.ExtensionData.ReconfigVM_Task($spec)
Write-Host "IOPS changed on $vm"
sleep -Seconds 5
}
#Disconnecting the connected vCenters.
Disconnect-VIServer * -Confirm:$false -Force
No comments:
Post a Comment