use of com.cloud.legacymodel.communication.answer.GetHostStatsAnswer 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.communication.answer.GetHostStatsAnswer in project cosmic by MissionCriticalCloud.
the class ResourceManagerImpl method getHostStatistics.
@Override
public HostStats getHostStatistics(final long hostId) {
final Answer answer = this._agentMgr.easySend(hostId, new GetHostStatsCommand(this._hostDao.findById(hostId).getGuid(), this._hostDao.findById(hostId).getName(), hostId));
if (answer != null && answer instanceof UnsupportedAnswer) {
return null;
}
if (answer == null || !answer.getResult()) {
final String msg = "Unable to obtain host " + hostId + " statistics. ";
s_logger.warn(msg);
return null;
} else {
// now construct the result object
if (answer instanceof GetHostStatsAnswer) {
return ((GetHostStatsAnswer) answer).getHostStats();
}
}
return null;
}
Aggregations