Thursday, 9 October 2014

Control-NcSnapMirrorGlobalThrottle.ps1

** Update 2016/04/01 ** Check out this instead:
http://mikethetechgeek.blogspot.com/2016/03/i-ran-into-issue-with-snapprotect.html

And before I start my PowerShell holiday…

Here’s a very quick script I knocked up to show how PowerShell could be used to facilitate a global SnapMirror throttle for Clustered ONTAP. Unlike Data ONTAP Operating in 7-Mode, Clustered ONTAP only allows per relationship SnapMirror throttles to be defined.

This script would work to demonstrate controlling throughput in a 1:1 Cluster Relationship. It would be run against the destination (when the SnapMirrors are defined). It’s set below to share out the available replication bandwidth between the transferring SnapMirrors, every 15 seconds (could easily reduce this, but I don’t think a new SnapMirror transfer would ramp up to full speed straight away!)

Import-Module DataONTAP

$cluster    = Read-Host "Cluster "
$username   = Read-Host "Username"
$password   = Read-Host "Password" -AsSecureString
$credential = New-Object System.Management.Automation.PsCredential($username,$password)
$connect    = Connect-NcController $cluster -Credential $credential
""
[Int]$globalThrottle    = Read-Host "Global throttle (KB/sec)"
""
$attributes             = Get-NcSnapMirror -Template
$query                  = Get-NcSnapMirror -Template
$query.RelationshipType = "data_protection"
$query.Status           = "transferring"

while ($true){

  $runningSnapMirrors = Get-NcSnapMirror -Attributes $attributes -Query $Query
  $count              = $runningSnapMirrors.count
 
  If ($count -gt 0){
    $averageThrottle = [Int64]($globalThrottle*1024 / $count)
    [Void]($runningSnapMirrors | Set-NcSnapMirror -MaxTransferRate $averageThrottle)
    "Set $count SnapMirrors with a throttle of $averageThrottle bytes"
  }
 
  Sleep 15
 
}

And now for that PowerShell vacation…

5 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Is there a way to set the new throttle value for a transferring Snapmirror? It seems like the new throttle value would be used on the next transfer if it was updated during transferring state.

    ReplyDelete
    Replies
    1. Lewis, I don't know if you resolved this issue but I thought I would put it out there. I ran into the same issue with SnapProtect resetting my throttle settings for CDOT SnapMirrors. NetApp Professional Services actually gave me the above script, which of course did not work for the same reason you mentioned. I have posted the following script I came up with.

      http://mikethetechgeek.blogspot.com/2016/03/i-ran-into-issue-with-snapprotect.html

      Delete
    2. Hi Mike, thank you very much for sharing your script. It wasn't until later I learnt the need to abort the mirrors for the throttle to apply. The script in this post was essentially just a curiosity piece, apologies it didn't actually work. Best regards, vCosonok.

      Delete
  3. Hi Lewis, I'm sure I tested this but it was more of a curiosity that something I actually needed. I don't have time at present to re-test. If you find out the answer for sure, please let me know - maybe this wouldn't work after all! Cheers, vCosonok

    ReplyDelete