Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
    
Is there a reason you wouldn't just take a look in vCenter? If you click on the server, the host is listed in the Status tab... –  Jes Sep 16 '10 at 13:38
    
@Jes - I'm looking to do this from a script –  warren Sep 16 '10 at 15:07
    
Why would you want to do that? Just curious. –  ThatGraemeGuy Sep 16 '10 at 15:51
    
in the context of a large, managed environment, it would be nice to be able to run a script on some schedule that would report to syslog or similar the host that it is resident upon –  warren Sep 17 '10 at 16:07
    
@Graeme Donaldson - to expand on my previous comment, when VMs move between hosts due to vMotion or because migration/upgrading of the underlying hardware of hypervisor is coming along, knowing where a given VM is currently running would be nice... but it appears this is [sadly] non-trivial (at least for now) –  warren Oct 20 '10 at 15:21

3 Answers 3

up vote 1 down vote accepted

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

share|improve this answer
    
Which powershell scripts in particular? As it stands this answer is pretty poor –  Mark Henderson Jun 12 at 1:50

You can't do it without first editing the VMX file.

Here is the stackoverflow answer to the same question

share|improve this answer
    
that's for Workstation, and I'm looking at this form an ESX/ESXi perspective (clarifying my question) –  warren Sep 16 '10 at 15:08
2  
The same limitation applies - getting information about the Hypervisor from within a guest is generally not easy, unless you already know the identity of the Hypervisor and can talk to it over the network. –  Helvick Sep 16 '10 at 15:26
    
It doesn't matter if its workstation, ESX, or any other VMware product. It's a security setting that has to be disabled. –  JakeRobinson Sep 16 '10 at 18:59

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.

share|improve this answer
1  
These are pretty kludgey solutions and the later assumes you know who the host is, which is exactly what is being looked for. If you'd looked at previous answers you'd see that the ESX host provides an API that you can connect to that introduces itself. It's always best to use provided features before hacking your own! –  Caleb Oct 22 '10 at 8:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.