VMware {code} Community
rwiltshire
Contributor
Contributor
Jump to solution

Capture host serial number in VC database

Hi All,

Has anyone written anything to grab the host machine serial number and store it in the VC database? We want to hook the VC to our Asset Mgmt tool but require the machine serial number. This should be fairly simple as it is easy enough to call up via sysytem commands on the box itself.

Thanks,

Ryan

Reply
0 Kudos
1 Solution

Accepted Solutions
lamw
Community Manager
Community Manager
Jump to solution

If you're referring to the hardware Asset Tag, yes this is extractable and has to be set. Take a look at HostHardwareSummary http://www.vmware.com/support/developer/vc-sdk/visdk25pubs/ReferenceGuide/vim.host.Summary.HardwareS... you'll also be able to extract other details regarding the hardware and depending on vendor, the information will vary within the otherIdentifyingInfo[] array, I know on HP Hardware on the bl460c, only the Asset Tag is available but again the available data will vary with vendor and some testing will tell you what you can extract.

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

If you find this information useful, please award points for "correct" or "helpful".

View solution in original post

Reply
0 Kudos
4 Replies
lamw
Community Manager
Community Manager
Jump to solution

If you're referring to the hardware Asset Tag, yes this is extractable and has to be set. Take a look at HostHardwareSummary http://www.vmware.com/support/developer/vc-sdk/visdk25pubs/ReferenceGuide/vim.host.Summary.HardwareS... you'll also be able to extract other details regarding the hardware and depending on vendor, the information will vary within the otherIdentifyingInfo[] array, I know on HP Hardware on the bl460c, only the Asset Tag is available but again the available data will vary with vendor and some testing will tell you what you can extract.

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

If you find this information useful, please award points for "correct" or "helpful".

Reply
0 Kudos
rwiltshire
Contributor
Contributor
Jump to solution

Thanks!

That is exactly what I am looking for!

Cheers,

Ryan

Reply
0 Kudos
shuisman
Contributor
Contributor
Jump to solution

Hi Iamw,

I'm relatively new to polling this type of information so please excuse my ignorance. How would I go about polling this information via a script? This info is coming from the Virtualcenter database I think so is it possible to write a query to poll this information from the VC database?

Thanks,

Scott

Reply
0 Kudos
lamw
Community Manager
Community Manager
Jump to solution

The information you're looking for is implemented in this VMware Health Check script: http://communities.vmware.com/docs/DOC-9420 take a look on how the data is extracted, here is a quick snippet:

if($local_host->summary->hardware->otherIdentifyingInfo) {
	my $add_info = $local_host->summary->hardware->otherIdentifyingInfo;
	foreach (@$add_info) {
		$additional_vendor_info .= $_->identifierType->key.": ".$_->identifierValue." ";
	}
	if($additional_vendor_info eq '') {
		$additional_vendor_info = "UNKNOWN";
	}
}

The script above uses the VI Perl Toolkit soon to be re-dubbed vSphere SDK for Perl and you can install the toolkit on either Windows/Linux or use the VMware VIMA/vMA virtual appliance to execute, find more information on the VMTN document.

I'm not 100% sure if the asset tag is stored in the VCDB, it potentially can but it's not recommended that you go and query the VCDB, the schema can change at will and it's better by going through the VI API. If you're more comfortable in a Windows environment, you can also take a look at Powershell/PowerCLI, it has similar hooks into the VI API to be able to extract the same piece of information.

Hopefully this will get you started and also a great document to start with if you're looking to implement this in Perl but the concepts applies to any of the scripting/programming languages: http://www.vmware.com/support/developer/viperltoolkit/doc/perl_toolkit_guide_idx.html

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

If you find this information useful, please award points for "correct" or "helpful".

Reply
0 Kudos