1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-11 05:17:41 +03:00

Feature #1664: Dashboard shows VM network speed graphs (instead of consumption)

This commit is contained in:
Carlos Martín 2013-03-07 18:43:22 +01:00
parent 4238cd38c9
commit fead11c584
5 changed files with 85 additions and 5 deletions

View File

@ -728,6 +728,9 @@ var OpenNebula = {
"monitor" : function(params){
OpenNebula.Action.monitor(params,OpenNebula.VM.resource,false);
},
"pool_monitor" : function(params){
OpenNebula.Action.monitor(params,OpenNebula.VM.resource,true);
},
"attachdisk" : function(params){
var action_obj = {"disk_template": params.data.extra_param};
OpenNebula.Action.simple_action(params,OpenNebula.VM.resource,

View File

@ -249,6 +249,22 @@ var dashboard_tab_content = '\
<h2 id="failed_vms" class="subheader"></h2>\
<h3 class="subheader"><small>'+tr("FAILED")+'</small></h3>\
</div>\
<div class="row">\
<div class="ten columns" id="dash_vm_net_tx_legend" style="width:60%;height: 100px;margin: 50px;">\
</div>\
</div>\
<div class="row">\
<div class="ten columns" id="dash_vm_net_tx_graph" style="width:60%;height: 200px;margin: 50px;">\
</div>\
</div>\
<div class="row">\
<div class="ten columns" id="dash_vm_net_rx_legend" style="width:60%;height: 100px;margin: 50px;">\
</div>\
</div>\
<div class="row">\
<div class="ten columns" id="dash_vm_net_rx_graph" style="width:60%;height: 200px;margin: 50px;">\
</div>\
</div>\
</div>\
</div>\
</div>\

View File

@ -35,10 +35,6 @@ var host_graphs = [
}
]
var host_monitoring_args = {
monitor_resources : "HOST_SHARE/CPU_USAGE,HOST_SHARE/USED_CPU,HOST_SHARE/MAX_CPU,HOST_SHARE/MEM_USAGE,HOST_SHARE/USED_MEM,HOST_SHARE/MAX_MEM"
};
var hosts_tab_content = '\
<form class="custom" id="form_hosts" action="">\
<div class="panel">\
@ -782,7 +778,11 @@ function updateHostsView (request,host_list){
$("#error_hosts", form_hosts).text(error_hosts);
// Update the dashboard graphs with monitoring information
Sunstone.runAction("Host.pool_monitor",host_monitoring_args);
Sunstone.runAction(
"Host.pool_monitor",
{
monitor_resources : "HOST_SHARE/CPU_USAGE,HOST_SHARE/USED_CPU,HOST_SHARE/MAX_CPU,HOST_SHARE/MEM_USAGE,HOST_SHARE/USED_MEM,HOST_SHARE/MAX_MEM"
});
//SunstoneMonitoring.monitor('HOST', host_list)
//

View File

@ -424,6 +424,43 @@ var vm_actions = {
error: vmMonitorError
},
"VM.pool_monitor" : {
type: "monitor_global",
call : OpenNebula.VM.pool_monitor,
callback: function(req,response) {
var vm_dashboard_graphs = [
{ labels : "Network transmission",
monitor_resources : "NET_TX",
humanize_figures : true,
convert_from_bytes : true,
derivative : true,
div_graph : $("#dash_vm_net_tx_graph", $dashboard),
div_legend : $("#dash_vm_net_tx_legend", $dashboard)
},
{ labels : "Network reception",
monitor_resources : "NET_RX",
humanize_figures : true,
convert_from_bytes : true,
derivative : true,
div_graph : $("#dash_vm_net_rx_graph", $dashboard),
div_legend : $("#dash_vm_net_rx_legend", $dashboard)
}
];
for(var i=0; i<vm_dashboard_graphs.length; i++) {
plot_totals(
response,
vm_dashboard_graphs[i]
);
}
// TODO: refresh individual info panel graphs with this new data?
},
// TODO: ignore error, or set message similar to hostMonitorError?
error: onError
},
"VM.chown" : {
type: "multiple",
call: OpenNebula.VM.chown,
@ -934,6 +971,9 @@ function updateVMachinesView(request, vmachine_list){
$("#pending_vms", form).text(pending_vms);
$("#failed_vms", form).text(failed_vms);
$("#off_vms", form).text(off_vms);
// Update the dashboard graphs with monitoring information
Sunstone.runAction("VM.pool_monitor",{ monitor_resources : "NET_TX,NET_RX"});
};
@ -1177,6 +1217,9 @@ function updateVMInfo(request,vm){
Sunstone.updateInfoPanelTab("vm_info_panel","vm_history_tab",history_tab);
Sunstone.updateInfoPanelTab("vm_info_panel","vm_monitoring_tab",monitoring_tab);
// TODO: do not call monitor for each graph
// TODO: re-use pool_monitor data?
//Pop up the info panel and asynchronously get vm_log and stats
Sunstone.popUpInfoPanel("vm_info_panel");
Sunstone.runAction("VM.log",vm_info.ID);

View File

@ -813,6 +813,24 @@ function plot_totals(response, info) {
if(id != "resource") {
var data = response[id][attribute];
if(info.derivative) {
for(var i=0; i<data.length-1; i++)
{
// Each elem is [timestamp, cumulative value]
var first = data[i];
var second = data[i+1];
// value now - value before / seconds
var speed = (second[1] - first[1]) / (second[0] - first[0]);
// The first element is replaced with the second one
data[i] = [first[0], speed];
}
// The last elem must be removed
data.pop();
}
var local_min = parseInt( data[0][0] );
var local_max = parseInt( data[data.length - 1][0] );