VMware Cloud Community
tdubb123
Expert
Expert

get-stat for 6 months data

I need to get info of Memory and cpu utilization on VMs on a cluster for 6 months.

any idea how I can get this info? I dont think vcenter stats go back that far.

0 Kudos
3 Replies
LucD
Leadership
Leadership

That depends on what Statistics Levels you defined on your vCenter.

See PowerCLI & VSphere Statistics – Part 1 – The Basics


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

0 Kudos
tdubb123
Expert
Expert

is there a way to get mem/cpu data to plot for trend usage?

the below script only give me 180 days

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

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

@{N="CPU Usage (Min), %" ; E={[Math]::Round((($_ | Get-Stat -Stat cpu.usage.average -Start (Get-Date).AddDays(-180) -IntervalMins 5 | Measure-Object Value -Minimum).Minimum),2)}},

@{N="CPU Usage (Max), %" ; E={[Math]::Round((($_ | Get-Stat -Stat cpu.usage.average -Start (Get-Date).AddDays(-180) -IntervalMins 5 | Measure-Object Value -Maximum).Maximum),2)}},

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

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

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

what if I want to get historical trend over 180days. do run this multiple times and plot the data?

0 Kudos
LucD
Leadership
Leadership

That seems to indicate that you only keep statistical for 180 days, or that your vCenter was reinitialised 180 days ago.

For trendlines you could have a look at what is possible with New-ExcelChart (from the ImportExcel module).

See for example Re: Automate CSV output to performance chart view powercli


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

0 Kudos