From 151b5b49d0e330f4d7cbb336bee969a578f6ae2f Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Thu, 29 Oct 2015 12:47:24 +0530 Subject: [PATCH] metrics: fix host metrics view threshold calculations Signed-off-by: Rohit Yadav --- ui/scripts/metrics.js | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/ui/scripts/metrics.js b/ui/scripts/metrics.js index be1efd1a0d7..96d84f1fb0e 100644 --- a/ui/scripts/metrics.js +++ b/ui/scripts/metrics.js @@ -585,16 +585,16 @@ memtotal: { label: 'label.metrics.memory.total' }, - memallocated: { - label: 'label.metrics.allocated', + memusedavg: { + label: 'label.metrics.memory.used.avg', thresholdcolor: true, thresholds: { notification: 'memnotificationthreshold', disable: 'memdisablethreshold' } }, - memusedavg: { - label: 'label.metrics.memory.used.avg', + memallocated: { + label: 'label.metrics.allocated', thresholdcolor: true, thresholds: { notification: 'memnotificationthreshold', @@ -633,31 +633,31 @@ items[idx].cores = host.cpunumber; items[idx].cputotal = (parseFloat(host.cpunumber) * parseFloat(host.cpuspeed) / 1000.0).toFixed(2); if (host.cpuused) { - items[idx].cpuusedavg = host.cpuused; + items[idx].cpuusedavg = (parseFloat(host.cpuused) * items[idx].cputotal / 100.0).toFixed(2) + ' Ghz'; } else { items[idx].cpuusedavg = '--'; } - items[idx].cpuallocated = host.cpuallocated; - items[idx].memtotal = (parseFloat(host.memorytotal)/(1024.0*1024.0*1024.0)).toFixed(2) + 'GB'; - items[idx].memallocated = (parseFloat(host.memoryallocated)/(1024.0*1024.0*1024.0)).toFixed(2) + 'GB'; + items[idx].cpuallocated = (parseFloat(host.cpuallocated) * items[idx].cputotal / 100.0).toFixed(2) + ' Ghz'; + items[idx].memtotal = (parseFloat(host.memorytotal)/(1024.0*1024.0*1024.0)).toFixed(2) + ' GB'; + items[idx].memallocated = (parseFloat(host.memoryallocated)/(1024.0*1024.0*1024.0)).toFixed(2) + ' GB'; if (host.memoryused) { - items[idx].memusedavg = (parseFloat(host.memoryused)/(1024.0*1024.0*1024.0)).toFixed(2) + 'GB'; + items[idx].memusedavg = (parseFloat(host.memoryused)/(1024.0*1024.0*1024.0)).toFixed(2) + ' GB'; } else { items[idx].memusedavg = '--'; } if (host.networkkbsread && host.networkkbswrite) { - items[idx].networkread = (parseFloat(host.networkkbsread)/(1024.0*1024.0)).toFixed(2) + 'GB'; - items[idx].networkwrite = (parseFloat(host.networkkbswrite)/(1024.0*1024.0)).toFixed(2) + 'GB'; + items[idx].networkread = (parseFloat(host.networkkbsread)/(1024.0*1024.0)).toFixed(2) + ' GB'; + items[idx].networkwrite = (parseFloat(host.networkkbswrite)/(1024.0*1024.0)).toFixed(2) + ' GB'; } else { items[idx].networkread = '--'; items[idx].networkwrite = '--'; } // Threshold color coding - items[idx].cpunotificationthreshold = 75.0; - items[idx].cpudisablethreshold = 95.0; - items[idx].memnotificationthreshold = 75.0; - items[idx].memdisablethreshold = 95.0; + items[idx].cpunotificationthreshold = 0.75 * parseFloat(items[idx].cputotal); + items[idx].cpudisablethreshold = 0.95 * parseFloat(items[idx].cputotal); + items[idx].memnotificationthreshold = 0.75 * parseFloat(items[idx].memtotal); + items[idx].memdisablethreshold = 0.95 * parseFloat(items[idx].memtotal); $.ajax({ url: createURL('listConfigurations'), @@ -700,7 +700,7 @@ async: false }); - items[idx].cputotal = items[idx].cputotal + 'Ghz (x' + cpuOverCommit + ')'; + items[idx].cputotal = items[idx].cputotal + ' Ghz (x' + cpuOverCommit + ')'; items[idx].memtotal = items[idx].memtotal + ' (x' + memOverCommit + ')'; }); }