From 7b912ca4e73d3c1fad0658fcf67b65aa89734ebf Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Fri, 16 Oct 2015 17:01:03 +0530 Subject: [PATCH] metrics: complete instances metrics view Signed-off-by: Rohit Yadav --- .../classes/resources/messages.properties | 12 +- ui/dictionary.jsp | 8 +- ui/scripts/metrics.js | 103 +++++++++++++----- 3 files changed, 84 insertions(+), 39 deletions(-) diff --git a/client/WEB-INF/classes/resources/messages.properties b/client/WEB-INF/classes/resources/messages.properties index 45ba35c287c..41fef4399f7 100644 --- a/client/WEB-INF/classes/resources/messages.properties +++ b/client/WEB-INF/classes/resources/messages.properties @@ -836,23 +836,23 @@ label.metrics.allocated=Allocated label.metrics.clusters=Clusters label.metrics.cpu.allocated=CPU Allocated label.metrics.cpu.max.dev=CPU Max Dev -label.metrics.cpu.total.ghz=Total CPU GHz +label.metrics.cpu.total=Total CPU label.metrics.cpu.usage=CPU Usage label.metrics.cpu.used.avg=Avg CPU label.metrics.disk.iops.total=IOPS Total -label.metrics.disk.read.bytes=Disk Read Bytes +label.metrics.disk.read=Disk Read label.metrics.disk.usage=Disk Usage -label.metrics.disk.write.bytes=Disk Write Bytes +label.metrics.disk.write=Disk Write label.metrics.hosts=Hosts label.metrics.memory.allocated=Mem Allocated label.metrics.memory.max.dev=Mem Max Dev -label.metrics.memory.total.gb=Total Mem GB +label.metrics.memory.total=Total Mem label.metrics.memory.usage=Memory Usage label.metrics.memory.used.avg=Avg Mem label.metrics.name=Name label.metrics.network.usage=Network Usage -label.metrics.network.read=Net Read GB -label.metrics.network.write=Net Write GB +label.metrics.network.read=Network Read +label.metrics.network.write=Network Write label.metrics.num.cpu.cores=Cores label.metrics.state=State label.migrate.instance.to.host=Migrate instance to another host diff --git a/ui/dictionary.jsp b/ui/dictionary.jsp index 74037234ce9..c67eefe371e 100644 --- a/ui/dictionary.jsp +++ b/ui/dictionary.jsp @@ -837,17 +837,17 @@ dictionary = { 'label.metrics.clusters': '', 'label.metrics.cpu.allocated': '', 'label.metrics.cpu.max.dev': '', -'label.metrics.cpu.total.ghz': '', +'label.metrics.cpu.total': '', 'label.metrics.cpu.usage': '', 'label.metrics.cpu.used.avg': '', 'label.metrics.disk.iops.total': '', -'label.metrics.disk.read.bytes': '', +'label.metrics.disk.read': '', 'label.metrics.disk.usage': '', -'label.metrics.disk.write.bytes': '', +'label.metrics.disk.write': '', 'label.metrics.hosts': '', 'label.metrics.memory.allocated': '', 'label.metrics.memory.max.dev': '', -'label.metrics.memory.total.gb': '', +'label.metrics.memory.total': '', 'label.metrics.memory.usage': '', 'label.metrics.memory.used.avg': '', 'label.metrics.name': '', diff --git a/ui/scripts/metrics.js b/ui/scripts/metrics.js index 219f34aa78d..c7e33d1f41a 100644 --- a/ui/scripts/metrics.js +++ b/ui/scripts/metrics.js @@ -84,7 +84,7 @@ } }, cputotal: { - label: 'label.metrics.cpu.total.ghz' + label: 'label.metrics.cpu.total' } } }, @@ -118,7 +118,7 @@ } }, memtotal: { - label: 'label.metrics.memory.total.gb' + label: 'label.metrics.memory.total' } } } @@ -317,7 +317,7 @@ } }, cputotal: { - label: 'label.metrics.cpu.total.ghz' + label: 'label.metrics.cpu.total' } } }, @@ -351,7 +351,7 @@ } }, memtotal: { - label: 'label.metrics.memory.total.gb' + label: 'label.metrics.memory.total' } } } @@ -531,12 +531,8 @@ return str; }, indicator: { - 'Enabled': 'on', 'Up': 'on', 'Down': 'off', - 'Unmanaged': 'off', - 'Destroyed': 'off', - 'Disabled': 'off' }, compact: true }, @@ -548,7 +544,7 @@ label: 'label.metrics.num.cpu.cores', }, cputotal: { - label: 'label.metrics.cpu.total.ghz' + label: 'label.metrics.cpu.total' }, cpuusedavg: { label: 'label.metrics.cpu.used.avg', @@ -573,7 +569,7 @@ collapsible: true, columns: { memtotal: { - label: 'label.metrics.memory.total.gb' + label: 'label.metrics.memory.total' }, memallocated: { label: 'label.metrics.allocated', @@ -644,10 +640,10 @@ $.each(json.listconfigurationsresponse.configuration, function(i, config) { switch (config.name) { case 'cluster.cpu.allocated.capacity.disablethreshold': - items[idx].cpudisablethreshold = parseFloat(config.value) * items[idx].cputotal; + items[idx].cpudisablethreshold = parseFloat(config.value) * parseFloat(items[idx].cputotal); break; case 'cluster.cpu.allocated.capacity.notificationthreshold': - items[idx].cpunotificationthreshold = parseFloat(config.value) * items[idx].cputotal; + items[idx].cpunotificationthreshold = parseFloat(config.value) * parseFloat(items[idx].cputotal); break; case 'cluster.memory.allocated.capacity.disablethreshold': items[idx].memdisablethreshold = parseFloat(config.value) * parseFloat(items[idx].memtotal); @@ -677,7 +673,7 @@ async: false }); - items[idx].cputotal = items[idx].cputotal + ' (x' + cpuOverCommit + ')'; + items[idx].cputotal = items[idx].cputotal + 'Ghz (x' + cpuOverCommit + ')'; items[idx].memtotal = items[idx].memtotal + ' (x' + memOverCommit + ')'; }); } @@ -712,10 +708,8 @@ return str; }, indicator: { - 'Enabled': 'on', - 'Unmanaged': 'off', - 'Destroyed': 'off', - 'Disabled': 'off' + 'Running': 'on', + 'Stopped': 'off' }, compact: true }, @@ -727,7 +721,7 @@ label: 'label.metrics.num.cpu.cores', }, cputotal: { - label: 'label.metrics.cpu.total.ghz' + label: 'label.metrics.cpu.total' }, cpuused: { label: 'label.metrics.cpu.used.avg', @@ -763,12 +757,12 @@ collapsible: true, columns: { diskread: { - label: 'label.metrics.disk.read.bytes' + label: 'label.metrics.disk.read' }, diskwrite: { - label: 'label.metrics.disk.write.bytes' + label: 'label.metrics.disk.write' }, - diskiops: { + diskiopstotal: { label: 'label.metrics.disk.iops.total' } } @@ -786,14 +780,65 @@ success: function(json) { var items = json.listvirtualmachinesresponse.virtualmachine; if (items) { - $.each(items, function(idx, host) { - items[idx].cores = 0; - items[idx].cputotal = 0; - items[idx].cpuused = 0.0; - items[idx].memallocated = 0.0; - items[idx].memused = 0.0; - items[idx].networkread = 0.0; - items[idx].networkwrite = 0.0; + $.each(items, function(idx, vm) { + items[idx].cores = vm.cpunumber; + items[idx].cputotal = (parseFloat(vm.cpunumber) * parseFloat(vm.cpuspeed)).toFixed(2) + 'Mhz'; + items[idx].cpuusedavg = vm.cpuused; + items[idx].cpuallocated = vm.cpuallocated; + items[idx].memallocated = (parseFloat(vm.memory)/1024.0).toFixed(2) + 'GB'; + items[idx].memused = (parseFloat(vm.memoryused)/(1024.0*1024.0*1024.0)).toFixed(2) + 'GB'; + items[idx].networkread = (parseFloat(vm.networkkbsread)/(1024.0*1024.0)).toFixed(2) + 'GB'; + items[idx].networkwrite = (parseFloat(vm.networkkbswrite)/(1024.0*1024.0)).toFixed(2) + 'GB'; + items[idx].diskread = (parseFloat(vm.diskkbsread)/(1024.0)).toFixed(2) + 'MB'; + items[idx].diskwrite = (parseFloat(vm.diskkbswrite)/(1024.0)).toFixed(2) + 'MB'; + items[idx].diskiopstotal = parseFloat(vm.diskioread) + parseFloat(vm.diskiowrite); + + var keys = [{'memoryused': 'memused'}, + {'networkkbsread': 'networkread'}, + {'networkkbswrite': 'networkwrite'}, + {'diskkbsread': 'diskread'}, + {'diskkbswrite': 'diskwrite'}, + {'diskioread': 'diskiopstotal'}]; + for (keyIdx in keys) { + var map = keys[keyIdx]; + var key = Object.keys(map)[0]; + var uiKey = map[key]; + if (!vm.hasOwnProperty(key)) { + items[idx][uiKey] = 'N/A'; + } + } + + // Threshold color coding + items[idx].cpunotificationthreshold = 75.0; + items[idx].cpudisablethreshold = 95.0; + items[idx].memnotificationthreshold = 75.0; + items[idx].memdisablethreshold = 95.0; + + $.ajax({ + url: createURL('listConfigurations'), + data: {zoneid: vm.zoneid, listAll: true}, + success: function(json) { + if (json.listconfigurationsresponse && json.listconfigurationsresponse.configuration) { + $.each(json.listconfigurationsresponse.configuration, function(i, config) { + switch (config.name) { + case 'cluster.cpu.allocated.capacity.disablethreshold': + items[idx].cpudisablethreshold = parseFloat(config.value) * items[idx].cputotal; + break; + case 'cluster.cpu.allocated.capacity.notificationthreshold': + items[idx].cpunotificationthreshold = parseFloat(config.value) * items[idx].cputotal; + break; + case 'cluster.memory.allocated.capacity.disablethreshold': + items[idx].memdisablethreshold = parseFloat(config.value) * parseFloat(items[idx].memtotal); + break; + case 'cluster.memory.allocated.capacity.notificationthreshold': + items[idx].memnotificationthreshold = parseFloat(config.value) * parseFloat(items[idx].memtotal); + break; + } + }); + } + }, + async: false + }); }); } args.response.success({