Find the vCenter VM IP, name and host name.
search cancel

Find the vCenter VM IP, name and host name.

book

Article ID: 325180

calendar_today

Updated On:

Products

VMware vCenter Server 7.0 VMware vCenter Server 8.0

Issue/Introduction

Symptoms:
In certain situations, it becomes necessary to determine the ESXi host where the vCenter VM is running. This information can be crucial for troubleshooting, maintenance, or resource management purposes. Here are common scenarios where this knowledge is needed:

Resource Allocation: To understand the resource consumption of the vCenter VM, it's helpful to know which ESXi host it resides on.
Migration Planning: Before migrating the vCenter VM, it's important to identify its current host to plan the migration process efficiently.
Performance Monitoring: Monitoring the performance of the vCenter VM can be more insightful when correlated with the performance of its host.
Snapshot: To take a snapshot of the vCenter VM from the Host UI.
Troubleshooting: When troubleshooting issues related to the vCenter VM, knowing its host can help narrow down the scope of potential issues.

Environment

VMware vCenter Server

Resolution

To find the ESXi host on which the vCenter VM is currently residing and the vCenter VM name, you can download the VCVM.sh script attached to this KB article and run this on the vCenter SSH.

Steps to execute:

  • Connect the vCenter through SSH.
  • Upload the VCVM.sh script to the /var/tmp folder.
  • Provide executable permission to the script file.
chmod +x VCVM.sh
  • Run the script
./VCVM.sh

The output will be the Host on which the vCenter VM resides.

Or run vi VCVM.sh. Paste the output of the script file manually to this file. Provide executable permissions to the file and run the file through ./VCVM.sh

vi VCVM.sh && chmod +x VCVM.sh

Expected Output:

# ./vcvm.sh
VCIP: X.X.X.X
VCVM_Name:  <vCenter Hostname>
VCVM_Host:  <hostname on which the VCSA VM is running>

Additional Information

If  you get this error -bash: ./VCVM.sh: /bin/bash^M: bad interpreter: No such file or directory
To fix run:

sed -i -e 's/\r$//' VCVM.sh

 

For finding the host on which any other VM on the vCenters is running, run the below command:

<Using VM FQDN:>
/opt/vmware/vpostgres/current/bin/psql -d VCDB -U postgres -t -c "select dns_name from vpx_host where id = (select host_id from vpx_vm where dns_name= '<VM_FQDN>');"

<Using VM IP:>
/opt/vmware/vpostgres/current/bin/psql -d VCDB -U postgres -t -c "select dns_name from vpx_host where id = (select host_id from vpx_vm where ip_address= '<VM_IP>');"

Attachments

VCVM.sh get_app