VMware Cloud Community
jvm2016
Hot Shot
Hot Shot
Jump to solution

cpu utilization of vms using powercli

HI Luc ,

can yu suggest on the following requirement?

need to create report where cpu utilization of vms  is less than 8 percent for last one month .

do i need to enable stat level 3 for this  on vcenter ??

 

Labels (1)
  • Hi

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You could do that, but why, the cpu.usage.average metric returns the percentage directly.

cpu.jpg


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

View solution in original post

Reply
0 Kudos
6 Replies
jvm2016
Hot Shot
Hot Shot
Jump to solution

also

below is what gives avarage value  but i need percentage is there any direct property for percentage also similar to 

cpu.usagemhz.average

 

 

 

Get-VM | Where {$_.PowerState -eq "PoweredOn"} | Select Name,
@{N="CPU Usage (Average), Mhz" ; E={[Math]::Round((($_ | Get-Stat -Stat cpu.usagemhz.average -Start (Get-Date).AddDays(-30) -IntervalMins 5 | Measure-Object Value -Average).Average),2)}}
Export-Csv -Path c:AverageUsage.csv

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

If you use the cpu.usage.average metric, you will have a percentage


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

Reply
0 Kudos
jvm2016
Hot Shot
Hot Shot
Jump to solution

so inoder to get actual requirement of vms where cpu avg percentage is less than 8 percent for last 30 days 

i need to put one more pipe  of |?{$_ -le "8"}} in below .can yu please check in lab if this gives correct result.

E={[Math]::Round((($_ | Get-Stat -Stat cpu.usagemhz.average -Start (Get-Date).AddDays(-30) -IntervalMins 5 | Measure-Object Value -Average).Average),2)}}

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

You are still using cpu.usagemhz.average


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

Reply
0 Kudos
jvm2016
Hot Shot
Hot Shot
Jump to solution

am i not supposed to get rario of   cpu.usagemhz.average and esxi cpu core MHZ to find cpu percentage??

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

You could do that, but why, the cpu.usage.average metric returns the percentage directly.

cpu.jpg


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

Reply
0 Kudos