diff --git a/agent/src/com/cloud/agent/resource/computing/LibvirtComputingResource.java b/agent/src/com/cloud/agent/resource/computing/LibvirtComputingResource.java index f8b0eb817ae..5c44d087b1c 100644 --- a/agent/src/com/cloud/agent/resource/computing/LibvirtComputingResource.java +++ b/agent/src/com/cloud/agent/resource/computing/LibvirtComputingResource.java @@ -2139,7 +2139,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv } - HostStatsEntry hostStats = new HostStatsEntry(cmd.getHostId(), cpuUtil, rx, tx, numCpus, "host", totMem, freeMem, 0, 0); + HostStatsEntry hostStats = new HostStatsEntry(cmd.getHostId(), cpuUtil, rx, tx, "host", totMem, freeMem, 0, 0); return new GetHostStatsAnswer(cmd, hostStats); } diff --git a/core/src/com/cloud/agent/api/GetHostStatsAnswer.java b/core/src/com/cloud/agent/api/GetHostStatsAnswer.java index c209ac84047..8d5a8ce152c 100755 --- a/core/src/com/cloud/agent/api/GetHostStatsAnswer.java +++ b/core/src/com/cloud/agent/api/GetHostStatsAnswer.java @@ -17,8 +17,6 @@ */ package com.cloud.agent.api; -import java.util.HashMap; - import com.cloud.host.HostStats; /** @@ -28,18 +26,9 @@ import com.cloud.host.HostStats; public class GetHostStatsAnswer extends Answer implements HostStats { HostStatsEntry hostStats; - - double cpuUtilization; - double networkReadKBs; - double networkWriteKBs; - int numCPUs; - String entityType; - double totalMemoryKBs; - double freeMemoryKBs; - double xapiMemoryUsageKBs; - double averageLoad; - + protected GetHostStatsAnswer() { + hostStats = new HostStatsEntry(); } public GetHostStatsAnswer(GetHostStatsCommand cmd, HostStatsEntry hostStatistics) { @@ -48,67 +37,51 @@ public class GetHostStatsAnswer extends Answer implements HostStats { } public GetHostStatsAnswer(GetHostStatsCommand cmd, double cpuUtilization, double freeMemoryKBs, double totalMemoryKBs, double networkReadKBs, - double networkWriteKBs, String entityType, double xapiMemoryUsageKBs, double averageLoad, int numCPUs) { + double networkWriteKBs, String entityType) { super(cmd); - - this.cpuUtilization = cpuUtilization; - this.freeMemoryKBs = freeMemoryKBs; - this.totalMemoryKBs = totalMemoryKBs; - this.networkReadKBs = networkReadKBs; - this.networkWriteKBs = networkWriteKBs; - this.entityType = entityType; - this.xapiMemoryUsageKBs = xapiMemoryUsageKBs; - this.numCPUs = numCPUs; + hostStats = new HostStatsEntry(); + + hostStats.setCpuUtilization(cpuUtilization); + hostStats.setFreeMemoryKBs(freeMemoryKBs); + hostStats.setTotalMemoryKBs(totalMemoryKBs); + hostStats.setNetworkReadKBs(networkReadKBs); + hostStats.setNetworkWriteKBs(networkWriteKBs); + hostStats.setEntityType(entityType); } @Override public double getUsedMemory() { - return (totalMemoryKBs - freeMemoryKBs); + return hostStats.getUsedMemory(); } @Override public double getFreeMemoryKBs() { - return freeMemoryKBs; + return hostStats.getFreeMemoryKBs(); } @Override public double getTotalMemoryKBs() { - return totalMemoryKBs; + return hostStats.getTotalMemoryKBs(); } @Override public double getCpuUtilization() { - return cpuUtilization; + return hostStats.getCpuUtilization(); } @Override public double getNetworkReadKBs() { - return networkReadKBs; + return hostStats.getNetworkReadKBs(); } @Override public double getNetworkWriteKBs() { - return networkWriteKBs; + return hostStats.getNetworkWriteKBs(); } - @Override - public double getAverageLoad() { - return averageLoad; - } - @Override public String getEntityType() { - return entityType; - } - - @Override - public double getXapiMemoryUsageKBs() { - return xapiMemoryUsageKBs; - } - - @Override - public int getNumCpus(){ - return numCPUs; + return hostStats.getEntityType(); } @Override diff --git a/core/src/com/cloud/agent/api/HostStatsEntry.java b/core/src/com/cloud/agent/api/HostStatsEntry.java index 65248aaa120..4b0c80b0fdb 100644 --- a/core/src/com/cloud/agent/api/HostStatsEntry.java +++ b/core/src/com/cloud/agent/api/HostStatsEntry.java @@ -26,43 +26,28 @@ import com.cloud.host.HostStats; public class HostStatsEntry implements HostStats { long hostId; + String entityType; double cpuUtilization; double networkReadKBs; double networkWriteKBs; - int numCpus; - String entityType; double totalMemoryKBs; double freeMemoryKBs; - double xapiMemoryUsageKBs; - double averageLoad; public HostStatsEntry() { } - public HostStatsEntry(long hostId,double cpuUtilization, double networkReadKBs, double networkWriteKBs, int numCPUs, String entityType, - double totalMemoryKBs, double freeMemoryKBs, double xapiMemoryUsageKBs, double averageLoad) + public HostStatsEntry(long hostId,double cpuUtilization, double networkReadKBs, double networkWriteKBs, String entityType, + double totalMemoryKBs, double freeMemoryKBs, double xapiMemoryUsageKBs, double averageLoad) { + this.hostId = hostId; + this.entityType = entityType; this.cpuUtilization = cpuUtilization; this.networkReadKBs = networkReadKBs; this.networkWriteKBs = networkWriteKBs; - this.numCpus = numCPUs; - this.entityType = entityType; this.totalMemoryKBs = totalMemoryKBs; this.freeMemoryKBs = freeMemoryKBs; - this.xapiMemoryUsageKBs = xapiMemoryUsageKBs; - this.averageLoad = averageLoad; - this.hostId = hostId; } - @Override - public double getAverageLoad() { - return averageLoad; - } - - public void setAverageLoad(double averageLoad) { - this.averageLoad = averageLoad; - } - @Override public double getNetworkReadKBs() { return networkReadKBs; @@ -80,10 +65,6 @@ public class HostStatsEntry implements HostStats { public void setNetworkWriteKBs(double networkWriteKBs) { this.networkWriteKBs = networkWriteKBs; } - - public void setNumCpus(int numCpus) { - this.numCpus = numCpus; - } @Override public String getEntityType(){ @@ -112,15 +93,6 @@ public class HostStatsEntry implements HostStats { this.freeMemoryKBs = freeMemoryKBs; } - @Override - public double getXapiMemoryUsageKBs(){ - return this.xapiMemoryUsageKBs; - } - - public void setXapiMemoryUsageKBs(double xapiMemoryUsageKBs){ - this.xapiMemoryUsageKBs = xapiMemoryUsageKBs; - } - @Override public double getCpuUtilization() { return this.cpuUtilization; @@ -135,14 +107,12 @@ public class HostStatsEntry implements HostStats { return (totalMemoryKBs-freeMemoryKBs); } - @Override - public int getNumCpus() { - return numCpus; - } - @Override public HostStats getHostStats() { - // TODO Auto-generated method stub - return null; + return this; + } + + public void setHostId(long hostId) { + this.hostId = hostId; } } diff --git a/core/src/com/cloud/host/HostStats.java b/core/src/com/cloud/host/HostStats.java index 128754bf6ca..d35a5c6d851 100755 --- a/core/src/com/cloud/host/HostStats.java +++ b/core/src/com/cloud/host/HostStats.java @@ -23,16 +23,16 @@ package com.cloud.host; */ public interface HostStats { - //host related stats - public double getAverageLoad(); + // host related stats public double getCpuUtilization(); public double getNetworkWriteKBs(); public double getTotalMemoryKBs(); public double getFreeMemoryKBs(); - public double getXapiMemoryUsageKBs(); public double getNetworkReadKBs(); public String getEntityType(); public double getUsedMemory(); - public int getNumCpus(); public HostStats getHostStats(); + + // public double getAverageLoad(); + // public double getXapiMemoryUsageKBs(); } diff --git a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java index e9555a19e67..fa5b804d5b1 100644 --- a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java +++ b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java @@ -1395,7 +1395,7 @@ public abstract class CitrixResourceBase implements ServerResource { protected HostStatsEntry getHostStats(Connection conn, GetHostStatsCommand cmd, String hostGuid, long hostId) { - HostStatsEntry hostStats = new HostStatsEntry(hostId, 0, 0, 0, 0, "host", 0, 0, 0, 0); + HostStatsEntry hostStats = new HostStatsEntry(hostId, 0, 0, 0, "host", 0, 0, 0, 0); Object[] rrdData = getRRDData(conn, 1); // call rrd method with 1 for host if (rrdData == null) { @@ -1448,21 +1448,25 @@ public abstract class CitrixResourceBase implements ServerResource { } if (param.contains("cpu")) { - hostStats.setNumCpus(hostStats.getNumCpus() + 1); + // 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))); } +*/ } } // add the host cpu utilization +/* if (hostStats.getNumCpus() != 0) { hostStats.setCpuUtilization(hostStats.getCpuUtilization() / hostStats.getNumCpus()); s_logger.debug("Host cpu utilization " + hostStats.getCpuUtilization()); } +*/ return hostStats; } diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java index ccef3e0d8f7..80654cf1628 100644 --- a/server/src/com/cloud/api/ApiResponseHelper.java +++ b/server/src/com/cloud/api/ApiResponseHelper.java @@ -502,7 +502,7 @@ public class ApiResponseHelper implements ResponseGenerator { float cpuUtil = (float) hostStats.getCpuUtilization(); cpuUsed = decimalFormat.format(cpuUtil) + "%"; hostResponse.setCpuUsed(cpuUsed); - hostResponse.setAverageLoad(Double.doubleToLongBits(hostStats.getAverageLoad())); + // hostResponse.setAverageLoad(Double.doubleToLongBits(hostStats.getAverageLoad())); hostResponse.setNetworkKbsRead(Double.doubleToLongBits(hostStats.getNetworkReadKBs())); hostResponse.setNetworkKbsWrite(Double.doubleToLongBits(hostStats.getNetworkWriteKBs())); }