VMware Cloud Community
riteshsakhuja
Contributor
Contributor

How to find the host on which VM is running ?

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

Reply
0 Kudos
7 Replies
Troy_Clavell
Immortal
Immortal

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

Reply
0 Kudos
ChrisDearden
Expert
Expert

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 )

If this post has been useful , please consider awarding points. @chrisdearden http://jfvi.co.uk http://vsoup.net
Reply
0 Kudos
HannaL
Enthusiast
Enthusiast

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.

Hope that helps, Hanna --- BSCS, VCP2, VCP VI3, VCP vSphere, VCP 5 https://www.ibm.com/developerworks/mydeveloperworks/blogs/vmware-support-ibm
Reply
0 Kudos
AndreTheGiant
Immortal
Immortal

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

Andre

Andrew | http://about.me/amauro | http://vinfrastructure.it/ | @Andrea_Mauro
Reply
0 Kudos
VMmatty
Virtuoso
Virtuoso

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

Matt | http://www.thelowercasew.com | @mattliebowitz
Reply
0 Kudos
logiboy123
Expert
Expert

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

Reply
0 Kudos
dcompa_841
Contributor
Contributor

Maybe the command should be

get-vm "VM Name" | get-vmhost