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.
VMware vCenter Server
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:
chmod +x VCVM.sh
./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.shVCIP: X.X.X.XVCVM_Name: <vCenter Hostname>VCVM_Host: <hostname on which the VCSA VM is running>
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>');"