Skip to content

Commit 4e8f149

Browse files
authored
ui: add memory used column in instance metrics view (#3243)
This adds memory used column in the instance metrics view. Also fixes a bug for VMware, due to which incorrect memory usage was returned. Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
1 parent de18613 commit 4e8f149

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5907,7 +5907,7 @@ private HashMap<String, VmStatsEntry> getVmStats(List<String> vmNames) throws Ex
59075907
} else if (objProp.getName().contains(instanceNameCustomField)) {
59085908
if (objProp.getVal() != null)
59095909
vmInternalCSName = ((CustomFieldStringValue)objProp.getVal()).getValue();
5910-
} else if (objProp.getName().equals(guestMemusage)) {
5910+
} else if (objProp.getName().equals(guestMemUseStr)) {
59115911
guestMemusage = objProp.getVal().toString();
59125912
} else if (objProp.getName().equals(numCpuStr)) {
59135913
numberCPUs = objProp.getVal().toString();

ui/scripts/metrics.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,9 @@
478478
columns: {
479479
memorytotal: {
480480
label: 'label.metrics.allocated'
481+
},
482+
memoryused: {
483+
label: 'label.metrics.memory.used.avg'
481484
}
482485
}
483486
},
@@ -525,6 +528,12 @@
525528
url: createURL('listVirtualMachinesMetrics'),
526529
data: data,
527530
success: function(json) {
531+
json.listvirtualmachinesmetricsresponse.virtualmachine.forEach(function(vm) {
532+
var memUsedPercent = (vm.memorykbs && vm.memoryintfreekbs) ? (Math.round((vm.memorykbs - vm.memoryintfreekbs) * 10000 / vm.memorykbs) / 100).toString() + "%" : "";
533+
$.extend(vm,{
534+
memoryused: memUsedPercent
535+
})
536+
});
528537
args.response.success({
529538
data: json.listvirtualmachinesmetricsresponse.virtualmachine
530539
});

0 commit comments

Comments
 (0)