• 0

Capture vCenter Versions



I need to be able to report on vCenter versions.  Today that is only captured when SNMP is configured on the vCenter Appliance.  I need another way to populate this for all of the VC's in my environment as many of them are not configured with SNMP just esx.user and .pass.

Anyone out there with a groovy script that would do this?  I'm stuck reading the output using the first link below.  I would like to just read the value from one of the properties on the page and set it as a property on my device.

This page displays the info nicely in xml - https://${host}/mob/?moid=ServiceInstance&doPath=content%2eabout

This one also does too via the API - https://vcenter.fqdn/rest/appliance/system/version

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

I figured this out and went a different route.  Here is what I'm using.  Works perfectly on all VC's in our environment, both windows and appliance.


import com.santaba.agent.groovyapi.esx.ESX
import com.vmware.vim25.mo.*

def host = hostProps.get("system.hostname")
def user = hostProps.get("esx.user")
def pass = hostProps.get("esx.pass")
def addr = hostProps.get("esx.url") ?: "https://${host}/sdk"

def svc = new ESX()
svc.open(addr, user, pass, 10 * 1000) // timeout in 10 seconds

def si = svc.getServiceInstance()
def rootFolder = si.getRootFolder()

// Get resource
HostSystem esxHost = new InventoryNavigator(rootFolder).searchManagedEntities("HostSystem").first()

println "auto.vcenter.fullname=${si.aboutInfo.fullName}"
println "auto.vcenter.build=${si.aboutInfo.build}"
println "auto.vcenter.licenseproductname=${si.aboutInfo.licenseProductName}"
println "auto.vcenter.os.type=${si.aboutInfo.osType}"
println "auto.vcenter.product.line=${si.aboutInfo.productLineId}"
println "auto.vcenter.version=${si.aboutInfo.version}"

return 0

Edited by Shack
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.