protected GetHostStatsAnswer() { hostStats = new HostStatsEntry(); }
protected Answer execute(GetHostStatsCommand cmd) { try { Map<String, String> res = OvmHost.getPerformanceStats(_conn, _publicNetworkName); Double cpuUtil = Double.parseDouble(res.get("cpuUtil")); Double rxBytes = Double.parseDouble(res.get("rxBytes")); Double txBytes = Double.parseDouble(res.get("txBytes")); Double totalMemory = Double.parseDouble(res.get("totalMemory")); Double freeMemory = Double.parseDouble(res.get("freeMemory")); HostStatsEntry hostStats = new HostStatsEntry(cmd.getHostId(), cpuUtil, rxBytes, txBytes, "host", totalMemory, freeMemory, 0, 0); return new GetHostStatsAnswer(cmd, hostStats); } catch (Exception e) { s_logger.debug("Get host stats of " + cmd.getHostName() + " failed", e); return new Answer(cmd, false, e.getMessage()); } }
public Answer execute(GetHostStatsCommand cmd) { try { CloudstackPlugin cSp = new CloudstackPlugin(c); Map<String, String> stats = cSp.ovsDom0Stats(config .getAgentPublicNetworkName()); Double cpuUtil = Double.parseDouble(stats.get("cpu")); Double rxBytes = Double.parseDouble(stats.get("rx")); Double txBytes = Double.parseDouble(stats.get("tx")); Double totalMemory = Double.parseDouble(stats.get("total")); Double freeMemory = Double.parseDouble(stats.get("free")); HostStatsEntry hostStats = new HostStatsEntry(cmd.getHostId(), cpuUtil, rxBytes, txBytes, "host", totalMemory, freeMemory, 0, 0); return new GetHostStatsAnswer(cmd, hostStats); } catch (Exception e) { LOGGER.debug("Unable to get host stats for: " + cmd.getHostName(), e); return new Answer(cmd, false, e.getMessage()); } }
public HostStatsEntry getHostStats(final Connection conn, final GetHostStatsCommand cmd, final String hostGuid, final long hostId) { final HostStatsEntry hostStats = new HostStatsEntry(hostId, 0, 0, 0, "host", 0, 0, 0, 0); final Object[] rrdData = getRRDData(conn, 1); // call rrd method with 1
public GetHostStatsAnswer(GetHostStatsCommand cmd, double cpuUtilization, double freeMemoryKBs, double totalMemoryKBs, double networkReadKBs, double networkWriteKBs, String entityType) { super(cmd); hostStats = new HostStatsEntry(); hostStats.setCpuUtilization(cpuUtilization); hostStats.setFreeMemoryKBs(freeMemoryKBs); hostStats.setTotalMemoryKBs(totalMemoryKBs); hostStats.setNetworkReadKBs(networkReadKBs); hostStats.setNetworkWriteKBs(networkWriteKBs); hostStats.setEntityType(entityType); }
@Override public Answer execute(final GetHostStatsCommand command, final LibvirtComputingResource libvirtComputingResource) { CPUStat cpuStat = libvirtComputingResource.getCPUStat(); MemStat memStat = libvirtComputingResource.getMemStat(); final double cpuUtil = cpuStat.getCpuUsedPercent(); final Pair<Double, Double> nicStats = libvirtComputingResource.getNicStats(libvirtComputingResource.getPublicBridgeName()); final HostStatsEntry hostStats = new HostStatsEntry(command.getHostId(), cpuUtil, nicStats.first() / 1024, nicStats.second() / 1024, "host", memStat.getTotal() / 1024, memStat.getAvailable() / 1024, 0, 0); return new GetHostStatsAnswer(command, hostStats); } }