M #~: Fix real cpu & memory bars (#426)

This commit is contained in:
Sergio Betanzos authored and GitHub committed 2020-11-16 17:17:58 +01:00
1 parent 39210fcee0
commit 8e835289e7
2 files changed
+20 -18

No files matched your search

@@ -29,29 +29,30 @@ define(function(require) {
var _html = function(host, hostShareFlag) {
var hostShare = hostShareFlag ? host : host && host.HOST_SHARE;
var hostMonitoring = hostShareFlag ? host : host.MONITORING && host.MONITORING.CAPACITY
var maxCPU = parseInt(hostShare.MAX_CPU||0);
var infoStr;
var allocatedCPUBar
if (hostShare.CPU_USAGE) {
var maxCPU = parseInt(hostShare.MAX_CPU||0);
var allocatedCPU = parseInt(hostShare.CPU_USAGE,10);
if (maxCPU > 0) {
var ratioAllocatedCPU = Math.round((allocatedCPU / maxCPU) * 100);
var ratioAllocatedCPU = Math.round((allocatedCPU / maxCPU) * 100);
infoStr = allocatedCPU + ' / ' + maxCPU + ' (' + ratioAllocatedCPU + '%)';
} else {
} else {
infoStr = "";
}
allocatedCPUBar = ProgressBar.html(allocatedCPU, maxCPU, infoStr);
}
allocatedCPUBar = ProgressBar.html(allocatedCPU, maxCPU, infoStr);
}
var realCPUBar
var realCPUBar
if (hostMonitoring && hostMonitoring.USED_CPU) {
var totalCPU = parseInt(hostShare.TOTAL_CPU||0);
var realCPU = parseInt(hostMonitoring.USED_CPU,10);
if (maxCPU > 0) {
var ratioRealCPU = Math.round((realCPU / maxCPU) * 100);
infoStr = realCPU + ' / ' + maxCPU + ' (' + ratioRealCPU + '%)';
if (totalCPU > 0) {
var ratioRealCPU = Math.round((realCPU / totalCPU) * 100);
infoStr = realCPU + ' / ' + totalCPU + ' (' + ratioRealCPU + '%)';
} else {
infoStr = "";
}
realCPUBar = ProgressBar.html(realCPU, maxCPU, infoStr);
realCPUBar = ProgressBar.html(realCPU, totalCPU, infoStr);
}
return {
real: realCPUBar,
@@ -29,29 +29,30 @@ define(function(require) {
var _html = function(host, hostShareFlag) {
var hostShare = hostShareFlag ? host : host.HOST_SHARE;
var hostMonitoring = hostShareFlag ? host : host.MONITORING && host.MONITORING.CAPACITY
var maxMem = parseInt(hostShare.MAX_MEM||0);
var infoStr = "";
var allocatedMemBar;
if (hostShare.MEM_USAGE) {
var maxMem = parseInt(hostShare.MAX_MEM||0);
var allocatedMem = parseInt(hostShare.MEM_USAGE);
if (maxMem > 0) {
var ratioAllocatedMem = Math.round((allocatedMem / maxMem) * 100);
infoStr = Humanize.size(allocatedMem) + ' / ' + Humanize.size(maxMem) + ' (' + ratioAllocatedMem + '%)';
var ratioAllocatedMem = Math.round((allocatedMem / maxMem) * 100);
infoStr = Humanize.size(allocatedMem) + ' / ' + Humanize.size(maxMem) + ' (' + ratioAllocatedMem + '%)';
} else {
infoStr = Humanize.size(allocatedMem) + ' / -';
infoStr = Humanize.size(allocatedMem) + ' / -';
}
allocatedMemBar = ProgressBar.html(allocatedMem, maxMem, infoStr);
}
var realMemBar;
if (hostMonitoring && hostMonitoring.USED_MEMORY) {
var totalMem = parseInt(hostShare.TOTAL_MEM||0);
var realMem = parseInt(hostMonitoring.USED_MEMORY,10);
if (maxMem > 0) {
var ratioRealMem = Math.round((realMem / maxMem) * 100);
infoStr = Humanize.size(realMem) + ' / ' + Humanize.size(maxMem) + ' (' + ratioRealMem + '%)';
if (totalMem > 0) {
var ratioRealMem = Math.round((realMem / totalMem) * 100);
infoStr = Humanize.size(realMem) + ' / ' + Humanize.size(totalMem) + ' (' + ratioRealMem + '%)';
} else {
infoStr = Humanize.size(realMem) + ' / -';
}
realMemBar = ProgressBar.html(realMem, maxMem, infoStr);
realMemBar = ProgressBar.html(realMem, totalMem, infoStr);
}
return {
real: realMemBar,