1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-22 18:50:08 +03:00

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

(cherry picked from commit 8e835289e7124f29067eebbcd4de3acf471ab7e8)
This commit is contained in:
Sergio Betanzos 2020-11-16 17:17:58 +01:00 committed by Tino Vazquez
parent 269c3f5852
commit 00eae96b85
No known key found for this signature in database
GPG Key ID: 14201E424D02047E
2 changed files with 20 additions and 18 deletions

View File

@ -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,

View File

@ -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,