theflakes
Contributor
Contributor

24 hour average lun read/write latency

Jump to solution

How can I get the average read and write latency for each LUN via PS? I know how to get the latest, but can't figure out how to get a 24 hour average. If it matters the storage we use is iSCSI shared between three ESXi essentials servers with vCenter running in a VM.

thanks...

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

Sure can.

First let's examine the available historical intervals

Get-StatInterval | select Samplingperiodsecs, name,  storagetimesecs

This will show

  SamplingPeriodSecs Name                                                                                StorageTimeSecs
  ------------------ ----                                                                                ---------------
                 300 Past Day                                                                                86400
                1800 Past Week                                                                                604800
                7200 Past Month                                                                                2592000
               86400 Past Year                                                                                31536000

For now only look at the first 2 columns, there you see the Historical Intervals 1-4

In minutes/days that gives

Historical Interval 1    5 minutes
Historical Interval 2    30 minutes
Historical Interval 3    120 minutes
Historical Interval 4    1 day

Besides the name in the second column, the third column shows how long you will have access to statistical data from that interval.

For example, Historical Interval 1 with the 5 minute interval is kept for 1 day.

If we get statistical data from 1 day ago, we will wind up in Historical Interval 2, with the 30 minute interval.

Let's get some stats

$esxName = <ESX-hostname>
# Sample instance
$tgtInstance = "naa.600507680180809ed000000000000179"

$stats = Get-Stat -Entity (Get-VMHost $esxName) `
		-Stat "disk.deviceReadLatency.average" `
		-Start (Get-Date).AddDays(-2) `
		-Finish (Get-Date).AddDays(-1) | `
		where{$_.instance -eq $tgtInstance}

As you see from the -Start and -Finish parameters we request the statistical data from between 48 and 24 hours ago.

The sample intervals will all be 30 minutes (Historical Interval 2).

To get the day average you can do

$dayAvg = ($stats | Measure-Object -Average -Property Value).Average

Now suppose we retrieve more than 1 day of data and we want day averages, you could do this

$esxName = <ESX-hostname>
# Sample instance
$tgtInstance = "naa.600507680180809ed000000000000179"

$stats = Get-Stat -Entity (Get-VMHost $esxName) `
		-Stat "disk.deviceReadLatency.average" `
		-Start (Get-Date).AddDays(-5) `
		-Finish (Get-Date).AddDays(-1) | `
		where{$_.instance -eq $tgtInstance}
$dayStats = $stats | Group-Object -Property {$_.Timestamp.Day}
$dayStats | %{
	$dayAvg = ($_.Group | Measure-Object -Average -Property Value).Average
	Write-Host "Day" $_.Name $dayAvg
}

Is this approximately what you were looking for ?


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

View solution in original post

0 Kudos
3 Replies
LucD
Leadership
Leadership

The Get-Stat cmdlet will return samples with an interval time based on the Historical Interval which contains the time range you are investigating.

If you fall in Historical Interval 4 the samples will already be consolidated into 1 day intervals.

If you fall in any of the other Historical Intervals you will have to calculate the 1 day average yourself.

But this is quite easy with PS.

You could:

- group the returned samples for example on the day (with the Group-Object cmdlet)

- calculate the average over all the samples in a 'day' group (with the Measure-Object cmdlet).


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

0 Kudos
ICT-Freak
Enthusiast
Enthusiast

Luc can you please post an example about this subject?

0 Kudos
LucD
Leadership
Leadership

Sure can.

First let's examine the available historical intervals

Get-StatInterval | select Samplingperiodsecs, name,  storagetimesecs

This will show

  SamplingPeriodSecs Name                                                                                StorageTimeSecs
  ------------------ ----                                                                                ---------------
                 300 Past Day                                                                                86400
                1800 Past Week                                                                                604800
                7200 Past Month                                                                                2592000
               86400 Past Year                                                                                31536000

For now only look at the first 2 columns, there you see the Historical Intervals 1-4

In minutes/days that gives

Historical Interval 1    5 minutes
Historical Interval 2    30 minutes
Historical Interval 3    120 minutes
Historical Interval 4    1 day

Besides the name in the second column, the third column shows how long you will have access to statistical data from that interval.

For example, Historical Interval 1 with the 5 minute interval is kept for 1 day.

If we get statistical data from 1 day ago, we will wind up in Historical Interval 2, with the 30 minute interval.

Let's get some stats

$esxName = <ESX-hostname>
# Sample instance
$tgtInstance = "naa.600507680180809ed000000000000179"

$stats = Get-Stat -Entity (Get-VMHost $esxName) `
		-Stat "disk.deviceReadLatency.average" `
		-Start (Get-Date).AddDays(-2) `
		-Finish (Get-Date).AddDays(-1) | `
		where{$_.instance -eq $tgtInstance}

As you see from the -Start and -Finish parameters we request the statistical data from between 48 and 24 hours ago.

The sample intervals will all be 30 minutes (Historical Interval 2).

To get the day average you can do

$dayAvg = ($stats | Measure-Object -Average -Property Value).Average

Now suppose we retrieve more than 1 day of data and we want day averages, you could do this

$esxName = <ESX-hostname>
# Sample instance
$tgtInstance = "naa.600507680180809ed000000000000179"

$stats = Get-Stat -Entity (Get-VMHost $esxName) `
		-Stat "disk.deviceReadLatency.average" `
		-Start (Get-Date).AddDays(-5) `
		-Finish (Get-Date).AddDays(-1) | `
		where{$_.instance -eq $tgtInstance}
$dayStats = $stats | Group-Object -Property {$_.Timestamp.Day}
$dayStats | %{
	$dayAvg = ($_.Group | Measure-Object -Average -Property Value).Average
	Write-Host "Day" $_.Name $dayAvg
}

Is this approximately what you were looking for ?


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

View solution in original post

0 Kudos