List Disk Latency for all VMs

Today I’ve been asked by an old colleague about a quick way of listing the disk latency for all virtual machines in a vCenter. Normally this is also held by the statistics level set on vCenter Settings so, I’d check at least you chose a Level 2.
At this point the following command will show the average value for the Maximum Disk Latency for every Virtual Machine during the last week.

Get-VM | ? {$_.PowerState -eq "PoweredOn"} | Select Name, @{n="AVG Max Latency (ms)";e={(get-stat -Entity $_ -Stat Disk.MaxTotalLatency.Latest -Start (Get-Date).AddDays(-7) | Measure Value -Average ).Average }}

Still can even be more descriptive when adding a second column with the Maximum value reached, so we could identify some peaks:

Get-VM | ? {$_.PowerState -eq "PoweredOn"} | Select Name, @{n="AVG Max Latency (ms)";e={(get-stat -Entity $_ -Stat Disk.MaxTotalLatency.Latest -Start (Get-Date).AddDays(-7) | Measure Value -Average ).Average }},@{n="Max Latency (ms)";e={(get-stat -Entity $_ -Stat Disk.MaxTotalLatency.Latest -Start (Get-Date).AddDays(-7) | Measure Value -Maximum ).Maximum }}
Advertisements

3 thoughts on “List Disk Latency for all VMs”

  1. Thanks for the script. I ran the script against a single machine, using the .AddDays(-7) and .AddDays(-1). The AVG Max Latency (ms) value is consistent, but Max Latency (ms) varies.

    1. Hi Dan,
      Welcome and thanks for your answer.
      I’m not quite sure how your vm is performing and how often you run this command.
      I’d say your VM is a very disk usage intensive or the datastore where the vm is located might also have high usage.
      Hope that could be useful for you.

      Regards.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s