Hi Guys,
I am hoping someone can help, I am trying to retrieve the datastore.maxTotalLatency.latest for all my datastores from each host to write this to a BI report.
But I cant seem find the correct scripts.
Thanks in advance
Rolf
I don't think you want the datastore.maxTotalLatency.latest metric.
This one returns the "Highest latency value across all datastores used by the host".
I suspect you want to see the latency per datastore.
Then you would have to add the read and write latency togther.
Something like this
$stat = 'datastore.totalReadLatency.average','datastore.totalWriteLatency.average'
$esx = Get-VMHost -Name $esxName
$dsTab = @{}
(Get-EsxCli -VMHost $esx).storage.vmfs.extent.list() | %{
$dsTab.Add($_.VMFSUUID,$_.VolumeName)
}
Get-Stat -Entity $esx -Stat $stat -Realtime -MaxSamples 1 |
Group-Object -Property Instance | %{
New-Object PSObject -Property @{
VMHost = $esx.Name
Datastore = $dsTab[$_.Name]
ReadLatency = $_.Group | where{$_.MetricId -eq 'datastore.totalReadLatency.average'} | select -ExpandProperty Value
WriteLatency = $_.Group | where{$_.MetricId -eq 'datastore.totalWriteLatency.average'} | select -ExpandProperty Value
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I don't think you want the datastore.maxTotalLatency.latest metric.
This one returns the "Highest latency value across all datastores used by the host".
I suspect you want to see the latency per datastore.
Then you would have to add the read and write latency togther.
Something like this
$stat = 'datastore.totalReadLatency.average','datastore.totalWriteLatency.average'
$esx = Get-VMHost -Name $esxName
$dsTab = @{}
(Get-EsxCli -VMHost $esx).storage.vmfs.extent.list() | %{
$dsTab.Add($_.VMFSUUID,$_.VolumeName)
}
Get-Stat -Entity $esx -Stat $stat -Realtime -MaxSamples 1 |
Group-Object -Property Instance | %{
New-Object PSObject -Property @{
VMHost = $esx.Name
Datastore = $dsTab[$_.Name]
ReadLatency = $_.Group | where{$_.MetricId -eq 'datastore.totalReadLatency.average'} | select -ExpandProperty Value
WriteLatency = $_.Group | where{$_.MetricId -eq 'datastore.totalWriteLatency.average'} | select -ExpandProperty Value
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks LucD,
This is exactly what I was looking for