Hi all,
Im trying to get a CPU, MEM, Net and Swap utilization report with powercli and I got the first 3 but I've been looking on how to get the VMs swap utilization with no luck, is there a way/metric to get this info with powerCLI??
moderator edit by wila: Moved to PowerCLI discussions forum.
Just to confirm, do you mean the amount of VM memory currently swapped out to disk by the hypervisor? If yes, that is just another metric. Are you using Get-Stat for the other 3? I.e. show what you are doing right now.
P.S.
I'm fairly sure there is a PowerCLI specific discussion group, you might want to post future questions there, don't duplicate this now of course.
This is what I have for the other metrics.
I need the same but for Swap memory usage if that even exists
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)}}
Depending on which Statistics Level you have defined on your vCenter, swap related metrics are available.
You can check on the memory page of the PerformanceManager or via Get-StatType, with the correct period.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
What Luc said (of course).
I like Florian's overview here: https://www.virten.net/2015/05/which-performance-counters-are-available-in-each-statistic-level/ (assuming a default configuration)
Alternatively, if you look at vCenter's Advanced Performance Charts and can't see the metric for the object you want to collect in the time range you are interested in, you can't collect it using API either (in the past, you could select the metric but it would show as not available when trying to graph, with recent vCenter versions the selection changes based on selected time-span).
In your case, for a VM, the available swap statistics outside of Real Time would be swap in / out rate.
P.S.
Don't just adjust the stats levels for the collection intervals, it comes at a cost esp. in larger environments.
You could of course also look at my PowerCLI & VSphere Statistics – Part 1 – The Basics. 😁
It goes into a bit more detail on metrics, statistic levels, intervals, instances ...
And it is Part 1 of a series.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
+1 Definitely read Luc's series, I'm still referring to it after all these years whenever I need to do something with PowerCLI and stats. The only "eyesore" is the capital V in vSphere in the title 😉
I'm afraid that was a WordPress feature that I didn't disable 🙄
Should be fixed now, and I hope your eyes will recover soon
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference