I'm trying to figure out a way to retrieve only the system information from the ESXI so I can retrieve the service tag or a serial number of the hardware.
I'm already using python and have made the connection. I just don't know how to set the fields to print out the service tag or serial number. Currently using pyvmomi
and pyvim
.
You're going to need to send over or otherwise execute a one line shell script to run the esxcfg-info command and grep for a line containing "Serial N". Then you'll have to use cut or awk to extract the portion of the line that you want. As with any such project you'll have to experiment a bit to find what works on your particular version of ESXi but it will likely be something like "esxcfg-info | grep 'Serial N'". Note that ESXi doesn't support bash, only ash, so if you send over a shell script make it a Bourne shell script (sh).
For a more detailed discussion you can refer to https://communities.vmware.com/t5/ESXi-Discussions/How-can-I-find-the-serial-number-of-my-Hardware/td-p/1323280. Generally the VMware communities discussions stick around for many years because VMware's customers are large enterprises who expect to find answers rather than dead links but it may eventually move. If so you could do worse than to search there for an answer.
Lastly, the aforementioned link noted that if you have a very old version of ESXi (e.g., 4.0 or older) you might be able to use "smbiosDump" but you'll have to tinker around to figure out what to grep for. It's been over a decade since I saw such an old system so I can't provide more guidance.