No issue was found. A script was run (below) to count the number of ESX hosts and VMs that were not blacklisted/license control. The results matched the License Usage dashboard.
License usage data will not update immediately after changes to Black List or License Control. The FE Licenses Overview dashboard refreshes hourly.
The following script can be used to display VMWare Agent License usage
import org.apache.log4j.Logger;
import com.quest.nitro.service.sl.interfaces.data.ObservationQuery.RetrievalType;
import com.quest.nitro.service.sl.interfaces.topology.TopologyTypeNotFoundException;
LOG = Logger.getLogger("VMware cartridge calculate VMware hosts usage");
def sb=new StringBuffer()
def vmwareUsage = 0;
def ts = server["TopologyService"];
ds = server.DataService;
currentDate = new Date();
endTime = currentDate.getTime()
Calendar c = Calendar.getInstance();
c.setTime(currentDate);
c.add(Calendar.HOUR, -1);
startTime = c.getTime().getTime();
try {
def allEsxs = ts.getObjectsOfType(ts.getType("VMWESXServer"));
sb.append("----------------All esxs befroe filter: " + allEsxs.size() + "------------------").append("\n");
for (esx in allEsxs) {
sb.append("##ESX host before filter[isInLicenseControl: ").append(esx?.isInLicenseControl).append("]").append("[isInBlackList: ").append(esx?.isInBlackList).append("]").append("[isDeleted: ").append(esx?.isDeleted).append("]: ").append(esx?.name).append("\n");
}
sb.append("------------------------------print all esxs end--------------------------------").append("\n");
def allVms = ts.getObjectsOfType(ts.getType("VMWVirtualMachine"));
sb.append("----------------All VMs befroe filter: " + allVms.size() + "------------------").append("\n");
for (vm in allVms) {
sb.append("##virtual machine before filter[isTemplate: ").append(vm?.isTemplate).append("]").append("[isInBlackList: ").append(vm?.isInBlackList).append("]").append("[isDeleted: ").append(vm?.isDeleted).append("]: ").append(vm?.name).append("\n");
}
sb.append("------------------------------print all esxs end--------------------------------").append("\n");
def licenseControlEsxs = allEsxs.findAll{it?.isInLicenseControl};
sb.append("----------------Esxs in license control: " + licenseControlEsxs.size() + "------------------").append("\n");
for(lcEsx in licenseControlEsxs) {
def vmsInLC = lcEsx?.virtualMachines;
sb.append("**********esx in license control: "+ lcEsx?.name + " -> " + vmsInLC?.size() + "VMs" + "************").append("\n");
for (vm in vmsInLC) {
sb.append("##virtual machine in license control[isTemplate: ").append(vm?.isTemplate).append("]: ").append(vm?.name).append("\n");
}
sb.append("******************************************************** ").append("\n");
}
sb.append("----------------------------print esxs in license control end-------------------------------").append("\n");
licenseControlEsxs.each{allVms.removeAll(it?.virtualMachines)};
allEsxs.removeAll(licenseControlEsxs);
sb.append("##all esx after filter licenseControlEsxs:" + allEsxs.size()).append("\n")
sb.append("##all Vms after filter licenseControlEsxs:" + allVms.size()).append("\n")
allEsxs = allEsxs.findAll{!it?.isInBlackList && !it.isDeleted};
allVms = allVms.findAll{!it?.isInBlackList && !it?.isDeleted};
sb.append("##all esx after filter blacklist and deleted:" + allEsxs.size()).append("\n")
sb.append("##all Vms after filter blacklist and deleted:" + allVms.size()).append("\n")
def fEsxs = getCountOfPoweredOnVmOrHost(allEsxs, "powerState");
sb.append("---------------------All esxs after filter: " + fEsxs?.size() + "-----------------------").append("\n");
for (esx in fEsxs) {
sb.append("##esx host after filter: " + esx?.name).append("\n");
}
sb.append("------------------------------print final valid esxs end--------------------------------").append("\n");
def fVms = getCountOfPoweredOnVmOrHost(allVms, "vmState");
sb.append("---------------------All VMs after filter: " + fVms?.size() + "-----------------------").append("\n");
for (vm in fVms) {
sb.append("##virtual machine after filter[isTemplate: ").append(vm?.isTemplate).append("]: ").append(vm?.name).append("\n");
}
sb.append("------------------------------print final valid vms end--------------------------------").append("\n");
sb.append("final license usage for vmware is: ").append(fEsxs?.size() + fVms?.size()).append("\n");
} catch (TopologyTypeNotFoundException ex) {
} catch (Exception e) {
LOG.warn("Failed to calculate VMware hosts usage.", e);
}
return sb.toString();
//get all monitoried objes size
def getCountOfPoweredOnVmOrHost(objs, obs) {
def validHosts = [];
def result = batchQueryVmMetrics(objs, obs);
for (obj in objs) {
def stateValues = result.getLastNValues(obj, obs);
if (stateValues && stateValues.size() > 0) {
validHosts.add(obj);
}
}
return validHosts;
}
//use the batch query to retrieve the state updated in one day
def batchQueryVmMetrics(objs, obs) {
query = ds.createObservationQuery();
query.setStartTime(startTime);
query.setEndTime(endTime);
query.setRetrievalType(RetrievalType.LAST_N);
query.setNumberOfValues(1);
query.include(objs, obs);
return ds.performQuery(query);
}
© ALL RIGHTS RESERVED. Feedback Terms of Use Privacy Cookie Preference Center