Is it possible to determine the name of the VMware host (ESX or ESXi) that my guest resides in, from within the guest itself?
I would expect this to be possible via VMware Tools, but am not sure where to look.
Is it possible to determine the name of the VMware host (ESX or ESXi) that my guest resides in, from within the guest itself?
I would expect this to be possible via VMware Tools, but am not sure where to look.
You can't do it without first editing the VMX file.
Here is the stackoverflow answer to the same question
There are a few powershell scripts that will let you do this. Alternatively.. open http://yourESXaddress and check out the api For a quick export that you could parse by script use your script to pull the contents of http://ESXIPAddress/mob/ which lists the resources managed by that ESX host
I think there are probably any number of ways to do this, and can think of two off the bat: One would be to install ViX in the guest, connect to the host without specifying the hostname, (Google "ViX reference" then see "common tasks") then use Vix_CopyFileFromHostToGuest() to copy the file /etc/vmware/esx.conf. Another would be to create some sort of network connection from the guest to the host (I used ssh but if you don't know the hostname or IP you could still do the ViX connection thing as above and dispatch a job that takes a while) and then say "netstat -a" in the guest. The netstat output will contain the hostname, if it is resolvable.
From a Linux guest, network routing information seems to yield the host information:
netif=$(arp -a | grep gateway | awk '{print $7}') SERVERIP=$(routel | grep $netif | grep -v gateway | grep -v default | grep -v broadcast | grep local | grep host | awk '{print $1}') VI_SERVER=$(host $SERVERIP | awk '{print $5}' | awk -F. '{print $1}') echo "This VM host is $SERVERIP, $VI_SERVER"
Seems to give the correct VM host name and IP address for several hosts with Linux VMs.