From f3843fa2d37f3531b730a926b9ec76108315d923 Mon Sep 17 00:00:00 2001 From: Frederick Borges Date: Wed, 9 Jun 2021 15:51:28 +0200 Subject: [PATCH] B #5420: Fix real CPU & MEM bars on ESX host table (#1285) (cherry picked from commit 3bf4870a94617688d750041331ada101e0954bc5) --- .../public/app/tabs/hosts-tab/utils/cpu-bars.js | 14 +++++++------- .../public/app/tabs/hosts-tab/utils/memory-bars.js | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/sunstone/public/app/tabs/hosts-tab/utils/cpu-bars.js b/src/sunstone/public/app/tabs/hosts-tab/utils/cpu-bars.js index c546fc1953..1615b28d65 100644 --- a/src/sunstone/public/app/tabs/hosts-tab/utils/cpu-bars.js +++ b/src/sunstone/public/app/tabs/hosts-tab/utils/cpu-bars.js @@ -36,15 +36,15 @@ define(function(require) { var allocatedCPU = parseInt(hostShare.CPU_USAGE,10); if (maxCPU > 0) { var ratioAllocatedCPU = Math.round((allocatedCPU / maxCPU) * 100); - infoStr = allocatedCPU + ' / ' + maxCPU + ' (' + ratioAllocatedCPU + '%)'; - } else { - infoStr = ""; - } - allocatedCPUBar = ProgressBar.html(allocatedCPU, maxCPU, infoStr); + infoStr = allocatedCPU + ' / ' + maxCPU + ' (' + ratioAllocatedCPU + '%)'; + } else { + infoStr = ""; } - var realCPUBar + allocatedCPUBar = ProgressBar.html(allocatedCPU, maxCPU, infoStr); + } + var realCPUBar; if (hostMonitoring && hostMonitoring.USED_CPU) { - var totalCPU = parseInt(hostShare.TOTAL_CPU||0); + var totalCPU = hostShareFlag ? parseInt(hostShare.MAX_CPU||0) : parseInt(hostShare.TOTAL_CPU||0); var realCPU = parseInt(hostMonitoring.USED_CPU,10); if (totalCPU > 0) { var ratioRealCPU = Math.round((realCPU / totalCPU) * 100); diff --git a/src/sunstone/public/app/tabs/hosts-tab/utils/memory-bars.js b/src/sunstone/public/app/tabs/hosts-tab/utils/memory-bars.js index 8bfeec5d60..060e9da9b2 100644 --- a/src/sunstone/public/app/tabs/hosts-tab/utils/memory-bars.js +++ b/src/sunstone/public/app/tabs/hosts-tab/utils/memory-bars.js @@ -43,9 +43,9 @@ define(function(require) { 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 (hostMonitoring && (hostMonitoring.USED_MEMORY || hostMonitoring.USED_MEM)) { + var totalMem = hostShareFlag ? parseInt(hostShare.MAX_MEM||0) : parseInt(hostShare.TOTAL_MEM||0); + var realMem = hostShareFlag ? parseInt(hostMonitoring.USED_MEM,10) : parseInt(hostMonitoring.USED_MEMORY,10); if (totalMem > 0) { var ratioRealMem = Math.round((realMem / totalMem) * 100); infoStr = Humanize.size(realMem) + ' / ' + Humanize.size(totalMem) + ' (' + ratioRealMem + '%)';