Do your VMs have all the resources you think they have?


I have a ‘well established’ VMware infrastructure that started back in ESX 1.51. So obviously I have been through many upgrades and/or migrations, but even though my ESX servers have been rebuilt, my VMs from older versions were not.

I don’t remember which revision or which combination of upgrade/migration caused it, but it did warn me that the resource allocations were being changed. When I looked to see what changed I saw all my VMs changed from a ‘normal’ resource share allocation to a custom fixed value that equaled the number for normal. What I didn’t notice back then was that the memory limit was also changed from ‘unlimited’ to the exact size of what was allocated to it at the time. The problem with that is that many of them have had their memory allocation increased since then, but the memory limit was still left at the original memory size thus negating the effectiveness of that additional memory.

What helped me in identifying just how many servers in my environment were in this situation was vKernels SearchMyVM free virtual appliance wich allowed me to query all VMs that don’t have a vm.memoryLimit equal to -1. There was only a default query that used cpuLimit but you can easily substitute memory for cpu and run the query. I also had a few VMs that had CPU limits as well because the unlimited checkbox was removed from them too, but this was less of a problem because all the ones I discovered in that condition had huge limits set that exceeded what they could use anyway.

Now that I’ve identified that I had over 300 VMs that had a memory limit set, I needed to find a way to correct it without going to them one by one. I luckily ran a across a script posted on VMware’s site that would allow me to do just that using the VMware Power Shell. I hadn’t used Power Shell yet, but I was familiar with Perl toolkit so I searched more to find a perl script to accomplish the task, but didn’t find one. I’m sure there’s a way to do it in Perl, but I’m more of a script modifier thatn a script writer so I settled on using the existing Power Shell script.

As is the norm for me once I set on using Power Shell it took me into another tangent. To use the VMware Power Shell script you first have to install Microsoft Power Shell. Normally that wouldn’t be an issue except for the fact that the PowerShell install checks if EFS is enabled first and our company disables it via GPO. When I ran the install I got this nice error message that states “This machine is disabled for file encryption”. The only way around it is to remove the computer from the domain, install PowerShell, then re-join the domain. I spent a few minutes trying to hack around and re-enable EFS on an OU containing my computer but resorted to just ripping it out of the domain since all in all it’s quicker.

After a few test runs in the lab I ran the script against every VM in my environment and I now know that all my VMs have the same default settings that I want them to have.

Leave a comment

Your email address will not be published.