I am trying to measure performance of our datastores and luns of our esx hosts. I am using the function below for measuring diskreadlatency and diskwritelatency :
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
}
}
}
Then use:
Get-VMHostLunLatency -vmhost (get-vmhost "esxhost" ) | Format-Table -Autosize *
When I run the above it lists all the LUNS for the esx hosts, but the values for readlatency and writelatency are all mainly 0, there are few values such as 4 or 5. Does this mean there is no latency for my luns at the moment, or is there any issue with measuring latency. Just want to make sure.
Thanks
Can't you cross-check with the vSphere client or with esxtop ?
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes I will check on vpshere client
Had a closer look at your script and made a few changes.
function Get-VMHostLunLatency {
param($VMHost)
$luns = $VMHost | Get-ScsiLun
$statsAll = Get-Stat -Entity $VMHost -stat disk.totalreadlatency.average,disk.totalwritelatency.average -maxsamples 1 -realtime
foreach ($lun in $luns) {
$statsLun = $statsAll | where { $_.Instance -eq $Lun.CanonicalName }
if ($statsLun.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 ($statsLun | where{$_.MetricId -eq "disk.totalreadlatency.average"}).Value
$obj | Add-Member -MemberType NoteProperty -Name WriteLatency -Value ($statsLun | where{$_.MetricId -eq "disk.totalwritelatency.average"}).Value
$obj
}
}
}
Get-VMHostLunLatency -vmhost (get-vmhost <esx-hostname> ) | Format-Table -Autosize
You only have to call Get-Stat once which will make the script faster.
For each Lun it extracts the statistics for that specific Lun in the $statsLun variable.
You can be sure that readlatency will always be the first value in the array. This way you're always sure.
Btw, I also see mos of the time zero values.
Which is good, there is nearly no latency on the Luns.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
