VMware Cloud Community
rolfbartels
Contributor
Contributor
Jump to solution

Need help scripting the datastore.maxTotalLatency.latest from datastores

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

1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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

$esxName = 'MyEsx'

$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

View solution in original post

2 Replies
LucD
Leadership
Leadership
Jump to solution

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

$esxName = 'MyEsx'

$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

rolfbartels
Contributor
Contributor
Jump to solution

Thanks LucD,

This is exactly what I was looking for

0 Kudos