diff --git a/src/sunstone/public/app/opennebula/vm.js b/src/sunstone/public/app/opennebula/vm.js index 56fce9d983..f4f0c17ab5 100644 --- a/src/sunstone/public/app/opennebula/vm.js +++ b/src/sunstone/public/app/opennebula/vm.js @@ -612,6 +612,7 @@ define(function(require) { "retrieveExternalIPs": retrieveExternalIPs, "retrieveExternalNetworkAttrs": retrieveExternalNetworkAttrs, "isNICGraphsSupported": isNICGraphsSupported, + "isDiskGraphsSupported": isDiskGraphsSupported, "isNICAttachSupported": isNICAttachSupported, "isVNCSupported": isVNCSupported, "isSPICESupported": isSPICESupported, @@ -643,6 +644,15 @@ define(function(require) { } } + function isDiskGraphsSupported(element) { + var history = retrieveLastHistoryRecord(element) + if (history) { + return $.inArray(history.VM_MAD, ['ec2','az']) == -1; + } else { + return false; + } + } + function isNICAttachSupported(element) { var history = retrieveLastHistoryRecord(element) if (history) { diff --git a/src/sunstone/public/app/tabs/vms-tab/panels/storage.js b/src/sunstone/public/app/tabs/vms-tab/panels/storage.js index b4bfdf4078..12d3c1289e 100644 --- a/src/sunstone/public/app/tabs/vms-tab/panels/storage.js +++ b/src/sunstone/public/app/tabs/vms-tab/panels/storage.js @@ -29,6 +29,8 @@ define(function(require) { var TemplateHtml = require('hbs!./storage/html'); var DiskDetailsHtml = require('hbs!./storage/disk-details'); var Navigation = require('utils/navigation'); + var Notifier = require('utils/notifier'); + var Graphs = require('utils/graphs'); /* CONSTANTS @@ -62,6 +64,7 @@ define(function(require) { Panel.prototype.setup = _setup; Panel.prototype.getState = _getState; Panel.prototype.setState = _setState; + Panel.prototype.onShow = _onShow; return Panel; @@ -76,10 +79,82 @@ define(function(require) { diskCost = Config.onedConf.DEFAULT_COST.DISK_COST; } - return TemplateHtml({ + var html = TemplateHtml({ element: this.element, diskCost: diskCost }); + // Do not show statistics for not hypervisors that do not gather net data + //if (OpenNebulaVM.isNICGraphsSupported(that.element)) { + html += '\ +
\ +
\ +
\ + ' + Locale.tr("Disk RD Bytes") + '\ +
\ +
\ +
\ + \ + \ + \ +
\ +
\ +
\ +
\ +
\ +
\ +
\ +
\ +
\ + ' + Locale.tr("Disk WR Bytes") + '\ +
\ +
\ +
\ + \ + \ + \ +
\ +
\ +
\ +
\ +
\ +
\ +
\ +
\ +
\ + ' + Locale.tr("Disk RD IOPS") + '\ +
\ +
\ +
\ + \ + \ + \ +
\ +
\ +
\ +
\ +
\ +
\ +
\ +
\ +
\ + ' + Locale.tr("Disk WR IOPS") + '\ +
\ +
\ +
\ + \ + \ + \ +
\ +
\ +
\ +
\ +
\ +
\ +
\ +
\ + '; + // } + return html; } function _setup(context) { @@ -571,4 +646,61 @@ define(function(require) { subTree : subTree }; } + + function _onShow(context) { + var that = this; + if (OpenNebulaVM.isDiskGraphsSupported(that.element)) { + OpenNebulaVM.monitor({ + data: { + id: that.element.ID, + monitor: { + monitor_resources : "MONITORING/DISKRDBYTES,MONITORING/DISKWRBYTES,MONITORING/DISKRDIOPS,MONITORING/DISKWRIOPS" + } + }, + success: function(req, response) { + var vmGraphs = [ + { + labels : Locale.tr("Disk read bytes"), + monitor_resources : "MONITORING/DISKRDBYTES", + humanize_figures : true, + convert_from_bytes : true, + derivative : true, + div_graph : $("#vm_st_drb_graph") + }, + { + labels : Locale.tr("Disk write bytes"), + monitor_resources : "MONITORING/DISKWRBYTES", + humanize_figures : true, + convert_from_bytes : true, + derivative : true, + div_graph : $("#vm_st_dwb_graph") + }, + { + labels : Locale.tr("Disk Read IOPS"), + monitor_resources : "MONITORING/DISKRDIOPS", + //humanize_figures : true, + //convert_from_bytes : true, + y_sufix : "IOPS/s", + derivative : true, + div_graph : $("#vm_st_drio_graph") + }, + { + labels : Locale.tr("Disk write IOPS"), + monitor_resources : "MONITORING/DISKWRIOPS", + //humanize_figures : true, + //convert_from_bytes : true, + y_sufix : "IOPS/s", + derivative : true, + div_graph : $("#vm_st_dwio_graph") + } + ]; + + for (var i = 0; i < vmGraphs.length; i++) { + Graphs.plot(response, vmGraphs[i]); + } + }, + error: Notifier.onError + }); + } + } });