# 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: 1425
# x-archived: 2016-10-03T02:25:01
# x-published: 2010-10-28T11:45:00
#
#
function Get-VMHostLunLatency {
param($VMHost)
$luns = $VMHost | Get-ScsiLun
foreach ($lun in $luns) {
$stats = $VMHost |
Get-Stat -stat disk.totalreadlatency.average,disk.totalwritelatency.average -maxsamples 1 -realtime |
Where { $_.Instance -eq $Lun.CanonicalName }
if ($stats.length -ne $null) {
$obj = New-Object PSObject
$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
}
}
}