1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-22 18:50:08 +03:00

Feature #2237: Show allocated VM and Memory values in VM capacity

This commit is contained in:
Carlos Martín 2016-07-12 12:44:18 +02:00
parent 7b4598452b
commit 4f7fb20dfc
3 changed files with 37 additions and 7 deletions

View File

@ -110,25 +110,39 @@ define(function(require) {
data: {
id: that.element.ID,
monitor: {
monitor_resources : "MONITORING/CPU,MONITORING/MEMORY"
monitor_resources : "MONITORING/CPU,TEMPLATE/CPU,MONITORING/MEMORY,TEMPLATE/MEMORY"
}
},
success: function(req, response) {
var vmGraphs = [
{
monitor_resources : "MONITORING/CPU",
labels : Locale.tr("Real CPU"),
monitor_resources : "TEMPLATE/CPU,MONITORING/CPU",
labels : Locale.tr("Allocated") + "," + Locale.tr("Real"),
humanize_figures : false,
div_graph : $(".vm_cpu_graph")
div_graph : $(".vm_cpu_graph", context),
div_legend : $(".vm_cpu_legend", context)
},
{
monitor_resources : "MONITORING/MEMORY",
labels : Locale.tr("Real MEM"),
monitor_resources : "TEMPLATE/MEMORY,MONITORING/MEMORY",
labels : Locale.tr("Allocated") + "," + Locale.tr("Real"),
humanize_figures : true,
div_graph : $(".vm_memory_graph")
div_graph : $(".vm_memory_graph", context),
div_legend : $(".vm_memory_legend", context)
}
];
if(response.monitoring["TEMPLATE/CPU"] != undefined){
response.monitoring["TEMPLATE/CPU"].map(function(e){
e[1] = e[1] * 100;
});
}
if(response.monitoring["TEMPLATE/MEMORY"] != undefined){
response.monitoring["TEMPLATE/MEMORY"].map(function(e){
e[1] = e[1] * 1024;
});
}
for (var i = 0; i < vmGraphs.length; i++) {
Graphs.plot(response, vmGraphs[i]);
}

View File

@ -68,6 +68,9 @@
</div>
</div>
</div>
<div class="row graph_legend">
<div class="large-10 columns centered vm_cpu_legend"></div>
</div>
</div>
<div class="medium-6 columns">
<div class="row">
@ -82,5 +85,8 @@
</span>
</div>
</div>
<div class="row graph_legend">
<div class="large-10 columns centered vm_memory_legend"></div>
</div>
</div>
</div>

View File

@ -1738,10 +1738,20 @@ int VirtualMachine::update_monitoring(SqlDB * db)
string error_str;
char * sql_xml;
float cpu = 0;
long long memory = 0;
obj_template->get("CPU", cpu);
obj_template->get("MEMORY", memory);
oss << "<VM>"
<< "<ID>" << oid << "</ID>"
<< "<LAST_POLL>" << last_poll << "</LAST_POLL>"
<< monitoring.to_xml(xml_body)
<< "<TEMPLATE>"
<< "<CPU>" << cpu << "</CPU>"
<< "<MEMORY>" << memory << "</MEMORY>"
<< "</TEMPLATE>"
<< "</VM>";
sql_xml = db->escape_str(oss.str().c_str());