/[projects]/misc/xenconsole/index.php
ViewVC logotype

Diff of /misc/xenconsole/index.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2028 by torben, Tue Jul 23 15:30:12 2013 UTC revision 2105 by torben, Mon Feb 10 08:13:22 2014 UTC
# Line 1  Line 1 
1  <?php  <?php
2    
3    if (! file_exists("config.php") ) {
4      die("Could not find config.php file");
5    }
6    
7  require("config.php");  require("config.php");
8    
9  function format_memory($size) {  function format_memory($size) {
# Line 83  $(document).ready( function() { Line 88  $(document).ready( function() {
88                  openConsole(conurl,session,name);                  openConsole(conurl,session,name);
89          });          });
90    
91            $('.bar').progressbar( );
92    
93          $('#logo').click( function() {          $('#logo').click( function() {
94                  refreshData();                  refreshData();
95          });          });
# Line 211  function refreshData() { Line 218  function refreshData() {
218                  $(xml).find('host').each(function() {                  $(xml).find('host').each(function() {
219                          var memtotal = $(this).find('memtotal').text();                          var memtotal = $(this).find('memtotal').text();
220                          var memfree = $(this).find('memfree').text();                            var memfree = $(this).find('memfree').text();  
221                          var cpuavg = $(this).find('cpuavg').text();                          var cpuavg = $(this).find('cpuavg').text() * 1; // *1 is used to convert the string var to an int
222    
223                          memtotal = Math.round ( memtotal / (1024*1024) );                          memtotal = Math.round ( memtotal / (1024*1024) );
224                          memfree = Math.round ( memfree / (1024*1024) );                          memfree = Math.round ( memfree / (1024*1024) );
# Line 220  function refreshData() { Line 227  function refreshData() {
227    
228                          //alert(memused + ' ' + mem_percentage);                          //alert(memused + ' ' + mem_percentage);
229    
230                          $('#server_memory_usage').attr('src', 'usagebar.php?usage=' + mem_percentage);                          //$('#server_memory_usage').attr('src', 'usagebar.php?usage=' + mem_percentage);
231                            $('#server_memory_usage').progressbar( "value", mem_percentage );
232                          $('#server_memory_usage').attr('alt', mem_percentage + '%');                          $('#server_memory_usage').attr('alt', mem_percentage + '%');
233                          $('#server_memory_usage').attr('title', mem_percentage + '%');                          $('#server_memory_usage').attr('title', mem_percentage + '%');
234                          $('#server_memory_usage_txt').text( memused + '/' + memtotal + 'MB');                          $('#server_memory_usage_txt').text( memused + '/' + memtotal + 'MB');
235    
236    
237                          $('#server_cpu_usage').attr('src', 'usagebar.php?usage=' + cpuavg);                          //$('#server_cpu_usage').attr('src', 'usagebar.php?usage=' + cpuavg);
238                            $('#server_cpu_usage').progressbar( "value", cpuavg );
239                          $('#server_cpu_usage').attr('alt', cpuavg + '%');                          $('#server_cpu_usage').attr('alt', cpuavg + '%');
240                          $('#server_cpu_usage').attr('title', cpuavg + '%');                          $('#server_cpu_usage').attr('title', cpuavg + '%');
241                          $('#server_cpu_usage_txt').text( cpuavg+ '%');                          $('#server_cpu_usage_txt').text( cpuavg+ '%');
# Line 278  function refreshData() { Line 287  function refreshData() {
287                                  }                                  }
288                                  vm.find('.os').text(' - ' + os);                                  vm.find('.os').text(' - ' + os);
289    
290                                    cpuavg = cpuavg * 1;
291                                  vm.find('.cpu_graph').show();                                  vm.find('.cpu_graph').show();
292                                  vm.find('.cpu_graph').attr('src', 'usagebar.php?usage=' + cpuavg);                                  //vm.find('.cpu_graph').attr('src', 'usagebar.php?usage=' + cpuavg);
293                                    vm.find('.cpu_graph').progressbar( "value", cpuavg );
294                                  vm.find('.cpu_graph').attr('title',  cpuavg + '%');                                  vm.find('.cpu_graph').attr('title',  cpuavg + '%');
295    
296                                  vm.find('.mem_graph').show();                                  vm.find('.mem_graph').show();
297                                  vm.find('.mem_graph').attr('src', 'usagebar.php?usage=' + mempercent);                                  //vm.find('.mem_graph').attr('src', 'usagebar.php?usage=' + mempercent);
298                                    vm.find('.mem_graph').progressbar( "value", mempercent );
299                                  vm.find('.mem_graph').attr('title',  curmem + ' / ' + maxmem + ' MB' );                                  vm.find('.mem_graph').attr('title',  curmem + ' / ' + maxmem + ' MB' );
300                          } else {                          } else {
301                                  if (state == "Halted") {                                  if (state == "Halted") {
# Line 304  function refreshData() { Line 315  function refreshData() {
315                                  vm.find('.cpu_graph').hide();                                  vm.find('.cpu_graph').hide();
316                                  vm.find('.mem_graph').hide();                                  vm.find('.mem_graph').hide();
317                          }                          }
318                            vm.find('.state').attr('title', state);
319                                                    
320                  });                  });
321                  $('#logo').show();                  $('#logo').show();
# Line 407  body { Line 419  body {
419          margin: 4;          margin: 4;
420          border: 1px solid #222;          border: 1px solid #222;
421  }  }
422    
423    .ui-progressbar-value {
424            background: #61B4F3;
425    }
426    
427    .ui-progressbar {
428            border-style:solid;
429            border-width:1px;
430            border-color: #666666;
431    }
432    
433    .bar {
434            width:  102px;
435            height:  16px;
436    }
437    
438  </style>  </style>
439  </head>  </head>
440  <body>  <body>
# Line 424  body { Line 452  body {
452          </span>          </span>
453  </td>  </td>
454  <td width='150'></td>  <td width='150'></td>
455          <td width='150' align='right' class='small'><img src='gfx/icon-cpu.png'>          <td width='150' align='right' class='small'>
456                  <img id='server_cpu_usage' src='usagebar.php?usage=12' width='102' height='16' title='static dummy data'><div id='server_cpu_usage_txt'>12%</div></td>          <div id='server_cpu_usage' class='bar'></div>
457                    <img src='gfx/icon-cpu.png'>
458                    <span id='server_cpu_usage_txt'>12%</span>
459            </td>
460    
461          <td width='150' align='right' class='small'><img src='gfx/icon-memory.png'>          <td width='150' align='right' class='small'>
462                  <img id='server_memory_usage' src='usagebar.php?usage=1' width='102' height='16' title='static dummy data'><div id='server_memory_usage_txt'>0/4 MB</div></td>          <div id='server_memory_usage' class='bar'></div>
463                    <img src='gfx/icon-memory.png'>
464                    <span id='server_memory_usage_txt'>0/4 MB</span>
465        </td>
466  <!--  <!--
467          <td width='150' align='right' class='small'><img src='gfx/icon-network.png'>          <td width='150' align='right' class='small'><img src='gfx/icon-network.png'>
468                  <img id='server_net_usage' src='usagebar.php?usage=41' width='102' height='16' title='static dummy data'><div id='server_net_usage_txt'>1%</div></td>                  <img id='server_net_usage' src='usagebar.php?usage=41' width='102' height='16' title='static dummy data'><div id='server_net_usage_txt'>1%</div></td>
# Line 498  foreach($vms_array as $vm) { Line 532  foreach($vms_array as $vm) {
532                          <span class="actionstop" style='display:none'>                          <span class="actionstop" style='display:none'>
533                                  start |                                  start |
534                                  <a href='#' onclick="doAction('shutdown','<?php echo $uuid;?>','<?php echo $clean_name;?>')" >stop</a> |                                  <a href='#' onclick="doAction('shutdown','<?php echo $uuid;?>','<?php echo $clean_name;?>')" >stop</a> |
535                                  <a href='#' onclick="doAction('hardshutdown','<?php echo $uuid;?>','<?php echo $clean_name;?>')" >force shutdown</a>                                  <a href='#' onclick="doAction('hardshutdown','<?php echo $uuid;?>','<?php echo $clean_name;?>')" >force shutdown</a> |
536                                    <a href='#' onclick="doAction('hardreboot','<?php echo $uuid;?>','<?php echo $clean_name;?>')" >force reboot</a>
537                          </span>                          </span>
538                                                    
539                          <span class="actionstart" style='display:none'>                                          <span class="actionstart" style='display:none'>                
# Line 510  foreach($vms_array as $vm) { Line 545  foreach($vms_array as $vm) {
545                  </td>                  </td>
546    
547                  <td width='100' align='right' class='small' valign='top'>                  <td width='100' align='right' class='small' valign='top'>
548                          <img src='usagebar.php?usage=1' width='102' height='16' title='static dummy data' class='cpu_graph'><br>                          <div class='cpu_graph bar'></div>
549                          <img src='gfx/icon-cpu.png' style='vertical-align: middle;'>                          <img src='gfx/icon-cpu.png' style='vertical-align: middle;'>
550                          <span class='vps_cpu_usage_txt_UID'><?php echo $cpu_count; ?> VCPU</span>                          <span class='vps_cpu_usage_txt_UID'><?php echo $cpu_count; ?> VCPU</span>
551                  </td>                  </td>
552                  <td width='100' align='right' class='small'>                  <td width='100' align='right' class='small'>
553                          <img src='usagebar.php?usage=1' width='102' height='16' title='static dummy data' class='mem_graph'><br>                          <div class='mem_graph bar'></div>
554                          <img src='gfx/icon-memory.png' style='vertical-align: middle;'>                          <img src='gfx/icon-memory.png' style='vertical-align: middle;'>
555                          <span class='vps_memory_usage_txt_UID'><?php echo format_memory($memory); ?></span>                          <span class='vps_memory_usage_txt_UID'><?php echo format_memory($memory); ?></span>
556                  </td>                  </td>

Legend:
Removed from v.2028  
changed lines
  Added in v.2105

  ViewVC Help
Powered by ViewVC 1.1.20