use of com.cloud.legacymodel.dc.HostStatsEntry in project cosmic by MissionCriticalCloud.
the class LibvirtGetHostStatsCommandWrapper method execute.
@Override
public Answer execute(final GetHostStatsCommand command, final LibvirtComputingResource libvirtComputingResource) {
final CpuStat cpuStat = libvirtComputingResource.getCpuStat();
final MemStat memStat = libvirtComputingResource.getMemStat();
final double cpuUtil = cpuStat.getCpuUsedPercent();
memStat.refresh();
final double totMem = memStat.getTotal();
final double freeMem = memStat.getAvailable();
final Pair<Double, Double> nicStats = libvirtComputingResource.getNicStats(libvirtComputingResource.getPublicBridgeName());
final HostStatsEntry hostStats = new HostStatsEntry(command.getHostId(), cpuUtil, nicStats.first() / 1024, nicStats.second() / 1024, "host", totMem, freeMem, 0, 0);
return new GetHostStatsAnswer(command, hostStats);
}
use of com.cloud.legacymodel.dc.HostStatsEntry in project cosmic by MissionCriticalCloud.
the class CitrixResourceBase method getHostStats.
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);
// call rrd method with 1
final Object[] rrdData = getRRDData(conn, 1);
if (rrdData == null) {
return null;
}
final Integer numRows = (Integer) rrdData[0];
final Integer numColumns = (Integer) rrdData[1];
final Node legend = (Node) rrdData[2];
final Node dataNode = (Node) rrdData[3];
final NodeList legendChildren = legend.getChildNodes();
for (int col = 0; col < numColumns; col++) {
if (legendChildren == null || legendChildren.item(col) == null) {
continue;
}
final String columnMetadata = getXMLNodeValue(legendChildren.item(col));
if (columnMetadata == null) {
continue;
}
final String[] columnMetadataList = columnMetadata.split(":");
if (columnMetadataList.length != 4) {
continue;
}
final String type = columnMetadataList[1];
final String param = columnMetadataList[3];
if (type.equalsIgnoreCase("host")) {
if (param.matches("pif_eth0_rx")) {
hostStats.setNetworkReadKBs(getDataAverage(dataNode, col, numRows) / 1000);
} else if (param.matches("pif_eth0_tx")) {
hostStats.setNetworkWriteKBs(getDataAverage(dataNode, col, numRows) / 1000);
} else if (param.contains("memory_total_kib")) {
hostStats.setTotalMemoryKBs(getDataAverage(dataNode, col, numRows));
} else if (param.contains("memory_free_kib")) {
hostStats.setFreeMemoryKBs(getDataAverage(dataNode, col, numRows));
} else if (param.matches("cpu_avg")) {
// hostStats.setNumCpus(hostStats.getNumCpus() + 1);
hostStats.setCpuUtilization(hostStats.getCpuUtilization() + getDataAverage(dataNode, col, numRows));
}
/*
* if (param.contains("loadavg")) { hostStats.setAverageLoad((hostStats.getAverageLoad() +
* getDataAverage(dataNode, col, numRows))); }
*/
}
}
return hostStats;
}
Aggregations