vmware / open-vm-tools

Official repository of VMware open-vm-tools project
http://sourceforge.net/projects/open-vm-tools/
2.23k stars 425 forks source link

Any way to retrieve the vc.uuid from vmtools ? #734

Open gits68 opened 1 month ago

gits68 commented 1 month ago

Is your feature request related to a problem? Please describe.

May help to autoconfigure zabbix client while using the "VMWare Guest" Template which identifies hosts using their vc.uuid instead of editing the configuration file on every hosts.

# grep ^HostnameItem= /etc/zabbix/zabbix_agent*.conf
HostnameItem=system.run[vmware-toolbox-cmd stat raw text session | awk '/vc.uuid/{print $NF}']

or HostnameItem=system.run[vmware-toolbox-cmd stat raw json session | jq -r '."vc.uuid"'

Describe the solution you'd like

# vmware-toolbox-cmd stat raw text session
session = -14796381390335328
uptime = 338588675128
version = VMware ESX 7.0.3 build-23307199
provider =
uuid.bios = 42 20 6f a4 2a 8a 54 5b-74 7a 05 5f 1f 22 d0 ce

+ vc.uuid = 5020efdf-1593-a8ef-27fb-2852a1b10fc2 or vc.uuid = 50 20 ef df 15 93 a8 ef 27 fb 28 52 a1 b1 0f c2

Describe alternatives you've considered

Fill guestInfo.vc.uuid the same way guestInfo.detailed.data if filled

Additional context

dmidecode doesn't help, only uuid.bios is returned

johnwvmw commented 1 month ago

I have filed an enhancement bug to provide a means to obtain the vm instance id (vc.uuid) from within a running guest VM.

@gits68 Could you provide more details how the vc.uuid would be used in the zabbix agent config file and what benefits are to be gained over the default "system.hostname". A better idea how this woulc or could be used would help add weight to the enhancement request.

Thanks

gits68 commented 4 weeks ago

Hi,

it depends on the template used, "vmware" or "vmware fqdn", the former historically uses vc.uuid to identify hosts while the later uses the hostname. The format used by zabix is 5020efdf-1593-a8ef-27fb-2852a1b10fc2, probably the one returned by the vmware api.

Usage examples

Case vmware template: Hostname=5020efdf-1593-a8ef-27fb-2852a1b10fc2 Or vc.uuid if it would be accessible some way

Hostname=

[vmware-toolbox-cmd stat raw text session | awk '/vc.uuid/{print $NF}']

Case vmware fqdn template: Hostname=somename Or

Hostname=

HostnameItem=system.hostname

PS: Don't remember, but possibly returned the system.hostname by default if all commented

Hostname=

HostnameItem=

Regards