in a rule, I generally do something like this:  ds = server.DataService  cluster = scope; esxHosts = cluster.get("esxServers");  Integer vCPUCount = 0;  for (esxHost in esxHosts) {  VMs = esxHost.get("virtualMachines"); for (VM in VMs) {    state = ds.retrieveLatestValue(VM,'vmState').getValue()   if (state == 'poweredOn') {     vCPUs = ds.retrieveLatestValue(VM.cpus,'cores').getValue().getAvg()    vCPUCount += vCPUs;   } } }  return vCPUCount;
I am trying to set up a Rule that set an Alarm when powered-on vCPUs in a cluster exceed a certain level.  The following function works just fine when I am creating a Dashboard, but when I try to port it into a Rule, I am unable to get values out of the VM metrics.  The "state" variable is assigned Null.  cluster = args['cluster']; esxHosts = cluster.get("esxServers");  Integer vCPUCount = 0;  for (esxHost in esxHosts) {   VMs = esxHost.get("virtualMachines");  for (VM in VMs) {    state = VM.get("vmState/current/value");   if (state == 'poweredOn') {     vCPUs = VM.get("cpus/cores/current/average");    vCPUCount += vCPUs;   }  } }  return vCPUCount;  I would appreciate any help you can provide!
Alarming on powered-on vCPUs at Cluster Level