VMware Cloud Community
sureshadmin2011
Enthusiast
Enthusiast

Collect VM cpu ready summation and average percentage for a specific time period

Want to collect CPU ready summation and average percentage specifically for a few hours in the day.

Its relatively easy to pull out the summation but need a script which will show up average percentage also.

For example, CPU ready summation and avg percentage values of all vm's in a cluster for specific consecutive five hours in a day with 1min interval exported to CSV.

Reply
0 Kudos
7 Replies
LucD
Leadership
Leadership

It's not clear to me what exactly you want.

What do you mean by  "average"? Is that on cpu.ready.summation?
Or do you mean values for cpu.ready.summation and cpu.usage.average?

And that over 1 minute intervals? Does this imply that you only want a report from data from the last day?


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

Reply
0 Kudos
sureshadmin2011
Enthusiast
Enthusiast

That "average" was confusing there.

Sorry i just need CPU ready summation and CPU ready percentage value on 1 min interval for a time period of any specified five hours on previous day.

Reply
0 Kudos
LucD
Leadership
Leadership

The statistics for the last day are already aggregated for a 5-minute interval.

That would make it hard to get values for a 1-minute interval.

The following will give you the value (ms and percentage) over the 5-minute interval.

$clusterName = 'MyCluster'

$interval = 5

$stat = 'cpu.ready.summation'

$finish = Get-Date

$start = ($finish).AddHours(- $interval)

$entity = Get-Cluster -Name $clusterName | Get-VM

Get-Stat -Entity $entity -Stat $stat -Start $start -Finish $finish |

Group-Object -Property {$_.Entity.Name} | %{

    $_.Group | %{

        New-Object PSObject -Property @{

            VM = $_.Entity.Name

            Date = $_.Timestamp

            ReadyMs = $_.Value

            ReadyPerc = "{0:P2}" -f ($_.Value/($_.Intervalsecs*1000))

        }

    }

}


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

Reply
0 Kudos
IKirill
Enthusiast
Enthusiast

Hi LUCD!

Should I divide the resulting values from the script by the number of VCPUs?

Reply
0 Kudos
LucD
Leadership
Leadership

You could, but I would prefer to have this as a percentage of Ready time over all available CPU resources.
Similar to what cpu.usage.average is giving.

But again, that is a personal preference.


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

Reply
0 Kudos
Sudi80
Contributor
Contributor

How it can be export this value in EXCEL / CSV Format ?

Reply
0 Kudos
LucD
Leadership
Leadership

Just add

| Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture

after the last curly brace.


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

Reply
0 Kudos