Datasource to get Uptime of VMWare vCenter Appliance

  • 22 March 2023
  • 1 reply

Userlevel 2

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.santaba.agent.groovyapi.esx.ESX;

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();, user, pass, 10 * 1000); // Timeout in 10 seconds

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

def hosts = new InventoryNavigator(rootFolder).searchManagedEntities("HostSystem");

esx ->
def uptimeinSeconds = esx.summary.quickStats;
println "UpTimeInSeconds=${uptimeinSeconds.uptime}";

return 0;

but cannot seem to adapt this for vCenter Appliances.


Any help would be appreciated!

1 reply

Userlevel 6
Badge +11

It looks like the API might be , 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.