I cannot find a DataSource to build off to grab the uptime of our vCenter appliances.
I am able to get ESXi hosts uptimes with:
import com.vmware.vim25.mo.*;<br/>import com.santaba.agent.groovyapi.esx.ESX;<br/><br/>def host = hostProps.get("system.hostname");<br/>def user = hostProps.get("esx.user");<br/>def pass = hostProps.get("esx.pass");<br/>def addr = hostProps.get("esx.url") ?: "https://${host}/sdk";<br/><br/>def svc = new ESX();<br/>svc.open(addr, user, pass, 10 * 1000); // Timeout in 10 seconds<br/><br/>def rootFolder = svc.getServiceInstance().getRootFolder();<br/><br/>def hosts = new InventoryNavigator(rootFolder).searchManagedEntities("HostSystem");<br/><br/>hosts.each<br/>{<br/> esx -><br/> def uptimeinSeconds = esx.summary.quickStats;<br/> println "UpTimeInSeconds=${uptimeinSeconds.uptime}";<br/>}<br/><br/>return 0;
but cannot seem to adapt this for vCenter Appliances.
Any help would be appreciated!
Mike Moniz
It looks like the API might be https://developer.vmware.com/apis/vsphere-automation/latest/appliance/api/appliance/system/uptime/get/ , but I did not test. You might want to base it on one of the existing VMware_VCSA_* DataSources as I don’t think the ESX groovy module support vcsa api calls.