@Override public ComputeResourceSummary getHyperHostHardwareSummary() throws Exception { if (s_logger.isTraceEnabled()) s_logger.trace("vCenter API trace - getHyperHostHardwareSummary(). target MOR: " + _mor.getValue()); // // This is to adopt the model when using Cluster as a big host while ComputeResourceSummary is used // directly from VMware resource pool // // When we break cluster hosts into individual hosts used in our resource allocator, // we will have to populate ComputeResourceSummary by ourselves here // HostHardwareSummary hardwareSummary = getHostHardwareSummary(); ComputeResourceSummary resourceSummary = new ComputeResourceSummary(); // TODO: not sure how hyper-threading is counted in VMware resourceSummary.setNumCpuCores(hardwareSummary.getNumCpuCores()); // Note: memory here is in Byte unit resourceSummary.setTotalMemory(hardwareSummary.getMemorySize()); // Total CPU is based on (# of cores) x Mhz int totalCpu = hardwareSummary.getCpuMhz() * hardwareSummary.getNumCpuCores(); resourceSummary.setTotalCpu(totalCpu); HostListSummaryQuickStats stats = getHostQuickStats(); if (stats.getOverallCpuUsage() == null || stats.getOverallMemoryUsage() == null) throw new Exception("Unable to get valid overal CPU/Memory usage data, host may be disconnected"); resourceSummary.setEffectiveCpu(totalCpu - stats.getOverallCpuUsage()); // Note effective memory is in MB unit resourceSummary.setEffectiveMemory(hardwareSummary.getMemorySize() / (1024 * 1024) - stats.getOverallMemoryUsage()); if (s_logger.isTraceEnabled()) s_logger.trace("vCenter API trace - getHyperHostHardwareSummary() done"); return resourceSummary; }
public HostListSummaryQuickStats getHostQuickStats() throws Exception { return (HostListSummaryQuickStats)_context.getVimClient().getDynamicProperty(_mor, "summary.quickStats"); }
public void execute() { try { for (final ManagedEntity managedEntity : hostEntities) { executorService.submit(new Runnable() { public void run() { HostSystem hostSystem = (HostSystem) managedEntity; HostListSummaryQuickStats hostStats = hostSystem.getSummary().getQuickStats(); long totalHz = hostSystem.getHardware().getCpuInfo().getHz(); short numCpuCores = hostSystem.getHardware().getCpuInfo().getNumCpuCores(); String hostName = managedEntity.getName(); String replacedHostName = applyReplacers(hostName, replacers); String baseMetricName = "HostSystem" + "|" + replacedHostName; printMetric(baseMetricName + "|Distributed CPU Fairness", hostStats.getDistributedCpuFairness()); printMetric(baseMetricName + "|Distributed Memory Fairness", hostStats.getDistributedMemoryFairness()); Integer overallCpuUsageinMHz = hostStats.getOverallCpuUsage(); printMetric(baseMetricName + "|Overall CPU Usage", overallCpuUsageinMHz); double totalCapacityMHz = totalHz * numCpuCores * 0.000001; double cpuUsagePercent = (overallCpuUsageinMHz * 100) / totalCapacityMHz; printMetric(baseMetricName + "|Overall CPU Usage %", Math.round(cpuUsagePercent)); printMetric(baseMetricName + "|Overall Memory Usage", hostStats.getOverallMemoryUsage()); printMetric(baseMetricName + "|Up Time", hostStats.getUptime()); HostHardwareInfo hardwareInfo = hostSystem.getHardware(); printMetric(baseMetricName + "|Memory Size", hardwareInfo.getMemorySize()); printMetric(baseMetricName + "|CPU Cores", hardwareInfo.getCpuInfo().getNumCpuCores()); List<VirtualMachine> vms = getVMs(hostSystem); vmMetricCollector.addVMs(vms, baseMetricName); hostCountDown.countDown(); } }); } } finally { if (executorService != null && !executorService.isShutdown()) { executorService.shutdown(); } } }