VMware Cloud Community
AlbertWT
Virtuoso
Virtuoso

Modifying PowerCLI script for Get-Stat2 ?

Hi All,

I wonder if anyone here can assist me in using the script created by LucD  http://www.lucd.info/download/Get-Stat2.ps1 to get the VM statistics:

Get-VM | Where {$_.PowerState -eq "PoweredOn"} | Select Name, Host, NumCpu, MemoryMB, `

@{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)}}, `

@{N="Memory Usage (Average), %" ; E={[Math]::Round((($_ | Get-Stat -Stat mem.usage.average -Start (Get-Date).AddDays(-30) -IntervalMins 5 | Measure-Object Value -Average).Average),2)}} , `

@{N="Network Usage (Average), KBps" ; E={[Math]::Round((($_ | Get-Stat -Stat net.usage.average -Start (Get-Date).AddDays(-30) -IntervalMins 5 | Measure-Object Value -Average).Average),2)}} , `

@{N="Disk Usage (Average), KBps" ; E={[Math]::Round((($_ | Get-Stat -Stat disk.usage.average -Start (Get-Date).AddDays(-30) -IntervalMins 5 | Measure-Object Value -Average).Average),2)}} |

Export-Csv -Path C:\TEMP\AverageUsage.csv -NoTypeInformation

The above script does not show anything even after I raised the Statistics to level 3 in the morning. Like this one:

Stats.JPG

Thanks in advance,

/* Please feel free to provide any comments or input you may have. */
2 Replies
cbelnap
Contributor
Contributor

Worked for me in a 6.0 vcenter that I have setup running statistics level 3,2,2,2.  Thinking that since you just changed the levels that there isn't enough data yet in the database to give you the 30 day average sample.  Maybe try using 1 day if that is how long it has been since you increased the statistics level. 

AlbertWT
Virtuoso
Virtuoso

cbelnap, yes, Luc has confirmed that to me in the other thread, so now I wonder if the script above can be modified using Get-Stat2 ?

/* Please feel free to provide any comments or input you may have. */
Reply
0 Kudos