PoshCode Archive  Artifact [3ba5f18251]

Artifact 3ba5f18251a8874c703b2be666c6f3955dc1603185a356ff380f72561db6ea10:

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

# 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
		}
	}
}