jvm2016
Hot Shot
Hot Shot

cpu utilization of vms using powercli

Jump to solution

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

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

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

0 Kudos
6 Replies
jvm2016
Hot Shot
Hot Shot

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

0 Kudos
LucD
Leadership
Leadership

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


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

0 Kudos
jvm2016
Hot Shot
Hot Shot

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)}}

0 Kudos
LucD
Leadership
Leadership

You are still using cpu.usagemhz.average


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

0 Kudos
jvm2016
Hot Shot
Hot Shot

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

0 Kudos
LucD
Leadership
Leadership

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

0 Kudos