Tag Archive: vSphere

May 18 2012

Finding CPU / Memory Maximum

I have been asked many times to try and work out the maximum performance of a VM from a CPU & Memory perspective for a number of reasons. I sat down and started plugin my way through to GUI to find the relevant information and then find out how to get the same from PowerGUI.

The below script is what I came up with which displays results as shown in the output below:

The script returns the Clusters and the VM’s in each Cluster and then outputs the relevant details; returning values for every 120 mins (2 hours) which is the default period for data saved for 1 month period (specified in script).

The output for one VM is shown below, which is the same info as we can see in the results taken from Virtual Center for the same VM.

Cluster VSI Cluster 01
VM VMName01
CPUCount 2
CPUUsage 91.88%
MEMSize 4096
MEMUsage 24.55%

CPU Usage


Nov 02 2011

Identifying VM Snapshots

Below you will see some code to identify VM snapshots in your Virtual Center environment.

Here you will see the VM that the snapshot is from, the Name, Cluster, Datastore, PowerState, Size and the date that the snapshot was taken. This information is extremely useful for finding all the snapshots in your VC environment to identify what can be deleted to save some space.

Code written in PowerCLI.

Aug 22 2011

VM Block Size & Max. Storage Size (vSphere 4)

I was working on a virtual environment recently and come across a problem with the maximum storage size for a VMDK. Upon looking further into this, I found that the block size for the datastores across our environment were mixed between, 1MB, 2MB and 4MB.

After some investigation, I found some great sites detailing the differences, best practices and recommendations. Below I will try to summarize this information for all interested.

If you run the below powerCLI script you will get a list of your Datastores, the driver version and the block size assigned…


Name Version BlocksizeMB
ABC-0211-0028-TIER1-500GB-0080 3.31 2
ABC-0212-0028-TIER1-1TB-0052 3.33 4
ABC-0213-0028-TIER1-500GB-0057 3.31 2
ABC-0214-0028-TIER1-500GB-0055 3.31 1
ABC-0215-3518-TIER2-1TB-0017 3.46 1
ABC-0215-3528-TIER1-1TB-0025 5.54 4

… from this script you can easily determine if the blocks sizes are different in your environments.

As stated above these blocks sizes determine the maximum size of your VMDK files and therefore default drives in the guest OS. This may also affect your Storage vMotion where you want to move a VMDK from one datastore to another. If the destination datastore has a smaller block size and the image is larger than the maximum volume size (above) then you will receive an error and the svMotion will not work. The block size and maximum volume size is shown below (Table 1)

Block Size Max Volume Size (VMFS-3)
1MB 256GB
2MB 512GB
Table 1: Block and Max Volume Size

In the event where you may want to resize all or all of your datastores, all data must be removed and the datatore itself must be reformatted with the new block size.

Having the larger block size will waste some disk space, but due to the number of files for each  VM (~10-15) wasting a small amount of disk space (~100MB) will far outweigh the advantaged of having Storage vMotion working effectively throughout your VMware environment.

Issues also come into play when Snapshots are left on disk for a period of time and the size of the image grows larger than the datastores maximum file size. Although the typical scenario suggests that snapshots shouldn’t be left on disk for this to occur, this can still be an issue.

In Table 2, below, the version of the file system, and from which ESX version they were formatted is shown. Where environments have been upgraded over time, you may find that you have mixed file system versions. For versions above 3.21 (ESX 3.0.0) no additional work is necessary if mixed version are found. The information presented here is only for information purposes only.

FS Version Formatted with ESX version
3.21 ESX 3.0.0
3.31 ESX 3.5.0
3.33 ESX 4.0
3.46 ESX 4.1
5.54 ESX 5.0
Table 2: FS Version & VM Version

After looking at all the problems above, the best solution to this potential problem, is to analyse all the current and future disk sizes you require and create a block size that will accommodate for these. If for instance you have a single server that will require a single disk image of 750GB, and all others only require 200GB, it would be advisable to create the datastore with a 4MB block size to allows for any potential storage vMotion you may require in the future.

Further information on these two topics can be found on the VMware knowledge base at the following URL’s:

http://bit.ly/nuHHeZ – Block Size Limitations
http://bit.ly/pgyx80 – Snapshot Size Limitations

Aug 11 2011

VM Hardware and Tool Versions – PowerCLI

We are in the process of upgrading our VM’s from a Tools and Hardware perspective. I was after the ability to find a list of VM, with the current build numbers for what was required to be upgraded and came up with the following script.. I hope this helps someone.

Results were as follows:

Aug 03 2011

PowerShell Hashtables

I was poking around in PowerCLI (Powershell for VMware) trying to identify all hosts with additional information like, Memory Allocation, Cluster Ownership and Storage Assignment. This information is somewhat easy to gather normally, but I found a useful little piece of code which makes it all that more compact, yet still simple enough to read.

This code uses what is known as “hash tables” to enclose another piece of code inside the primary code block. In this example above, I use the ‘get-vmhost’ to get all the VM’s attached to vCenter, then pull some information bound to each primary VM such as which cluster they were from, the total amount of memory for each host and an array of the datastores that were assigned to each.

What this command does, it uses the ‘get-vmhost’ to gather each host, then pipe this information to the standard select statement to gather selective information. In this case, the NAME of the host is the first information, but then we see @ symbol and then {N=”Cluster”;E={get-cluster -VMHost $_}}. This creates a new Column to be displayed with the Title “Cluster”, as displayed after the N=. The E= is the command that is run, which in this case is the ‘get-cluster…’ The $_ after the -VMHost indicates that we want to use the already stored value before the pipe (|) in the current loop cycle.

The resulting output you will recieve from this piece of code is as follow:

In some instances you will find that the output it too large to fit in one line of output. In this instance, you can output the result to a .CSV file. This will give you the ability to open the file in excel (or another spreadsheet application) with all the information visible.

This piece of code will definitely help in reducing the amount of code you type, and doesn’t take that long to learn how to use it effectively.

You can find more information on splatting by googling “powershell hashtables”.