mirror of https://github.com/apache/cloudstack.git
metrics: cluster view table model/api wip
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
parent
218468b8c1
commit
5c37238042
|
|
@ -54,7 +54,7 @@
|
|||
hosts: {
|
||||
label: 'label.hosts'
|
||||
},
|
||||
cpuavg: {
|
||||
cpuused: {
|
||||
label: 'Avg CPU Used'
|
||||
},
|
||||
cpumaxdev: {
|
||||
|
|
@ -66,7 +66,7 @@
|
|||
cputotal: {
|
||||
label: 'Total CPU Ghz'
|
||||
},
|
||||
memavg: {
|
||||
memused: {
|
||||
label: 'Avg Memory Used'
|
||||
},
|
||||
memmaxdev: {
|
||||
|
|
@ -80,8 +80,6 @@
|
|||
}
|
||||
},
|
||||
dataProvider: function(args) {
|
||||
console.log(args);
|
||||
|
||||
var data = {};
|
||||
listViewDataProvider(args, data);
|
||||
$.ajax({
|
||||
|
|
@ -89,7 +87,41 @@
|
|||
data: data,
|
||||
success: function(json) {
|
||||
var items = json.listclustersresponse.cluster;
|
||||
console.log(items);
|
||||
$.each(items, function(idx, cluster) {
|
||||
$.ajax({
|
||||
url: createURL('listHosts'),
|
||||
data: {clusterid: cluster.id},
|
||||
success: function(json) {
|
||||
items[idx].hosts = json.listhostsresponse.count;
|
||||
items[idx].cpuused = 0.0;
|
||||
items[idx].cpumaxdev = 0.0;
|
||||
items[idx].cpuallocated = 0.0;
|
||||
items[idx].cputotal = 0.0;
|
||||
items[idx].memused = 0.0;
|
||||
items[idx].memmaxdev = 0.0;
|
||||
items[idx].memallocated = 0.0;
|
||||
items[idx].memtotal = 0.0;
|
||||
var maxCpuUsed = 0.0;
|
||||
$.each(json.listhostsresponse.host, function(i, host) {
|
||||
if (host.hasOwnProperty('cpuused')) {
|
||||
items[idx].cpuused += host.cpuused;
|
||||
if (host.cpuused > maxCpuUsed) {
|
||||
maxCpuUsed = host.cpuused;
|
||||
}
|
||||
}
|
||||
|
||||
if (host.hasOwnProperty('cpuallocated')) {
|
||||
items[idx].cpuallocated += parseFloat(host.cpuallocated.replace('%', ''));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
items[idx].cpuused = 100.0 * items[idx].cpuused / items[idx].hosts;
|
||||
items[idx].cpuallocated = (items[idx].cpuallocated / items[idx].hosts).toFixed(2);
|
||||
},
|
||||
async: false
|
||||
});
|
||||
});
|
||||
args.response.success({
|
||||
data: items
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue