VMware Cloud Community
mike-p
Enthusiast
Enthusiast
Jump to solution

Script to list ballooning VM's

I search a cmdlet or script to list all vm's  were the memctl requests memory.

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Are these VMs, for which you get the error, powered on ?

Try this variation

$vms = Get-VM 
Get-Stat -Entity $vms -Realtime -Stat mem.vmmemctl.average -MaxSamples 1 -ErrorAction SilentlyContinue |
where {$_.Value -gt 5} | Select @{N="VM";E={$_.Entity.Name}},Value


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

View solution in original post

0 Kudos
7 Replies
Bahou
Enthusiast
Enthusiast
Jump to solution

Hello Mike,

Can you please clarify your question?  Are you asking about using esxtop to monitor your VM memory ballooing statistics?

- Jack
0 Kudos
LucD
Leadership
Leadership
Jump to solution

You could do something like this.

It will list all VMs that have ballooning above 5 KB

$vms = Get-VM 
Get-Stat -Entity $vms -Realtime -Stat mem.vmmemctl.average -MaxSamples 1 | where {$_.Value -gt 5} | Select @{N="VM";E={$_.Entity.Name}},Value


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

0 Kudos
mike-p
Enthusiast
Enthusiast
Jump to solution

I found one but it seems to work only with ESX3 :  http://ict-freak.nl/2009/12/18/powercli-find-resourcepool-or-vms-with-memory-ballooningswap-usage/  I think ".Summary.QuickStats.BalloonedMemory" is not supported on ESX4 anymore

0 Kudos
mike-p
Enthusiast
Enthusiast
Jump to solution

Hi Luc, the script works for affected vm's but gives an error for all others :  Get-Stat : 01.03.2012 00:19:14    Get-Stat        The metric counter "mem.vmmemctl.average" doesn't exist for  entity "VMNAME". At C:\Users\Administrator\Downloads\balloon-vm2.ps1:2 Col:9 + Get-Stat <<<<  -Entity $vms -Realtime -Stat mem.vmmemctl.average -MaxSamples 1 |     + CategoryInfo          : ResourceUnavailable: (mem.vmmemctl.average:String) [Get-Stat], VimException     + FullyQualifiedErrorId : Client20_RuntimeDataServiceImpl_CheckUserMetrics_MetricDoesntExist,VMware.VimA    utomation.ViCore.Cmdlets.Commands.GetViStats

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Are these VMs, for which you get the error, powered on ?

Try this variation

$vms = Get-VM 
Get-Stat -Entity $vms -Realtime -Stat mem.vmmemctl.average -MaxSamples 1 -ErrorAction SilentlyContinue |
where {$_.Value -gt 5} | Select @{N="VM";E={$_.Entity.Name}},Value


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

0 Kudos
mike-p
Enthusiast
Enthusiast
Jump to solution

Hi Luc, this works great. Only one warning is shown :  WARNING: 'Entity' property is obsolete. Use 'EntityId' instead.  But the output is exactly what i searched for.  Thanks

0 Kudos
LucD
Leadership
Leadership
Jump to solution

That warning can be ignored for now. It just states that in a future PowerCLI build that property might not be there anymore.

You can get rid of those warnings by doing the following once in your session

Set-PowerCLIConfiguration -DisplayDeprecationWarnings $false


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

0 Kudos