VMware Cloud Community
dvnguyen
Contributor
Contributor
Jump to solution

IOPs & Latency For Each VM

This is my first time writing a script to pull metrics from the virtual environment and I am trying to pull out the total disk latency and disk iops for each VM in the environment.

Here are the relevant portions that I have so far:

#Get powered on VMs

$VMs = Get-VM | ?{$_.powerstate -eq "PoweredOn"}

#Loop through each VM

foreach ($vm in $VMs) {

     $dskreadlatency = Get-Stat -Entity $vm -Stat "disk.totalreadlatency.average" -Start $start -Finish $end

     $dskwritelatency = Get-Stat -Entity $vm -Stat "disk.totalwritelatency.average" -Start $start -Finish $end

     $dsknumberwrites = Get-Stat -Entity $vm -Stat "virtualdisk.numberwriteaveraged.average" -Start $start -Finish $end

     $dsknumberreads= Get-Stat -Entity $vm -Stat "virtualdisk.numberreadaveraged.average" -Start $start -Finish $end         

}

#setting fields to the averages of the stats (I have 4 of these)

$fieldX = [string]([Math]::Round((($dskYYY | Measure-Object Value -Average).Average),2))

I'm unfortunately getting 0 for all of these stats.  My level settings are all set at 2.  It would be great if I could receive assistance regarding this.

Tags (2)
Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Just to make sure the performance data capturing process is set up correctly on vCenter, do you see data for these counters under the Performance tab for that same time interval ?


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

View solution in original post

Reply
0 Kudos
6 Replies
LucD
Leadership
Leadership
Jump to solution

Where do you populate the $start and $end variables ? And with which datetime values ?

And where does this $dskYYY variable come from ?


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

Reply
0 Kudos
dvnguyen
Contributor
Contributor
Jump to solution

$start = ($currentdate = get-date).adddays(-5).ToString("d")

$end = ($currentdate = get-date).adddays(-1).ToString("d")

The dates were populated right at the beginning.

$dskYYY would be replaced by one of the following:   $dskreadlatency, $dskwritelatency, $dsknumberwrites, $dsknumberreads


Sorry for the confusion!


Additionally I am exporting this information to an excel spreadsheet so at some other point of my code, I set the appropriate column to the proper variable.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

First, try changing the $start and $end assignments like this

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

$end = (Get-Date).AddDays(-1)


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

Reply
0 Kudos
dvnguyen
Contributor
Contributor
Jump to solution

I am still receiving 0s for all 4 stats.

$dskreadlatency = Get-Stat -Entity $vm -Stat "virtualdisk.totalreadlatency.average" -Start $start -Finish $end

$dskwritelatency = Get-Stat -Entity $vm -Stat "virtualdisk.totalwritelatency.average" -Start $start -Finish $end

$dsknumberwrites = Get-Stat -Entity $vm -Stat "virtualdisk.numberwriteaveraged.average" -Start $start -Finish $end

$dsknumberreads= Get-Stat -Entity $vm -Stat "virtualdisk.numberreadaveraged.average" -Start $start -Finish $end        

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Just to make sure the performance data capturing process is set up correctly on vCenter, do you see data for these counters under the Performance tab for that same time interval ?


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

Reply
0 Kudos
dvnguyen
Contributor
Contributor
Jump to solution

I did double check and found out data only existed as of 3AM 2 days ago.  I adjusted the interval and the numbers came out properly.  Thank you!

Reply
0 Kudos