7 Replies Latest reply on Sep 22, 2014 6:59 AM by weaverj

    Script for setting IOPS=1 with Reporting

    weaverj Novice

      I've cobbled together this script from the ones I've found online.  The script sets everything I want correctly in our 5.0u3 env (I have a separate one for our 5.1 Lab) for our FA EMC-VMAX storage.  I would like a better report for the output though.  The Export-CSV doesn't Append yet so I'm looking for options on putting the output into a table or compiling them into a csv for review after it's been run.

       

      ## Script Variables

      $VC = Read-Host 'Please Enter VirtualCenter Name'

      $mycluster = Read-Host 'Please enter Cluster Name'

      $DiskID = "naa.600*"

      $psp = "VMW_PSP_RR"

       

      ### Connect to VirtualCenter

      Connect-VIServer $VC -Protocol https -User "$admin" | Out-Null

       

      ### Loop Through Cluster or DC to get ESXCLI instances and run commands

      $esxHosts = Get-VMHost -Location $mycluster | Sort Name

      foreach($esx in $esxHosts)

      {

        Write-Host $esx #Display host Name

        $csvfile = "H:\" + $esx + "_set_iops.csv" #Create file for Host Export

       

        ### $esxcli.system.hostname.get() ###

        $esxcli = Get-EsxCli -VMHost $esx

           $esxcli.storage.nmp.device.list() | where {$_.Device -match  $DiskID}| %  {

        $esxcli.storage.nmp.psp.roundrobin.deviceconfig.set($null,$_.Device,1,"iops",$null)|Out-Null

       

        ###Display IOPS

        $esxcli.storage.nmp.psp.roundrobin.deviceconfig.get($_.device) | Format-Table -AutoSize

        #$esxcli.storage.nmp.psp.roundrobin.deviceconfig.get($_.device) | Export-csv $csvfile -NoTypeInformation #Commented out-Needs work for output as a table.

                }

       

      ###Change the default PSP

      $esxcli.storage.nmp.satp.set($null,”VMW_PSP_RR”,”VMW_SATP_SYMM”)

      }

       

      #Disconnect from VirtualCenter

      Disconnect-VIServer $VC -Confirm:$false | Out-Null

       

      Current output overwrites the CSV for each Datastore on each host, so I only get the last Datastore ran.  I understand why, just not sure the best way to modify it to move forward.

      Current output:

      ByteLimitDeviceIOOperationLimitLimitTypeUseActiveUnoptimizedPaths
      10485760naa.60000xxxxxxxxxxxxxxxxxxxxxx1IopsFALSE
        • 1. Re: Script for setting IOPS=1 with Reporting
          LucD Guru
          User ModeratorsCommunity WarriorsvExpert

          You have the Export-Csv inside the inner loop, but you knew that of course.

          A solution could be to capture the output in an array, and then at the end of the script export that array to a CSV file.

          Something like this

           

          ## Script Variables

          $VC = Read-Host 'Please Enter VirtualCenter Name'

          $mycluster = Read-Host 'Please enter Cluster Name'

          $DiskID = "naa.600*"

          $psp = "VMW_PSP_RR"

           

          ### Connect to VirtualCenter

          Connect-VIServer $VC -Protocol https -User "$admin" | Out-Null

           

          $report = @()

           

          ### Loop Through Cluster or DC to get ESXCLI instances and run commands

          $esxHosts = Get-VMHost -Location $mycluster | Sort Name

          foreach($esx in $esxHosts)

          {

            Write-Host $esx #Display host Name

            $csvfile = "H:\" + $esx + "_set_iops.csv" #Create file for Host Export

           

            ### $esxcli.system.hostname.get() ###

            $esxcli = Get-EsxCli -VMHost $esx

            $esxcli.storage.nmp.device.list() | where {$_.Device -match  $DiskID}| %  {

              $esxcli.storage.nmp.psp.roundrobin.deviceconfig.set($null,$_.Device,1,"iops",$null)|Out-Null

           

              ###Display IOPS

              $report += $esxcli.storage.nmp.psp.roundrobin.deviceconfig.get($_.device)

            }

            ###Change the default PSP

            $esxcli.storage.nmp.satp.set($null,”VMW_PSP_RR”,”VMW_SATP_SYMM”)

          }

           

          $report | Export-csv $csvfile -NoTypeInformation

           

          #Disconnect from VirtualCenter

           

          Disconnect-VIServer $VC -Confirm:$false | Out-Null

          • 2. Re: Script for setting IOPS=1 with Reporting
            weaverj Novice

            Great! 

             

            Next on my list is to add host name to the first field of each line of the array (or a new line with the name when it changes hosts)

            1 person found this helpful
            • 3. Re: Script for setting IOPS=1 with Reporting
              LucD Guru
              Community WarriorsvExpertUser Moderators

              Try like this

               

              ## Script Variables

              $VC = Read-Host 'Please Enter VirtualCenter Name'

              $mycluster = Read-Host 'Please enter Cluster Name'

              $DiskID = "naa.600*"

              $psp = "VMW_PSP_RR"

               

              ### Connect to VirtualCenter

              Connect-VIServer $VC -Protocol https -User "$admin" | Out-Null

               

              $report = @()

               

              ### Loop Through Cluster or DC to get ESXCLI instances and run commands

              $esxHosts = Get-VMHost -Location $mycluster | Sort Name

              foreach($esx in $esxHosts)

              {

                Write-Host $esx #Display host Name

                $csvfile = "H:\" + $esx + "_set_iops.csv" #Create file for Host Export

               

                ### $esxcli.system.hostname.get() ###

                $esxcli = Get-EsxCli -VMHost $esx

                $esxcli.storage.nmp.device.list() | where {$_.Device -match  $DiskID}| %  {

                  $esxcli.storage.nmp.psp.roundrobin.deviceconfig.set($null,$_.Device,1,"iops",$null)|Out-Null

               

                  ###Display IOPS

                  $report += $esxcli.storage.nmp.psp.roundrobin.deviceconfig.get($_.device) |

                      Add-Member -Name Host -Value $esx.Name -MemberType NoteProperty -PassThru

                }

                ###Change the default PSP

                $esxcli.storage.nmp.satp.set($null,”VMW_PSP_RR”,”VMW_SATP_SYMM”)

              }

               

              $report | Select Host,Device,ByteLimit,IOOperationLimit,LimitType,UseActiveUnoptimizedPaths |

              Export-csv $csvfile -NoTypeInformation

               

              #Disconnect from VirtualCenter

               

              Disconnect-VIServer $VC -Confirm:$false | Out-Null

               

              • 4. Re: Script for setting IOPS=1 with Reporting
                weaverj Novice

                Works perfectly!  I changed the variable for the file name to the Cluster instead of the Host name.

                Here is the one for 5.0

                ## Script Variables
                $VC = Read-Host 'Please Enter VirtualCenter Name'
                $mycluster = Read-Host 'Please enter Cluster Name'
                $DiskID = "naa.600009*"
                $psp = "VMW_PSP_RR"
                
                ### Connect to VirtualCenter
                Connect-VIServer $VC -Protocol https -User "$admin" | Out-Null
                
                $report = @()
                
                ### Loop Through Cluster or DC to get ESXCLI instances and run commands
                $esxHosts = Get-VMHost -Location $mycluster | Sort Name
                foreach($esx in $esxHosts)
                {
                  Write-Host $esx #Display host Name
                  $csvfile = "H:\" + $mycluster + "_set_iops.csv" #Create file for Host Export
                
                  ### $esxcli.system.hostname.get() ###
                  $esxcli = Get-EsxCli -VMHost $esx
                  $esxcli.storage.nmp.device.list() | where {$_.Device -match  $DiskID}| %  {
                    $esxcli.storage.nmp.psp.roundrobin.deviceconfig.set($null,$_.Device,1,"iops",$null)|Out-Null
                
                    ###Display IOPS
                    $report += $esxcli.storage.nmp.psp.roundrobin.deviceconfig.get($_.device) |
                        Add-Member -Name Host -Value $esx.Name -MemberType NoteProperty -PassThru
                  }
                  ###Change the default PSP
                  $esxcli.storage.nmp.satp.set($null,”VMW_PSP_RR”,”VMW_SATP_SYMM”)
                }
                
                $report | Select Host,Device,ByteLimit,IOOperationLimit,LimitType,UseActiveUnoptimizedPaths |
                Export-csv $csvfile -NoTypeInformation
                
                #Disconnect from VirtualCenter
                
                Disconnect-VIServer $VC -Confirm:$false | Out-Null
                
                

                 

                and for 5.1

                ## Script Variables
                $VC = Read-Host 'Please Enter VirtualCenter Name'
                $mycluster = Read-Host 'Please enter Cluster Name'
                $DiskID = "naa.600009*"
                $psp = "VMW_PSP_RR"
                
                
                ### Connect to VirtualCenter
                Connect-VIServer $VC -Protocol https -User "$admin" | Out-Null
                
                
                $report = @()
                
                
                ### Loop Through Cluster or DC to get ESXCLI instances and run commands
                $esxHosts = Get-VMHost -Location $mycluster | Sort Name
                $csvfile = "H:\" + $mycluster + "_set_iops.csv" #Create file for Host Export
                
                
                foreach($esx in $esxHosts)
                {
                  Write-Host $esx #Display host Name
                  $report += $esx.name
                  ### $esxcli.system.hostname.get() ###
                  $esxcli = Get-EsxCli -VMHost $esx
                    $esxcli.storage.nmp.device.list() | where {$_.Device -match  $DiskID}| %  {
                  $esxcli.storage.nmp.psp.roundrobin.deviceconfig.set(0,$null,$_.Device,1,"iops",$null)|Out-Null
                
                    ###Display IOPS
                    $report += $esxcli.storage.nmp.psp.roundrobin.deviceconfig.get($_.device) |
                        Add-Member -Name Host -Value $esx.Name -MemberType NoteProperty -PassThru
                  }
                  ###Change the default PSP
                  $esxcli.storage.nmp.satp.set($null,”VMW_PSP_RR”,”VMW_SATP_SYMM”)
                }
                
                $report | Select Host,Device,ByteLimit,IOOperationLimit,LimitType,UseActiveUnoptimizedPaths |
                Export-csv $csvfile -NoTypeInformation
                
                #Disconnect from VirtualCenter
                
                Disconnect-VIServer $VC -Confirm:$false | Out-Null
                
                
                • 5. Re: Script for setting IOPS=1 with Reporting
                  weaverj Novice

                  Is there a way to set the IOPS=1 as the default with the policy or do we need to keep setting that as we add new storage?

                  • 7. Re: Script for setting IOPS=1 with Reporting
                    weaverj Novice

                    I was hoping to set it in the script above (line 26) to do everything at once.  I believe I can change line 25 to:

                    $esxcli.storage.nmp.satp.rule.add($null,$null,"EMC Custom SYMM Rule",$null,$null,$null,"SYMMETRIX",$null,"VMW_PSP_RR","iops=1","VMW_SATP_SYMM",$null,$null,"EMC")