--- misc/xenconsole/index.php 2012/12/01 11:27:10 1888 +++ misc/xenconsole/index.php 2012/12/03 11:25:39 1893 @@ -64,6 +64,29 @@ function refreshData() { $.get('ajaxdata.php', function(xml) { + $(xml).find('host').each(function() { + var memtotal = $(this).find('memtotal').text(); + var memfree = $(this).find('memfree').text(); + var cpuavg = $(this).find('cpuavg').text(); + + memtotal = Math.round ( memtotal / (1024*1024) ); + memfree = Math.round ( memfree / (1024*1024) ); + var memused = memtotal - memfree; + var mem_percentage = Math.round( (memused/memtotal) * 100); + + //alert(memused + ' ' + mem_percentage); + + $('#server_memory_usage').attr('src', 'usagebar.php?usage=' + mem_percentage); + $('#server_memory_usage').attr('alt', mem_percentage + '%'); + $('#server_memory_usage').attr('title', mem_percentage + '%'); + $('#server_memory_usage_txt').text( memused + '/' + memtotal + 'MB'); + + + $('#server_cpu_usage').attr('src', 'usagebar.php?usage=' + cpuavg); + $('#server_cpu_usage').attr('alt', cpuavg + '%'); + $('#server_cpu_usage').attr('title', cpuavg + '%'); + $('#server_cpu_usage_txt').text( cpuavg+ '%'); + }); $(xml).find('vm').each(function() { var name = $(this).find('name').text(); var state = $(this).find('state').text(); @@ -72,6 +95,7 @@ var conurl = $(this).find('conurl').text(); var session = $(this).find('session').text(); var os = $(this).find('os').text(); + var cpuavg = $(this).find('cpuavg').text(); name = name.replace(" ", "_"); name = name.replace(".", "_"); @@ -90,6 +114,12 @@ vm.find('.actionstop').show(); vm.find('.actionstart').hide(); vm.find('.os').text(' - ' + os); + + + vm.find('.cpu_graph').show(); + vm.find('.cpu_graph').attr('src', 'usagebar.php?usage=' + cpuavg); + vm.find('.cpu_graph').attr('title', cpuavg + '%'); + vm.find('.mem_graph').show(); } else { if (state == "Halted") { vm.find('.state').css("background-image", "url('gfx/vps_topred.png')"); @@ -100,9 +130,11 @@ vm.find('.console').hide(); vm.find('.actionstop').hide(); vm.find('.actionstart').show(); + vm.find('.cpu_graph').hide(); + vm.find('.mem_graph').hide(); } - }) + }) }); } @@ -183,19 +215,19 @@ - + - +
0/4 MB
+ +
1%
+
89.3/405.5 GB


-
12%
-
1%
-
89.3/405.5 GB
@@ -262,11 +294,13 @@ - + +
VCPU +
@@ -276,11 +310,12 @@ na --> - + +