mirror of
https://github.com/apache/cloudstack.git
synced 2025-12-20 04:23:34 +01:00
CLOUDSTACK-9665 List hosts api dose not report correct cpu and memory usage.
This commit is contained in:
parent
701146ff28
commit
09de5e0b51
@ -107,6 +107,15 @@ public class HostForMigrationResponse extends BaseResponse {
|
|||||||
@Param(description = "the amount of the host's CPU after applying the cpu.overprovisioning.factor ")
|
@Param(description = "the amount of the host's CPU after applying the cpu.overprovisioning.factor ")
|
||||||
private String cpuWithOverprovisioning;
|
private String cpuWithOverprovisioning;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
@SerializedName("memorytotal")
|
||||||
|
@Param(description = "the memory total of the host, this parameter is deprecated use memorywithoverprovisioning")
|
||||||
|
private Long memoryTotal;
|
||||||
|
|
||||||
|
@SerializedName("memorywithoverprovisioning")
|
||||||
|
@Param(description = "the amount of the host's memory after applying the mem.overprovisioning.factor ")
|
||||||
|
private String memWithOverprovisioning;
|
||||||
|
|
||||||
@SerializedName("averageload")
|
@SerializedName("averageload")
|
||||||
@Param(description = "the cpu average load on the host")
|
@Param(description = "the cpu average load on the host")
|
||||||
private Long averageLoad;
|
private Long averageLoad;
|
||||||
@ -119,13 +128,9 @@ public class HostForMigrationResponse extends BaseResponse {
|
|||||||
@Param(description = "the outgoing network traffic on the host")
|
@Param(description = "the outgoing network traffic on the host")
|
||||||
private Long networkKbsWrite;
|
private Long networkKbsWrite;
|
||||||
|
|
||||||
@SerializedName("memorytotal")
|
|
||||||
@Param(description = "the memory total of the host")
|
|
||||||
private Long memoryTotal;
|
|
||||||
|
|
||||||
@SerializedName("memoryallocated")
|
@SerializedName("memoryallocated")
|
||||||
@Param(description = "the amount of the host's memory currently allocated")
|
@Param(description = "the amount of the host's memory currently allocated")
|
||||||
private Long memoryAllocated;
|
private String memoryAllocated;
|
||||||
|
|
||||||
@SerializedName("memoryused")
|
@SerializedName("memoryused")
|
||||||
@Param(description = "the amount of the host's memory currently used")
|
@Param(description = "the amount of the host's memory currently used")
|
||||||
@ -305,11 +310,7 @@ public class HostForMigrationResponse extends BaseResponse {
|
|||||||
this.networkKbsWrite = networkKbsWrite;
|
this.networkKbsWrite = networkKbsWrite;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMemoryTotal(Long memoryTotal) {
|
public void setMemoryAllocated(String memoryAllocated) {
|
||||||
this.memoryTotal = memoryTotal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMemoryAllocated(Long memoryAllocated) {
|
|
||||||
this.memoryAllocated = memoryAllocated;
|
this.memoryAllocated = memoryAllocated;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -401,6 +402,10 @@ public class HostForMigrationResponse extends BaseResponse {
|
|||||||
this.cpuWithOverprovisioning = cpuWithOverprovisioning;
|
this.cpuWithOverprovisioning = cpuWithOverprovisioning;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMemWithOverprovisioning(String memWithOverprovisioning){
|
||||||
|
this.memWithOverprovisioning=memWithOverprovisioning;
|
||||||
|
}
|
||||||
|
|
||||||
public void setHypervisorVersion(String hypervisorVersion) {
|
public void setHypervisorVersion(String hypervisorVersion) {
|
||||||
this.hypervisorVersion = hypervisorVersion;
|
this.hypervisorVersion = hypervisorVersion;
|
||||||
}
|
}
|
||||||
@ -408,4 +413,8 @@ public class HostForMigrationResponse extends BaseResponse {
|
|||||||
public void setHaHost(Boolean haHost) {
|
public void setHaHost(Boolean haHost) {
|
||||||
this.haHost = haHost;
|
this.haHost = haHost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMemoryTotal(Long memoryTotal) {
|
||||||
|
this.memoryTotal = memoryTotal;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -125,13 +125,18 @@ public class HostResponse extends BaseResponse {
|
|||||||
@Param(description = "the outgoing network traffic on the host")
|
@Param(description = "the outgoing network traffic on the host")
|
||||||
private Long networkKbsWrite;
|
private Long networkKbsWrite;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
@SerializedName("memorytotal")
|
@SerializedName("memorytotal")
|
||||||
@Param(description = "the memory total of the host")
|
@Param(description = "the memory total of the host, this parameter is deprecated use memorywithoverprovisioning")
|
||||||
private Long memoryTotal;
|
private Long memoryTotal;
|
||||||
|
|
||||||
|
@SerializedName("memorywithoverprovisioning")
|
||||||
|
@Param(description = "the amount of the host's memory after applying the mem.overprovisioning.factor")
|
||||||
|
private String memWithOverprovisioning;
|
||||||
|
|
||||||
@SerializedName("memoryallocated")
|
@SerializedName("memoryallocated")
|
||||||
@Param(description = "the amount of the host's memory currently allocated")
|
@Param(description = "the amount of the host's memory currently allocated")
|
||||||
private Long memoryAllocated;
|
private long memoryAllocated;
|
||||||
|
|
||||||
@SerializedName("memoryused")
|
@SerializedName("memoryused")
|
||||||
@Param(description = "the amount of the host's memory currently used")
|
@Param(description = "the amount of the host's memory currently used")
|
||||||
@ -328,11 +333,11 @@ public class HostResponse extends BaseResponse {
|
|||||||
this.networkKbsWrite = networkKbsWrite;
|
this.networkKbsWrite = networkKbsWrite;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMemoryTotal(Long memoryTotal) {
|
public void setMemWithOverprovisioning(String memWithOverprovisioning){
|
||||||
this.memoryTotal = memoryTotal;
|
this.memWithOverprovisioning=memWithOverprovisioning;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMemoryAllocated(Long memoryAllocated) {
|
public void setMemoryAllocated(long memoryAllocated) {
|
||||||
this.memoryAllocated = memoryAllocated;
|
this.memoryAllocated = memoryAllocated;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -458,6 +463,9 @@ public class HostResponse extends BaseResponse {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMemoryTotal(Long memoryTotal) {
|
||||||
|
this.memoryTotal = memoryTotal;
|
||||||
|
}
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
@ -542,7 +550,7 @@ public class HostResponse extends BaseResponse {
|
|||||||
return memoryTotal;
|
return memoryTotal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getMemoryAllocated() {
|
public long getMemoryAllocated() {
|
||||||
return memoryAllocated;
|
return memoryAllocated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -289,7 +289,6 @@ import com.cloud.user.dao.UserDao;
|
|||||||
import com.cloud.user.dao.UserStatisticsDao;
|
import com.cloud.user.dao.UserStatisticsDao;
|
||||||
import com.cloud.uservm.UserVm;
|
import com.cloud.uservm.UserVm;
|
||||||
import com.cloud.utils.EnumUtils;
|
import com.cloud.utils.EnumUtils;
|
||||||
import com.cloud.utils.NumbersUtil;
|
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
import com.cloud.vm.ConsoleProxyVO;
|
import com.cloud.vm.ConsoleProxyVO;
|
||||||
import com.cloud.vm.DomainRouterVO;
|
import com.cloud.vm.DomainRouterVO;
|
||||||
@ -1275,10 +1274,14 @@ public class ApiDBUtils {
|
|||||||
return s_networkModel.getDedicatedNetworkDomain(networkId);
|
return s_networkModel.getDedicatedNetworkDomain(networkId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float getCpuOverprovisioningFactor() {
|
public static float getCpuOverprovisioningFactor(long clusterId) {
|
||||||
String opFactor = s_configDao.getValue(CapacityManager.CpuOverprovisioningFactorCK);
|
float opFactor = CapacityManager.CpuOverprovisioningFactor.valueIn(clusterId);
|
||||||
float cpuOverprovisioningFactor = NumbersUtil.parseFloat(opFactor, 1);
|
return opFactor;
|
||||||
return cpuOverprovisioningFactor;
|
}
|
||||||
|
|
||||||
|
public static float getMemOverprovisioningFactor(long clusterId) {
|
||||||
|
float opFactor = CapacityManager.MemOverprovisioningFactor.valueIn(clusterId);
|
||||||
|
return opFactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isExtractionDisabled() {
|
public static boolean isExtractionDisabled() {
|
||||||
|
|||||||
@ -154,8 +154,10 @@ public class HostJoinDaoImpl extends GenericDaoBase<HostJoinVO, Long> implements
|
|||||||
Long mem = host.getMemReservedCapacity() + host.getMemUsedCapacity();
|
Long mem = host.getMemReservedCapacity() + host.getMemUsedCapacity();
|
||||||
Long cpu = host.getCpuReservedCapacity() + host.getCpuUsedCapacity();
|
Long cpu = host.getCpuReservedCapacity() + host.getCpuUsedCapacity();
|
||||||
|
|
||||||
|
hostResponse.setMemoryTotal(mem);
|
||||||
|
Float totalMemorywithOverprovisioning=new Float((host.getTotalMemory()*ApiDBUtils.getMemOverprovisioningFactor(host.getClusterId())));
|
||||||
|
hostResponse.setMemWithOverprovisioning(totalMemorywithOverprovisioning.toString());
|
||||||
hostResponse.setMemoryAllocated(mem);
|
hostResponse.setMemoryAllocated(mem);
|
||||||
hostResponse.setMemoryTotal(host.getTotalMemory());
|
|
||||||
|
|
||||||
String hostTags = host.getTag();
|
String hostTags = host.getTag();
|
||||||
hostResponse.setHostTags(host.getTag());
|
hostResponse.setHostTags(host.getTag());
|
||||||
@ -173,10 +175,10 @@ public class HostJoinDaoImpl extends GenericDaoBase<HostJoinVO, Long> implements
|
|||||||
|
|
||||||
hostResponse.setHypervisorVersion(host.getHypervisorVersion());
|
hostResponse.setHypervisorVersion(host.getHypervisorVersion());
|
||||||
|
|
||||||
String cpuAlloc = decimalFormat.format(((float)cpu / (float)(host.getCpus() * host.getSpeed())) * 100f) + "%";
|
Float cpuWithOverprovisioning = new Float(host.getCpus() * host.getSpeed() * ApiDBUtils.getCpuOverprovisioningFactor(host.getClusterId()));
|
||||||
|
String cpuAlloc = decimalFormat.format(((float)cpu / cpuWithOverprovisioning * 100f)) + "%";
|
||||||
hostResponse.setCpuAllocated(cpuAlloc);
|
hostResponse.setCpuAllocated(cpuAlloc);
|
||||||
String cpuWithOverprovisioning = new Float(host.getCpus() * host.getSpeed() * ApiDBUtils.getCpuOverprovisioningFactor()).toString();
|
hostResponse.setCpuWithOverprovisioning(cpuWithOverprovisioning.toString());
|
||||||
hostResponse.setCpuWithOverprovisioning(cpuWithOverprovisioning);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (details.contains(HostDetails.all) || details.contains(HostDetails.stats)) {
|
if (details.contains(HostDetails.all) || details.contains(HostDetails.stats)) {
|
||||||
@ -297,8 +299,10 @@ public class HostJoinDaoImpl extends GenericDaoBase<HostJoinVO, Long> implements
|
|||||||
Long mem = host.getMemReservedCapacity() + host.getMemUsedCapacity();
|
Long mem = host.getMemReservedCapacity() + host.getMemUsedCapacity();
|
||||||
Long cpu = host.getCpuReservedCapacity() + host.getCpuReservedCapacity();
|
Long cpu = host.getCpuReservedCapacity() + host.getCpuReservedCapacity();
|
||||||
|
|
||||||
hostResponse.setMemoryAllocated(mem);
|
hostResponse.setMemoryTotal(mem);
|
||||||
hostResponse.setMemoryTotal(host.getTotalMemory());
|
Float memWithOverprovisioning =new Float((host.getTotalMemory()*ApiDBUtils.getMemOverprovisioningFactor(host.getClusterId())));
|
||||||
|
hostResponse.setMemWithOverprovisioning(memWithOverprovisioning.toString());
|
||||||
|
hostResponse.setMemoryAllocated(decimalFormat.format((float)mem/ memWithOverprovisioning*100f).toString()+"%");
|
||||||
|
|
||||||
String hostTags = host.getTag();
|
String hostTags = host.getTag();
|
||||||
hostResponse.setHostTags(host.getTag());
|
hostResponse.setHostTags(host.getTag());
|
||||||
@ -316,10 +320,10 @@ public class HostJoinDaoImpl extends GenericDaoBase<HostJoinVO, Long> implements
|
|||||||
|
|
||||||
hostResponse.setHypervisorVersion(host.getHypervisorVersion());
|
hostResponse.setHypervisorVersion(host.getHypervisorVersion());
|
||||||
|
|
||||||
String cpuAlloc = decimalFormat.format(((float)cpu / (float)(host.getCpus() * host.getSpeed())) * 100f) + "%";
|
Float cpuWithOverprovisioning = new Float(host.getCpus() * host.getSpeed() * ApiDBUtils.getCpuOverprovisioningFactor(host.getClusterId()));
|
||||||
|
String cpuAlloc = decimalFormat.format(((float)cpu / cpuWithOverprovisioning * 100f)).toString() + "%";
|
||||||
hostResponse.setCpuAllocated(cpuAlloc);
|
hostResponse.setCpuAllocated(cpuAlloc);
|
||||||
String cpuWithOverprovisioning = new Float(host.getCpus() * host.getSpeed() * ApiDBUtils.getCpuOverprovisioningFactor()).toString();
|
hostResponse.setCpuWithOverprovisioning(cpuWithOverprovisioning.toString());
|
||||||
hostResponse.setCpuWithOverprovisioning(cpuWithOverprovisioning);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (details.contains(HostDetails.all) || details.contains(HostDetails.stats)) {
|
if (details.contains(HostDetails.all) || details.contains(HostDetails.stats)) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user