One of the rich aspects of VMware vSphere is the Managed Object Reference architecture, or MoRef. This is a way that items are visible in the vSphere environment so among other things, the name may change but we can still refer to the same VM. Many programs that interact with vSphere latch on the MoRef architecture, so as to not confuse one VM from another as well.There is a way to grab a quick view of the console of a VM using the MoRef architecture, and what's best is it is quite easy to do. The hardest part is finding the VM's ID on the ESXi host. There are two ways to do this. The first is the VMware way, which uses the HTTP browser into the host's object inventory. VMware KB 1017126 explains how to do this. The simple premise here is to browse into the host, and report all the VMs running on the host by what makes up the contents of the main host folder, then datastore and finally the list of VMs on that datastore. Figure A shows VMs running on my selected datastore that I did this experiment on in my lab:
Click to enlarge.The highlighted section indicates the ID for each VM. 2592 in the example is a Linux firewall that I'm running (Untangle). When I go to https://192.168.1.4/screen?id=2592 (Where 192.168.1.4 is the ESXi host), I'm able to quickly get the console status of the VM. This is shown in Figure B below:
Click to enlarge.Getting the VM's MoRef ID will be the hard part, but aside from browsing the MoRef inventory as shown in the KB above, you can also use SSH. Now, VMware wants to avoid SSH, but I'm lazy and it's a sweet one-liner, so I will probably keep finding VM IDs this way until SSH is gone from the host. The simple SSH command:
vim-cmd vmsvc/getallvmswill report all VMs with their IDs in a quick result set, regardless of datastore. Figure C below runs this command and the Untangle VM is shown as 2592, and all other VMs are shown also.
Click to enlarge.VM ID 2656 is a Windows VM, highlighted to show its result in the SSH command. Opening up the same URL with 2656 provided will show that VM's console status as well. This is shown in Figure D below:
This is a quite handy technique that may be beneficial to small environments or development situations. This trick doesn't exactly work the same way when vCenter is in place as the ‘owner' of the VM is still the host. Aside from finding the VM ID, this is a pretty nifty tip and many thanks to Anton Gostev for pointing this out to me!
Do you see this as useful to take a quick console shot of a VM? If so, how would you use it? Share your comments below.
Rick Vanover is a software strategy specialist for Veeam Software, based in Columbus, Ohio. Rick has years of IT experience and focuses on virtualization, Windows-based server administration, and system hardware.