PoshCode Archive  Artifact [2e83c3f704]

Artifact 2e83c3f70485590b148e092eeb2b8e7c99734aa6be28e1c9404114bd8642eff8:

  • File ESX-Lun-Latencies.ps1 — part of check-in [ac0abd1824] at 2018-06-10 13:11:45 on branch trunk — Given an ESX host, produce a report of read and write latencies for all attached LUNs. (user: Carter Shanklin size: 1281)

# encoding: ascii
# api: powershell
# title: ESX Lun Latencies
# description: Given an ESX host, produce a report of read and write latencies for all attached LUNs.
# version: 0.1
# type: function
# author: Carter Shanklin
# license: CC0
# function: Get-VMHostLunLatency
# x-poshcode-id: 2515
# x-archived: 2017-03-25T18:32:20
# x-published: 2011-02-22T05:53:00
#
#
function Get-VMHostLunLatency {
  param([parameter(Mandatory=$true, ValueFromPipeline=$true)] $VMHost)

  process {
    $luns = Get-ScsiLun -VmHost $VMHost
    $DiskStats = $VMHost |
      Get-Stat -stat disk.totalreadlatency.average,disk.totalwritelatency.average -maxsamples 1 -realtime 
    foreach ($lun in $luns) {
      $Stats = $DiskStats  |
        Where { $_.Instance -eq $Lun.CanonicalName }
      if ($stats.length -ne $null) {
        $obj = New-Object PSObject
        $obj | Add-Member -MemberType NoteProperty -Name VMHost -Value $VMHost.Name
        $obj | Add-Member -MemberType NoteProperty -Name Lun -Value $lun.CanonicalName
        $obj | Add-Member -MemberType NoteProperty -Name ReadLatency -Value ($stats[0].Value)
        $obj | Add-Member -MemberType NoteProperty -Name WriteLatency -Value ($stats[1].Value)
        Write-Output $obj
      }
    }
  }
}