If you are an admin who manages a vSphere environment then you are in the right place. How many times did you wish for a report that would give you a holistic view of capacity of your environment? Well, I know you can get that from vRealize Operations Manager, but what about a simple script which can give you similar information but in more compact form.
Imagine logging in to your system in the morning and opening a HTML report which gives you at a
glance information of your environment. This script does exactly that.
This is a script which generates a HTML report on overall capacity of a vSphere environment. For example, it can tell you what is the total available physical cores in your environment. What is the allocated vCPU and Used vCPU in your environment. Similar information for memory of the environment is also available. It will also tell you the total number of VM’s in the environment. At the end it gives you view of all the datastores. The script gives you a close approximation of the resources, since it does not calculate the memory overhead of the VM’s or memory required by the hypervisor, so it is not an exact value, but would give you fair idea about your environment capacity. The best part of this script is, it breaks down the information from overall capacity to Cluster level to Host level. So that you can get a fair idea of the environment.
This is a plain PowerShell script which you can run manually or schedule it in Windows Scheduler. There is a single script Get-Capacity.ps1 which when run will generate the report for the environment. To run the script, follow the following format:
Get-Capacity -vcenter <vcenter> -vcuser <vcenter user=""> -vcpassword <vcenter password=""> -consolidation <cpu consolidation="" ratio=""> </cpu></vcenter></vcenter></vcenter>
Note the Consolidation parameter. Depending on the number of available physical cores, the script calculates Available vCPU count. This count is generated based on the CPU consolidation ratio that you want for your environment.
A sample output is shown below.
vSphere Capacity Report
This is the first cut of the script and I plan to improve the following areas.
Also I plan to collaborate with my reader and take inputs for them. This script is more of educational value than practical value. So I want my readers to work on this and provide suggestions.
You can download the main script as well as the sample HTML file from the GitHub repository at https://github.com/sajaldebnath/vsphere-capacity-report . So let’s start!!!!!!!!!!!!!!