VMware Cloud Community
Sivaramsharmar
Enthusiast
Enthusiast

Clusterwise CPU & MEM Utilization Report

Hi All,

I have gone through some of the discussions(in VMware Communities) and able to get CPU & MEM stats from ESXi Level but we are in a need of getting same report from Cluster level.

Could some one help me on getting below report from past 7 days.

ClusterName,CPU Usage, MEM Usage

Cluster1, 20%, 60%

Cluster2, 25%,50%

Thanks in Advance.

Siva

Reply
0 Kudos
3 Replies
LucD
Leadership
Leadership

You can do something like this.

It collects the statistics over all the ESXi nodes in the cluster, and then calculates the average

$clusterName = 'MyCluster'

$cluster = Get-Cluster -Name $clusterName

$esx = Get-VMHost -Location $cluster

$stat = 'cpu.usage.average','mem.usage.average'

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

Get-stat -Entity $esx -Stat $stat -Start $start -Instance '' |

Group-Object -Property Timestamp | %{

    New-Object -TypeName PSObject -Property @{

        Cluster = $clusterName

        Date = $_.Name

        CPUAvg = $_.Group | where{$_.MetricId -eq 'cpu.usage.average'} | Measure-Object -Property Value -Average | Select -ExpandProperty Average

        MemAvg = $_.Group | where{$_.MetricId -eq 'mem.usage.average'} | Measure-Object -Property Value -Average | Select -ExpandProperty Average

    }

   

}


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

Reply
0 Kudos
Sivaramsharmar
Enthusiast
Enthusiast

Hi Lucd,

I am getting output as below, as timestamp of 5 minutes difference in a cluster.

Date                                        Cluster                                                          CPUAvg                        MemAv

----                                             -------                                                              ------                                -----

1/25/2016 1:25:00 PM          Cluster1                                                   4.87333337776363              47.253334045410

1/25/2016 1:20:00 PM          Cluster1                                                   4.12333321881791              47.173333485921

1/25/2016 1:15:00 PM          Cluster1                                                   5.05000003178914              47.206666310628

1/25/2016 1:10:00 PM          Cluster1                                                                             5.5              47.203333536783

1/25/2016 1:05:00 PM          Cluster1                                                    5.26666673024495             47.053333282470

1/25/2016 1:00:00 PM          Cluster1                                                    5.1100001335144               46.776666005452

Is there any way that we can get output will be in below format by aggregating all the Average values per day.

Date                                        Cluster                                                          CPUAvg                        MemAv

----                                             -------                                                              ------                                -----

1/25/2016                              Cluster1                                                                 6                                   15

1/25/2016                              Cluster2                                                                 8                                   20

Thanks,

Siva

Reply
0 Kudos
LucD
Leadership
Leadership

Try like this

$cluster = Get-Cluster

$esx = Get-VMHost -Location $cluster

$stat = 'cpu.usage.average','mem.usage.average'

$start = (Get-Date).AddHours(-1)

$stats = Get-stat -Entity $esx -Stat $stat -Start $start -Instance ''

$stats | Group-Object -Property {$_.Entity.ExtensionData.Parent} | %{

    New-Object -TypeName PSObject -Property @{

        Cluster = Get-View -Id $_.Name -Property Name | Select -ExpandProperty Name

        Date = $start

        CPUAvg = $_.Group | where{$_.MetricId -eq 'cpu.usage.average'} | Measure-Object -Property Value -Average | Select -ExpandProperty Average

        MemAvg = $_.Group | where{$_.MetricId -eq 'mem.usage.average'} | Measure-Object -Property Value -Average | Select -ExpandProperty Average

    }

}


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

Reply
0 Kudos