Still Life

A Series of Mental Snapshots

Posts Tagged ‘shot’

Taking Screenshots From VMWare ESX Command line using vmdumper

Posted by Steve on June 11, 2008

VMdumper is something that apparently does not exist, well according to google at least. But fortunately,  I have learned of, and now am sharing some of the usefulness of this little tool in VMware.

The main thing that I have used it for is to take a .png screenshot of a virtual machine on that ESX server. This has a whole bevy of usefulness. Specifically for me, I was trying to catch a specific error that was occurring when my VMs were booting in a specific way and that left no trace if itself in any log files, the only way to know it happens is to look at the screen, thus a screenshot was in order!

The vmdumper command can be accessed on your ESX server by connecting via SSH and navigating to the following directory:

From here you can run ./vmdumper which will provide the following output:
./vmdumper: [options] <world id|–listVM> <unsync|sync|vmx|vmx_force|samples_on|samples_off|nmi|screenshot|backtrace>
-f: ignore vsi version check
-h: print friendly help message
-l: print information about running VMs

These are the options available to you using this VMdumper tool! So moving on, you know where the tool is, and you want to take a screenshot! To take a screen shot, you need to know the VMID. The VMID is unfortunately dynamic, but have no fear another command is here. The vmdumper will list all of the information you need with the following command:
/usr/lib/vmware/bin/vmdumper –listVM

This will list out all of the VMs that are on your ESX server in an uglyish format, but it is pretty simple to extract the desired information, that is the VMID with the following command:
VMID=`/usr/lib/vmware/bin/vmdumper –listVM | grep VMsDisplayName | awk ‘/vmid/ {print $1}’ | awk -F= ‘ {print $2}’`

Basically what is happening is that this command is that the list of VMS is piped out and the grep command finds the line that has the desired VMID with the use of the VM’s display name. The first awk command pulls out the whole vmid filed, and the second awk pulls just the vmid number, and finally it is assigned to the variable VMID!

Now the screenshot command can be done from any directory, you just need to execute the following command:
/usr/lib/vmware/bin/vmdumper VMID screenshot

The screenshot will be deposited where that VMs .vmx file is located and will be labeled vmdumper.png!

There you have it, a screenshot of a running VM from the command line that you can run from a bash shell script! One final time here are the commands you’ll need to run.
VMID=`/usr/lib/vmware/bin/vmdumper –listVM | grep ${VMS[counter]} | awk ‘/vmid/ {print $1}’ | awk -F= ‘ {print $2}’` #Gets the VMID
/usr/lib/vmware/bin/vmdumper $VMID screenshot #take the screenshot

Hopefully this helps someone out, I know it made my day a lot easier!


Post Script:
This is the first time I have posted a sort of How To, or purely information related post, feel free to drop me a line on the formatting or if there is any info that should be included that is not!


Posted in ESX Scripting | Tagged: , , , , , , , , , | 2 Comments »