Search in sources :

Example 11 with GetHostStatsAnswer

use of com.cloud.agent.api.GetHostStatsAnswer in project cloudstack by apache.

the class LibvirtGetHostStatsCommandWrapper method execute.

@Override
public Answer execute(final GetHostStatsCommand command, final LibvirtComputingResource libvirtComputingResource) {
    CPUStat cpuStat = libvirtComputingResource.getCPUStat();
    MemStat memStat = libvirtComputingResource.getMemStat();
    final double cpuUtil = cpuStat.getCpuUsedPercent();
    final double loadAvg = cpuStat.getCpuLoadAverage();
    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, loadAvg);
    return new GetHostStatsAnswer(command, hostStats);
}
Also used : GetHostStatsAnswer(com.cloud.agent.api.GetHostStatsAnswer) CPUStat(org.apache.cloudstack.utils.linux.CPUStat) HostStatsEntry(com.cloud.agent.api.HostStatsEntry) MemStat(org.apache.cloudstack.utils.linux.MemStat)

Aggregations

GetHostStatsAnswer (com.cloud.agent.api.GetHostStatsAnswer)11 HostStatsEntry (com.cloud.agent.api.HostStatsEntry)8 Answer (com.cloud.agent.api.Answer)6 MaintainAnswer (com.cloud.agent.api.MaintainAnswer)6 CheckVirtualMachineAnswer (com.cloud.agent.api.CheckVirtualMachineAnswer)4 GetVncPortAnswer (com.cloud.agent.api.GetVncPortAnswer)4 ReadyAnswer (com.cloud.agent.api.ReadyAnswer)4 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)4 ConfigurationException (javax.naming.ConfigurationException)4 CheckHealthAnswer (com.cloud.agent.api.CheckHealthAnswer)3 CheckNetworkAnswer (com.cloud.agent.api.CheckNetworkAnswer)3 FenceAnswer (com.cloud.agent.api.FenceAnswer)3 GetHostStatsCommand (com.cloud.agent.api.GetHostStatsCommand)3 GetStorageStatsAnswer (com.cloud.agent.api.GetStorageStatsAnswer)3 GetVmStatsAnswer (com.cloud.agent.api.GetVmStatsAnswer)3 MigrateAnswer (com.cloud.agent.api.MigrateAnswer)3 ModifyStoragePoolAnswer (com.cloud.agent.api.ModifyStoragePoolAnswer)3 PrepareForMigrationAnswer (com.cloud.agent.api.PrepareForMigrationAnswer)3 RebootAnswer (com.cloud.agent.api.RebootAnswer)3 StartAnswer (com.cloud.agent.api.StartAnswer)3