I am running this report and want to add average memory Usage in GB. I'd like to account for all the memory that a VM has been demanding from ESXi, including overhead.
get-vm | select name, memoryGB
How can I add average memory demand to this report?
Thanks!
You can do
Get-StatType -Interval "Past Week" -Entity AnyVM | where {$_ -match "mem"}
Just replace the AnyVM with a name of a VM in your environment
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try something like this
Get-VM |
Select Name, MemoryGB,@{N="MemoryConsumedGB";E={
[math]::Round(((Get-Stat -Entity $_ -Realtime -MaxSamples 1 -Stat "mem.consumed.average","mem.overhead.average" |
Measure-Object -Property Value -Sum | Select -ExpandProperty Sum)/1MB),1)
}}
It adds the currently consumed and overhead memory together.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
OK great thanks.
Thanks again for all the help!
It looks as if you are looking for the active memory in that case.
The following gets the average over 7 days.
Get-VM |
Select Name, MemoryGB,@{N="MemoryConsumedGB";E={
[math]::Round((
(Get-Stat -Entity $_ -Start (Get-Date).AddDays(-7)-Stat "mem.active.average" |
Measure-Object -Property Value -Average | Select -ExpandProperty Average)/1MB),1)}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
OK thanks. That gives me a blank. I suspect it is my statistics logging level. How can I check which statistics I do have available for memory for the last week so I know what I have to work with?
You can do
Get-StatType -Interval "Past Week" -Entity AnyVM | where {$_ -match "mem"}
Just replace the AnyVM with a name of a VM in your environment
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
OK thanks again.