VMware Cloud Community
jlaco
Enthusiast
Enthusiast
Jump to solution

Script to list vm io latency and the datastore the vm is on

Hello.  We have a vsphere 5.0 environment and we are experiencing some heavy io latency.  I have been looking for a powercli script that will get the io latency for each vm and get the datastore name it currently resides on.  We access our storage over fiber.  I'm trying to get a good overview of io latency in one nice view in a csv.  I found what might be a good base at https://communities.vmware.com/thread/304827?start=0&tstart=0 but I'm not quite sure how to get the datastore name into the array and I think it is written for nfs storage anyway.  Thanks in advance for any info\advice!

69 Replies
LucD
Leadership
Leadership
Jump to solution

Yes, but it requires the Statistics Level (in the vCenter) to be set to 4 (which will grow your vCenter DB).

And if you change that value now, it will take time before you see it reflected in the Historical Intervals.

latency.png


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

beharibabu
Contributor
Contributor
Jump to solution

Thanks for the help..

All your inputs are highly helpful.

0 Kudos
beharibabu
Contributor
Contributor
Jump to solution

For now we will not be able to change statistical value at vcenter level, hence couldn't get historical value of read latency at vdisk level. With the script in this discussion, for 80% of the VMs in the cluster getting the junk value of disk latency at datastore level. Hence can you provide a script to find the Read Rate of VM disks, so that we can get VMs with high disk read rate and will work on vFRC.

Thanks in advance.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Collect the vdisk.numberReadAveraged.average and vdisk.numberWriteAveraged.average.

Those metrics require Statistics Level 1 for the aggregate over all vDisks per VM, and Statistics Level 3 for values per vDisk per VM.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
beharibabu
Contributor
Contributor
Jump to solution

I have modified your another script and used it as below.

Add-PSSnapin VMware.VimAutomation.Core

Connect-VIServer *****************

$vmName = Get-Content -Path "C:\Temp\vm.txt"

$stat = 'virtualDisk.numberReadAveraged.average','virtualDisk.numberWriteAveraged.average'

$entity = Get-VM -Name $vmName

Get-Stat -Entity $entity -Stat $stat -Realtime -MaxSamples 1

I'm new to scripting, not sure how to change this script to get historical value(for 15 days).

And statistical value of vcenter is as follows.

pastedImage_5.png

0 Kudos
LucD
Leadership
Leadership
Jump to solution

You can do something like this

$vmName = Get-Content -Path "C:\Temp\sevicm07_vm.txt"

$stat = 'virtualDisk.numberReadAveraged.average','virtualDisk.numberWriteAveraged.average'

$entity = Get-VM -Name $vmName

$start = (Get-Date).AddDays(-15)

Get-Stat -Entity $entity -Stat $stat -Start $start -MaxSamples ([int]::MaxValue)


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
santoshannie
Contributor
Contributor
Jump to solution

It fails for me when i ran the script

pastedImage_0.png

0 Kudos
LucD
Leadership
Leadership
Jump to solution

That metric requires Statistics Level 3.

numberwrite.jpg


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

santoshannie
Contributor
Contributor
Jump to solution

Is there any other way I can fetch the report without changing statistic level .I tried esxtop but there a lot of vms in one esxi host and becomes very difficult .

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Not that I know of I'm afraid.

If the Statistics level is not at the right level, the vCenter will not save the values for the metric in the vCenter DB.

The only numbers you can retrieve are the ones for the Realtime interval, which are kept on each ESXi node for about 1 hour.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos