Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 214415

Setting IO Limits

$
0
0

Hi all

 

I'm putting together a script to automatically set disk IO limits based on what datastore they are in and how big the disk is.  I have a CSV file listing each datastore and how many IOPs per GB to assign to disks in that datastore and I've written the following, which seems to work.  If I schedule it to run every hour it'll set the IO limit on each VMDK file accordingly.

 

However, because it sets the DiskIOLimitPerSecond value on every VMDK every time it runs, and each config change takes around a second, the script is quite slow when there are a few hundred VMs to chew through.  What I'd like to do, is put a check in to see if DiskLimitIOPerSecond is already set to the correct value ($disk.CapacityGB * $_.IOLimitPerGB) then only make the config change is it's not.  I'm not sure how to go about it though.

 

This is my script so far

 

 

 

 

 

$filepath = "c:\software\datastores.csv"

Import-CSV $filepath | Foreach-Object {

 

  $colVMs = Get-Datastore $_.Datastore | Get-VM

  foreach ($VM in $colVMs) {

     $colDisks = Get-HardDisk $VM

     foreach ($disk in $colDisks) {

        $VM | Get-VMResourceConfiguration | Set-VMResourceConfiguration -Disk $disk -DiskLimitIOPerSecond ($disk.CapacityGB * $_.IOLimitPerGB)
     }
  }
}

 

I've tried putting a Where-Object into the line that sets the DiskLimitIOPerSecond like this:

$VM | Get-VMResourceConfiguration | Where-Object {$disk.DiskLimitIOPerSecond -ne ($disk.CapacityGB * $_.IOLimitPerGB)} | Set-VMResourceConfiguration -Disk $disk -DiskLimitIOPerSecond ($disk.CapacityGB * $_.IOLimitPerGB)

 

I've tried using $VM | Get-VMResourceConfiguration -Disk $disk to see if that'll let me query the current value but it tells me that "a parameter cannot be found that matches parameter name 'Disk'

 

I'm a bit lost to be honest.  I'm not much of a powershell scripter - my experience is mainly VB Script (which might show in how I wrote the script actually!)

 

Dave


Viewing all articles
Browse latest Browse all 214415

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>