\
-
\
- \
-
\
-
\
- '+tr("Allocated")+' \
- '+tr("Real")+' \
- '+tr("Total")+'\
-
\
-
\
- \
+
\
+
\
\
+
\
@@ -148,20 +169,23 @@ var widgets = {
\
\
\
- \
-
\
-
\
- \
+ \
\
\
\
-
\
-
\
diff --git a/src/sunstone/public/js/plugins/hosts-tab.js b/src/sunstone/public/js/plugins/hosts-tab.js
index b2ea5da17f..c2a28d4c6c 100644
--- a/src/sunstone/public/js/plugins/hosts-tab.js
+++ b/src/sunstone/public/js/plugins/hosts-tab.js
@@ -513,113 +513,74 @@ function updateHostsView (request,host_list){
off_hosts = 0;
error_hosts = 0;
- // TODO: ms to s, sunstone-util probably does s to ms
- var now = new Date().getTime() / 1000;
+ var max_cpu = 0;
+ var allocated_cpu = 0;
+ var real_cpu = 0;
- var do_host_monitoring_graphs = true;
+ var max_mem = 0;
+ var allocated_mem = 0;
+ var real_mem = 0;
- if (typeof (last_host_monitoring_time) == 'undefined'){
- last_host_monitoring_time = 0;
- }
- // If the refresh is too frecuent, ignore it. In seconds
- if (now < last_host_monitoring_time + 60){
- do_host_monitoring_graphs = false;
- }
+ $.each(host_list,function(){
+ //Grab table data from the host_list
+ host_list_array.push(hostElementArray(this));
- if (!do_host_monitoring_graphs){
+ max_cpu += parseInt(this.HOST.HOST_SHARE.MAX_CPU);
+ allocated_cpu += parseInt(this.HOST.HOST_SHARE.CPU_USAGE);
+ real_cpu += parseInt(this.HOST.HOST_SHARE.USED_CPU);
- $.each(host_list,function(){
- //Grab table data from the host_list
- host_list_array.push(hostElementArray(this));
- });
-
- } else {
- var empty = false;
-
- if (typeof (host_monitoring_data) == 'undefined'){
- host_monitoring_data = {};
- empty = true;
- }
-
- last_host_monitoring_time = now;
-
- var metrics = ["CPU_USAGE", "USED_CPU", "MAX_CPU", "MEM_USAGE", "USED_MEM", "MAX_MEM"];
-
- $.each(host_list,function(){
- //Grab table data from the host_list
- host_list_array.push(hostElementArray(this));
-
- // Grab monitoring data
- if (host_monitoring_data[this.HOST.ID] === undefined){
- host_monitoring_data[this.HOST.ID] = {};
-
- for (var i=0; i
0) {
+ var ratio_allocated_cpu = Math.round((allocated_cpu / max_cpu) * 100);
+ info_str = allocated_cpu + ' / ' + max_cpu + ' (' + ratio_allocated_cpu + '%)';
+ } else {
+ info_str = "";
+ }
+
+ $("#dash_host_allocated_cpu").html(usageBarHtml(allocated_cpu, max_cpu, info_str, true));
+
+
+ if (max_cpu > 0) {
+ var ratio_real_cpu = Math.round((real_cpu / max_cpu) * 100);
+ info_str = real_cpu + ' / ' + max_cpu + ' (' + ratio_real_cpu + '%)';
+ } else {
+ info_str = "";
+ }
+
+ $("#dash_host_real_cpu").html(usageBarHtml(real_cpu, max_cpu, info_str, true));
+
+
+ if (max_mem > 0) {
+ var ratio_allocated_mem = Math.round((allocated_mem / max_mem) * 100);
+ info_str = humanize_size(allocated_mem) + ' / ' + humanize_size(max_mem) + ' (' + ratio_allocated_mem + '%)';
+ } else {
+ info_str = humanize_size(allocated_mem) + ' / -';
+ }
+
+ $("#dash_host_allocated_mem").html(usageBarHtml(allocated_mem, max_mem, info_str, true));
+
+
+ if (max_mem > 0) {
+ var ratio_real_mem = Math.round((real_mem / max_mem) * 100);
+ info_str = humanize_size(real_mem) + ' / ' + humanize_size(max_mem) + ' (' + ratio_real_mem + '%)';
+ } else {
+ info_str = humanize_size(real_mem) + ' / -';
+ }
+
+ $("#dash_host_real_mem").html(usageBarHtml(real_mem, max_mem, info_str, true));
+
+
$(".total_hosts").text(host_list.length);
$(".on_hosts").text(on_hosts);
$(".off_hosts").text(off_hosts);
$(".error_hosts").text(error_hosts);
-
- if (do_host_monitoring_graphs){
- var host_dashboard_graphs = [
- {
- monitor_resources : "CPU_USAGE,USED_CPU,MAX_CPU",
- labels : tr("Allocated")+","+tr("Real")+","+tr("Total"),
- humanize_figures : false,
- div_graph : $("#dash_host_cpu_graph", $dashboard)
- //div_legend : $("#dash_host_cpu_legend", $dashboard)
- },
- {
- monitor_resources : "MEM_USAGE,USED_MEM,MAX_MEM",
- labels : tr("Allocated")+","+tr("Real")+","+tr("Total"),
- humanize_figures : true,
- div_graph : $("#dash_host_mem_graph", $dashboard),
- div_legend : $("#dash_host_mem_legend", $dashboard)
- }
- ];
-
- var t0 = new Date().getTime();
-
- // TODO: plot only when the dashboard is visible
- for(var i=0; i 3000) {
- host_monitoring_data = {};
- }
- }
}
function insert_datastores_capacity_table(host_share) {
diff --git a/src/sunstone/public/js/plugins/vms-tab.js b/src/sunstone/public/js/plugins/vms-tab.js
index 4e6c541836..726ff7f07a 100644
--- a/src/sunstone/public/js/plugins/vms-tab.js
+++ b/src/sunstone/public/js/plugins/vms-tab.js
@@ -1275,106 +1275,45 @@ function updateVMachinesView(request, vmachine_list){
failed_vms = 0;
off_vms = 0;
+ var total_real_cpu = 0;
+ var total_allocated_cpu = 0;
- var do_vm_monitoring_graphs = true;
+ var total_real_mem = 0;
+ var total_allocated_mem = 0;
- if (!do_vm_monitoring_graphs){
+ $.each(vmachine_list,function(){
+ vmachine_list_array.push( vMachineElementArray(this));
- $.each(vmachine_list,function(){
- vmachine_list_array.push( vMachineElementArray(this));
- });
+ if(this.VM.STATE == 3 && this.VM.STATE == 3){ // ACTIVE, RUNNING
+ total_real_cpu += parseInt(this.VM.CPU);
+ total_allocated_cpu += parseInt(this.VM.TEMPLATE.CPU * 100);
- } else {
- if (typeof (vm_monitoring_data) == 'undefined'){
- vm_monitoring_data = {};
+ total_real_mem += parseInt(this.VM.MEMORY);
+ total_allocated_mem += parseInt(this.VM.TEMPLATE.MEMORY);
}
-
- var metrics = ["NET_TX", "NET_RX"];
-
- $.each(vmachine_list,function(){
- vmachine_list_array.push( vMachineElementArray(this));
-
- var empty = false;
- var time = this.VM.LAST_POLL;
-
- if (time != "0"){
-
- if (vm_monitoring_data[this.VM.ID] === undefined){
- empty = true;
-
- vm_monitoring_data[this.VM.ID] = {};
-
- for (var i=0; i 3000) {
- vm_monitoring_data = {};
- }
- }
};
diff --git a/src/sunstone/public/js/sunstone.js b/src/sunstone/public/js/sunstone.js
index c9507bfead..f22b735f14 100644
--- a/src/sunstone/public/js/sunstone.js
+++ b/src/sunstone/public/js/sunstone.js
@@ -3424,6 +3424,36 @@ function quotaBarHtml(usage, limit, info_str){
return html;
}
+function usageBarHtml(usage, limit, info_str, color){
+ percentage = 0;
+
+ if (limit > 0){
+ percentage = (usage / limit) * 100;
+
+ if (percentage > 100){
+ percentage = 100;
+ }
+ }
+
+ info_str = info_str || ( usage+' / '+((limit > 0) ? limit : '-') );
+
+ if (color){
+ var r = Math.min(parseInt(255 * percentage / 50), 255);
+ var g = Math.min(parseInt(255 * (100 - percentage) / 50), 255);
+ var b = 0;
+
+ var style='width: '+percentage+'%; background: rgb('+r+','+g+','+b+') !important';
+ } else {
+ var style='width: '+percentage+'%';
+ }
+
+ html = '';
+
+ return html;
+}
+
function quotaIntLimit(limit, default_limit){
i_limit = parseInt(limit, 10);
i_default_limit = parseInt(default_limit, 10);