cw1314: Fix high CPU deviation issues seen in metrics view

HostStats returns cpu usage in percentage while memory usage in bytes.
This fixes a regression in maximum CPU usage deviation that did not
assume the values to be in percentage and multiple the final ratios
with 100 which leads to 100x the actual deviation value.

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
Rohit Yadav 2017-05-03 13:59:53 +05:30 committed by Rohit Yadav
parent b70140c1bd
commit bf7efaa98d
2 changed files with 8 additions and 8 deletions

View File

@ -128,10 +128,10 @@ public class ClusterMetricsResponse extends ClusterResponse {
}
}
public void setCpuMaxDeviation(final Double maxCpuDeviation, final Double totalCpuUsed, final Long totalHosts) {
if (maxCpuDeviation != null && totalCpuUsed != null && totalHosts != null && totalHosts != 0) {
final Double averageCpuUsage = totalCpuUsed / totalHosts;
this.cpuMaxDeviation = String.format("%.2f%%", (maxCpuDeviation - averageCpuUsage) * 100.0 / averageCpuUsage);
public void setCpuMaxDeviation(final Double maxCpuUsagePercentage, final Double totalCpuUsedPercentage, final Long totalHosts) {
if (maxCpuUsagePercentage != null && totalCpuUsedPercentage != null && totalHosts != null && totalHosts != 0) {
final Double averageCpuUsagePercentage = totalCpuUsedPercentage / totalHosts;
this.cpuMaxDeviation = String.format("%.2f%%", (maxCpuUsagePercentage - averageCpuUsagePercentage) * 1.0 / averageCpuUsagePercentage);
}
}

View File

@ -123,10 +123,10 @@ public class ZoneMetricsResponse extends ZoneResponse {
}
}
public void setCpuMaxDeviation(final Double maxCpuDeviation, final Double totalCpuUsed, final Long totalHosts) {
if (maxCpuDeviation != null && totalCpuUsed != null && totalHosts != null && totalHosts != 0) {
final Double averageCpuUsage = totalCpuUsed / totalHosts;
this.cpuMaxDeviation = String.format("%.2f%%", (maxCpuDeviation - averageCpuUsage) * 100.0 / averageCpuUsage);
public void setCpuMaxDeviation(final Double maxCpuUsagePercentage, final Double totalCpuUsedPercentage, final Long totalHosts) {
if (maxCpuUsagePercentage != null && totalCpuUsedPercentage != null && totalHosts != null && totalHosts != 0) {
final Double averageCpuUsagePercentage = totalCpuUsedPercentage / totalHosts;
this.cpuMaxDeviation = String.format("%.2f%%", (maxCpuUsagePercentage - averageCpuUsagePercentage) * 1.0 / averageCpuUsagePercentage);
}
}