VMware vSphere

 View Only
  • 1.  How to find the host on which VM is running ?

    Posted Apr 25, 2011 08:03 PM

    Hello All,

    How to find the ESX host running a VM guest by using the command line from within the guest

    for example

    i we have 3 ESX hosts ESX1 ESX2 ESX3

    ESX1

    vm1

    vm2

    ESX2

    vm3

    vm4

    ESX3

    vm5

    vm6

    is there a command that can be used from within vm3 to find it's  ESX host

    Regards

    Ritesh



  • 2.  RE: How to find the host on which VM is running ?

    Posted Apr 25, 2011 08:12 PM

    the guest has no idea of the underlying hardware(ESX), so you won't be able to get this information from the guest.



  • 3.  RE: How to find the host on which VM is running ?

    Posted Apr 27, 2011 02:15 PM

    Guessing there isn't anything you can do via VMware Tools ?

    If you pulled info from vCenter into a different CMDB , a guest could query itself that way ( to update a BGinfo Script - with the caveat that in a more fluid DRS environment , that may not always be 100% up to date )



  • 4.  RE: How to find the host on which VM is running ?

    Posted Apr 29, 2011 04:06 AM

    no way from the guest.  Instead look at the summary tab when the VM is highlighted and it will tell you which ESX host that VM is registered on.



  • 5.  RE: How to find the host on which VM is running ?

    Posted Apr 29, 2011 04:53 AM

    To do this kind of query you need some scripting to interact with the virtual environment.

    Andre



  • 6.  RE: How to find the host on which VM is running ?

    Posted May 01, 2011 06:36 PM

    Check out this blog post for a set of tools/scripts you can run to accomplish this.  It assigns a variable to the VM itself rather than something you run from within the guest, but it accomplishes the same goal.

    http://onebyte8bits.com/?p=41

    Matt

    http://www.thelowercasew.com



  • 7.  RE: How to find the host on which VM is running ?

    Posted May 02, 2011 02:42 AM

    Why not just install PowerCLI and use the VMware commands to return the information you are after?

    http://www.vmware.com/support/developer/PowerCLI/index.html

    Once you have this installed you would then

    Connect-VIServer vCenterServerName

    Get-VMHost "ESXiServer01" | Get-VM

    This would return all VM's on the ESXi host ESXiServer01.

    Regards,

    Paul



  • 8.  RE: How to find the host on which VM is running ?

    Posted Jan 20, 2022 05:20 PM

    Maybe the command should be

    get-vm "VM Name" | get-vmhost