PowerCLI

 View Only
  • 1.  get-stat for 6 months data

    Posted Sep 18, 2019 08:48 PM

    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.



  • 2.  RE: get-stat for 6 months data

    Posted Sep 19, 2019 12:40 AM

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

    See PowerCLI & VSphere Statistics – Part 1 – The Basics



  • 3.  RE: get-stat for 6 months data

    Posted Sep 20, 2019 03:34 PM

    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?



  • 4.  RE: get-stat for 6 months data

    Posted Sep 20, 2019 06:20 PM

    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