VMware Cloud Community
Sivaramsharmar
Enthusiast
Enthusiast
Jump to solution

Cluster IOPS

Hi All,

Is there any way to get Cluster IOPS with avg read, avg write, read min, read max, write min, write max, IOPS min, IOPS max using Powercli.

Thanks in advance.

1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try like this.

Note that the script only does shared VMFS datastores.

$clusterName = 'MyCluster'

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

$esx =  Get-Cluster -Name $clusterName | Get-VMHost

$dsTab = @{}

Get-Datastore -RelatedObject $esx | where {$_.Type -eq 'VMFS' -and $_.ExtensionData.Summary.MultipleHostAccess} | Sort-Object -Property Name -Unique | %{

    $dsTab.Add($_.ExtensionData.Info.Vmfs.Uuid,$_.Name)

}

Get-Stat -Entity $esx -Stat $stat -Realtime -MaxSamples 1 |

Group-Object -Property Instance | %{

    if($dsTab.ContainsKey($_.Name)){

        New-Object PSObject -Property @{

            Datastore = $dsTab[$_.Name]

            ReadIOPS = $_.Group | where {$_.metricId -match 'read'} | Measure-Object -Property Value -Sum | Select -ExpandProperty Sum

            WriteIOPS = $_.Group | where {$_.metricId -match 'write'} | Measure-Object -Property Value -Sum | Select -ExpandProperty Sum

        }

    }

}


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

View solution in original post

10 Replies
LucD
Leadership
Leadership
Jump to solution

I assume you are looking for the IOPS per datastore over all the ESXi nodes in the cluster ?


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

Reply
0 Kudos
Sivaramsharmar
Enthusiast
Enthusiast
Jump to solution

Yes Lucd, I am looking for same.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Try like this.

Note that the script only does shared VMFS datastores.

$clusterName = 'MyCluster'

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

$esx =  Get-Cluster -Name $clusterName | Get-VMHost

$dsTab = @{}

Get-Datastore -RelatedObject $esx | where {$_.Type -eq 'VMFS' -and $_.ExtensionData.Summary.MultipleHostAccess} | Sort-Object -Property Name -Unique | %{

    $dsTab.Add($_.ExtensionData.Info.Vmfs.Uuid,$_.Name)

}

Get-Stat -Entity $esx -Stat $stat -Realtime -MaxSamples 1 |

Group-Object -Property Instance | %{

    if($dsTab.ContainsKey($_.Name)){

        New-Object PSObject -Property @{

            Datastore = $dsTab[$_.Name]

            ReadIOPS = $_.Group | where {$_.metricId -match 'read'} | Measure-Object -Property Value -Sum | Select -ExpandProperty Sum

            WriteIOPS = $_.Group | where {$_.metricId -match 'write'} | Measure-Object -Property Value -Sum | Select -ExpandProperty Sum

        }

    }

}


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

Sivaramsharmar
Enthusiast
Enthusiast
Jump to solution

Thanks Lucd, Script works like Charm!!

Reply
0 Kudos
sistemasvmware
Contributor
Contributor
Jump to solution

Is there any way to get specific dates?

I need to deep inside storage problems with iops

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Yes, you could use that Start and Finish parameters on the Get-Stat cmdlet, instead of the Realtime switch.

But note that the granularity of the returned data will be (a lot) less, depending on the historical interval you end up in.

See PowerCLI & vSphere statistics – Part 1 – The basics for some more info on Historical Intervals.


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

Reply
0 Kudos
sistemasvmware
Contributor
Contributor
Jump to solution

Doing that gaves me the same result.

$clusterName = 'Cluster'

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

$esx =  Get-Cluster -Name $clusterName | Get-VMHost

$dsTab = @{}

Get-Datastore -RelatedObject $esx | where {$_.Type -eq 'VMFS' -and $_.ExtensionData.Summary.MultipleHostAccess} | Sort-Object -Property Name -Unique | %{

    $dsTab.Add($_.ExtensionData.Info.Vmfs.Uuid,$_.Name)

}

$todayMidnight = (Get-Date -Hour 0 -Minute 0 -Second 0).AddMinutes(-1)

Get-Stat -Entity (Get-VMHost $esxName) -Stat cpu.usage.average -Start $todayMidnight.AddDays(-5) -Finish $todayMidnight.AddDays(-1)

Get-Stat -Entity $esx -Stat $stat -Realtime -MaxSamples 1 |

Group-Object -Property Instance | %{

    if($dsTab.ContainsKey($_.Name)){

        New-Object PSObject -Property @{

            Datastore = $dsTab[$_.Name]

            ReadIOPS = $_.Group | where {$_.metricId -match 'read'} | Measure-Object -Property Value -Sum | Select -ExpandProperty Sum

            WriteIOPS = $_.Group | where {$_.metricId -match 'write'} | Measure-Object -Property Value -Sum | Select -ExpandProperty Sum

        }

    }

}

Im trying to get 5 days before.

I need to delete "| where{$_.Instance -eq ""}" this part because the script returns me that a var was null.

im a little bit confused

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

The metrics used in the script are level 3 to get "per device" data.

This means that you would have to set the Statistics level to 3 for the Historical Interval in which your desired timeframe falls.

If that is the case, you could use something like this

$clusterName = 'MyCluster'

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

$esx =  Get-Cluster -Name $clusterName | Get-VMHost

$dsTab = @{}

Get-Datastore -RelatedObject $esx | where {$_.Type -eq 'VMFS' -and $_.ExtensionData.Summary.MultipleHostAccess} | Sort-Object -Property Name -Unique | %{

    $dsTab.Add($_.ExtensionData.Info.Vmfs.Uuid,$_.Name)

}

$todayMidnight = (Get-Date -Hour 0 -Minute 0 -Second 0).AddMinutes(-1)

Get-Stat -Entity $esx -Stat $stat -Start $todayMidnight.AddDays(-5) -Finish $todayMidnight.AddDays(-1)

foreach($instance in (Group-Object -Property Instance)){

    if($dsTab.ContainsKey($instance.Name)){

        $instance.Group | Group-Object -Property Timestamp | %{

            New-Object PSObject -Property @{

                Timestamp = $_.Name

                Datastore = $dsTab[$instance.Name]

                ReadIOPS = $_.Group | where {$_.metricId -match 'read'} | Measure-Object -Property Value -Sum | Select -ExpandProperty Sum

                WriteIOPS = $_.Group | where {$_.metricId -match 'write'} | Measure-Object -Property Value -Sum | Select -ExpandProperty Sum

            }

        }

    }

}


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

Reply
0 Kudos
sistemasvmware
Contributor
Contributor
Jump to solution

Thanks LUCD. i appreciate your work a lot.

Think that you are one of the hardest column at powercli!

PD:Is there a way to get all datastores info? not only vmfs shared

Thanks!

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Thanks Smiley Happy

To get all the datastores, remove the Where-clause after the Get-Datastore cmdlet.


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

Reply
0 Kudos