/[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 1893 by torben, Mon Dec 3 11:25:39 2012 UTC revision 1956 by torben, Tue Mar 26 08:32:05 2013 UTC
# Line 40  $license = "License: " . $host["license_ Line 40  $license = "License: " . $host["license_
40    
41  $vms_array = $xenserver->VM__get_all_records();  $vms_array = $xenserver->VM__get_all_records();
42    
43    $namelabel = $host["name_label"];
44    
45  ?>  ?>
46  <html>  <html>
47  <head>  <head>
48  <title>XenServer::SERVER</title>  <title>XenServer::<?php echo $namelabel;?></title>
49  <script type='text/javascript' src="jquery-1.8.2.min.js"></script>  
50    <link rel="stylesheet" type="text/css" href="jquery/theme/jquery-ui.css">
51    <style>
52    .ui-menu {
53            width: 200px;
54    }
55    </style>
56    <script type='text/javascript' src="jquery/jquery-1.9.1.min.js"></script>
57    <script type='text/javascript' src="jquery/jquery-ui-1.10.2.min.js"></script>
58    
59  <script type='text/javascript'>  <script type='text/javascript'>
60    var menu = 0;
61    
62  $(document).ready( function() {  $(document).ready( function() {
63            $("#menu").hide();
64          setInterval(refreshData, 60000);                  setInterval(refreshData, 60000);        
65          refreshData();          refreshData();
66          $('.console').click( function() {          $('.console').click( function() {
67                  var session = $(this).data('session');                  var session = $(this).data('session');
68                  var conurl = $(this).data('conurl');                  var conurl = $(this).data('conurl');
69                  console(conurl,session);                  var name = $(this).data('name');
70                    console(conurl,session,name);
71          });          });
72    
73          $('#logo').click( function() {          $('#logo').click( function(event) {
74                  refreshData();                  //refreshData();
75                    $('#menu').show().position( {my: "left top", of: event} );
76    
77                    $('#menu').menu( {
78                            select: function(event2,ui) {
79                                            alert( ui.item.text() );
80                                            //closeMenu();
81                                    },
82                            create: function(event3,ui) {
83                                    menu = 1;
84                                    }
85                            /*position: {
86                                    my: "left", of: event
87                            }*/
88                    });
89                    event.stopPropagation();
90          });          });
91    
92            $(document).click( function(event) {
93                    closeMenu();
94            });
95    
96  });  });
97    
98    function closeMenu() {
99            if (menu > 0) {
100                    $("#menu").menu("destroy").hide();
101                    menu = 0;
102            }
103    }
104    
105  function refreshData() {  function refreshData() {
106            $("#logo").hide();      
107          $.get('ajaxdata.php', function(xml) {          $.get('ajaxdata.php', function(xml) {
108                  $(xml).find('host').each(function() {                  $(xml).find('host').each(function() {
109                          var memtotal = $(this).find('memtotal').text();                          var memtotal = $(this).find('memtotal').text();
# Line 95  function refreshData() { Line 136  function refreshData() {
136                          var conurl = $(this).find('conurl').text();                          var conurl = $(this).find('conurl').text();
137                          var session = $(this).find('session').text();                          var session = $(this).find('session').text();
138                          var os = $(this).find('os').text();                          var os = $(this).find('os').text();
139                            var guestversion = $(this).find('guestversion').text();
140                          var cpuavg = $(this).find('cpuavg').text();                          var cpuavg = $(this).find('cpuavg').text();
141                            var curmem = $(this).find('curmem').text();
142                            var maxmem = $(this).find('maxmem').text();
143    
144                            var mempercent = Math.round( (curmem*100) / maxmem );
145    
146                          name = name.replace(" ", "_");                          name = name.replace(" ", "_");
147                          name = name.replace(".", "_");                          name = name.replace(".", "_");
# Line 104  function refreshData() { Line 150  function refreshData() {
150    
151                          var vm = $(id);                                          var vm = $(id);                
152    
153                            if (guestversion != '') {
154                                    os += ' Guest Tools: ' + guestversion;
155                            }
156    
157                            vm.find('.vps_memory_usage_txt_UID').text( maxmem + " MB");
158    
159                          if (state == "Running") {                          if (state == "Running") {
160                                  vm.find('.state').css("background-image", "url('gfx/vps_topgreen.png')");                                  vm.find('.state').css("background-image", "url('gfx/vps_topgreen.png')");
161                                  vm.find('.network').show();                                  vm.find('.network').show();
# Line 111  function refreshData() { Line 163  function refreshData() {
163                                  vm.find('.console').show();                                  vm.find('.console').show();
164                                  vm.find('.console').data('conurl', conurl);                                  vm.find('.console').data('conurl', conurl);
165                                  vm.find('.console').data('session', session);                                  vm.find('.console').data('session', session);
166                                    vm.find('.console').data('name', name);
167                                  vm.find('.actionstop').show();                                  vm.find('.actionstop').show();
168                                  vm.find('.actionstart').hide();                                  vm.find('.actionstart').hide();
169                                  vm.find('.os').text(' - ' + os);                                  vm.find('.os').text(' - ' + os);
# Line 119  function refreshData() { Line 172  function refreshData() {
172                                  vm.find('.cpu_graph').show();                                  vm.find('.cpu_graph').show();
173                                  vm.find('.cpu_graph').attr('src', 'usagebar.php?usage=' + cpuavg);                                  vm.find('.cpu_graph').attr('src', 'usagebar.php?usage=' + cpuavg);
174                                  vm.find('.cpu_graph').attr('title',  cpuavg + '%');                                  vm.find('.cpu_graph').attr('title',  cpuavg + '%');
175    
176                                  vm.find('.mem_graph').show();                                  vm.find('.mem_graph').show();
177                                    vm.find('.mem_graph').attr('src', 'usagebar.php?usage=' + mempercent);
178                                    vm.find('.mem_graph').attr('title',  curmem + ' / ' + maxmem + ' MB' );
179                          } else {                          } else {
180                                  if (state == "Halted") {                                  if (state == "Halted") {
181                                          vm.find('.state').css("background-image", "url('gfx/vps_topred.png')");                                          vm.find('.state').css("background-image", "url('gfx/vps_topred.png')");
182                                  } else {                                  } else {
183                                          vm.find('.state').css("background-image", "url('gfx/vps_topyellow.png')");                                          vm.find('.state').css("background-image", "url('gfx/vps_topyellow.png')");
184                                  }                                  }
185                                    vm.find('.os').text('');
186    
187                                  vm.find('.network').hide();                                  vm.find('.network').hide();
188                                  vm.find('.console').hide();                                  vm.find('.console').hide();
189                                  vm.find('.actionstop').hide();                                  vm.find('.actionstop').hide();
# Line 134  function refreshData() { Line 192  function refreshData() {
192                                  vm.find('.mem_graph').hide();                                  vm.find('.mem_graph').hide();
193                          }                          }
194                                                    
195                  })                  });
196                    $('#logo').show();
197         });         });
198  }  }
199    
200  function doAction(action, uuid, vm) {  function doAction(action, uuid, vm) {
201            var val="";
202    
203          var key = prompt("Key");          var key = prompt("Key");
204          if (key == "" || key == null) {          if (key == "" || key == null) {
205                  return;                  return;
# Line 146  function doAction(action, uuid, vm) { Line 207  function doAction(action, uuid, vm) {
207          document.body.style.cursor = 'wait';          document.body.style.cursor = 'wait';
208          $('#vm_' + vm).find('.state').css("background-image", "url('gfx/vps_topyellow.png')");          $('#vm_' + vm).find('.state').css("background-image", "url('gfx/vps_topyellow.png')");
209    
210          var url = "action.php?action=" + action + "&uuid=" + uuid + "&key=" + key;          if (action == "setMemory") {
211                    val = prompt("Set memory target");
212                    if (val == "" || val == null) {
213                            alert("" + val);
214                            return;
215                    }
216            }
217    
218            var url = "action.php?action=" + action + "&uuid=" + uuid + "&key=" + key + "&val=" + val;;
219          var response = $.get(url, function(data) {          var response = $.get(url, function(data) {
220                  if (data != 'OK') {                  if (data != 'OK') {
221                          alert(data);                          alert(data);
# Line 157  function doAction(action, uuid, vm) { Line 226  function doAction(action, uuid, vm) {
226          });          });
227  }  }
228    
229  function console(url, session) {  function console(url, session, name) {
230          if (url == '')          if (url == '')
231                  return;                  return;
232    
# Line 165  function console(url, session) { Line 234  function console(url, session) {
234          if (key == "" || key == null) {          if (key == "" || key == null) {
235                  return;                  return;
236          }          }
237          var url = "console.php?url=" + url + "&session=" + session + "&key=" + key;          var url = "console.php?url=" + url + "&session=" + session + "&key=" + key + "&name=" + name;
238    
239          //window.location = url;          //window.location = url;
240          //$('#mainwindow').load(url);          //$('#mainwindow').load(url);
# Line 215  body { Line 284  body {
284  <table width='100%' background='gfx/topbg.png' cellpadding='3' cellspacing='0' border='0' class='toptable'>  <table width='100%' background='gfx/topbg.png' cellpadding='3' cellspacing='0' border='0' class='toptable'>
285  <tr>  <tr>
286          <td rowspan='2' width='160'><img src='gfx/citrix-logo.png' id='logo'></td>          <td rowspan='2' width='160'><img src='gfx/citrix-logo.png' id='logo'></td>
287          <td colspan='4' class='small' align='right'><?php echo $xenversion;?><br><?php echo $license;?></td>          <td colspan='4' class='small' align='right'><?php echo $namelabel . " / " . $xenversion;?><br><?php echo $license;?></td>
288  </tr>  </tr>
289  <tr>  <tr>
290    <td width='150'></td>
291    <td width='150'></td>
292          <td width='150' align='right' class='small'><img src='gfx/icon-cpu.png'>          <td width='150' align='right' class='small'><img src='gfx/icon-cpu.png'>
293                  <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>                  <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>
294    
295          <td width='150' align='right' class='small'><img src='gfx/icon-memory.png'>          <td width='150' align='right' class='small'><img src='gfx/icon-memory.png'>
296                  <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>                  <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>
297    <!--
298          <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'>
299                  <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>
300          <td width='150' align='right' class='small'><img src='gfx/icon-disk.png'>          <td width='150' align='right' class='small'><img src='gfx/icon-disk.png'>
301                  <img id='server_disk_usage' src='usagebar.php?usage=41' width='102' height='16' title='static dummy data'><div id='server_memory_usage_txt'>89.3/405.5 GB</div></td>                  <img id='server_disk_usage' src='usagebar.php?usage=41' width='102' height='16' title='static dummy data'><div id='server_memory_usage_txt'>89.3/405.5 GB</div></td>
   
302          </td>          </td>
303    -->
304  </tr></table>  </tr></table>
305    
306    
# Line 242  foreach($vms_array as $vm) { Line 313  foreach($vms_array as $vm) {
313          }          }
314    
315          $name = $vm["name_label"];          $name = $vm["name_label"];
316            $description = $vm["name_description"];
317          $uuid = $vm["uuid"];          $uuid = $vm["uuid"];
318          $state = $vm["power_state"] ;          $state = $vm["power_state"] ;
319          $memory = $vm['memory_target'];          $memory = $vm['memory_target'];
# Line 267  foreach($vms_array as $vm) { Line 339  foreach($vms_array as $vm) {
339          <table width='99%' cellpadding='3' cellspacing='0' border='0' class='vps' id='vm_<?php echo $clean_name;?>'>          <table width='99%' cellpadding='3' cellspacing='0' border='0' class='vps' id='vm_<?php echo $clean_name;?>'>
340                  <tr background='gfx/vps_topbg.png'  >                  <tr background='gfx/vps_topbg.png'  >
341                          <td width='10' class='small state'>&nbsp;</td>                          <td width='10' class='small state'>&nbsp;</td>
342                          <td colspan='2' class='small'><b><?php echo $name; ?></b><span class='os'></span></td>                          <td colspan='2' class='small' title='<?php echo $description;?>'><b><?php echo $name; ?></b><span class='os'></span></td>
343                          <td colspan='2' class='small' align='right'>                          <td colspan='2' class='small' align='right'>
344                                  <span class='network'></span>                                  <span class='network'></span>
345                                  <a href='#' style='display:none;' class='console'>                                  <a href='#' style='display:none;' class='console'>
# Line 283  foreach($vms_array as $vm) { Line 355  foreach($vms_array as $vm) {
355                          <span class="actionstop" style='display:none'>                          <span class="actionstop" style='display:none'>
356                                  start |                                  start |
357                                  <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> |
358                                  <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> |
359                                    set memory
360                          </span>                          </span>
361                                                    
362                          <span class="actionstart">                                                <span class="actionstart">                      
363                                  <a href='#' onclick="doAction('start','<?php echo $uuid;?>','<?php echo $clean_name;?>')" >start</a> |                                  <a href='#' onclick="doAction('start','<?php echo $uuid;?>','<?php echo $clean_name;?>')" >start</a> |
364                                  stop |                                  stop |
365                                  force shutdown                                  force shutdown |
366    
367                                    <a href='#' onclick="doAction('setMemory','<?php echo $uuid;?>','<?php echo $clean_name;?>')" >set memory</a>
368                          </span>                          </span>
369    
370                  </td>                  </td>
# Line 302  foreach($vms_array as $vm) { Line 377  foreach($vms_array as $vm) {
377                  <td width='100' align='right' class='small'>                  <td width='100' align='right' class='small'>
378                          <img src='usagebar.php?usage=1' width='102' height='16' title='static dummy data' class='mem_graph'><br>                          <img src='usagebar.php?usage=1' width='102' height='16' title='static dummy data' class='mem_graph'><br>
379                          <img src='gfx/icon-memory.png' style='vertical-align: middle;'>                          <img src='gfx/icon-memory.png' style='vertical-align: middle;'>
380                          <span id='vps_memory_usage_txt_UID'><?php echo format_memory($memory); ?></span>                          <span class='vps_memory_usage_txt_UID'><?php echo format_memory($memory); ?></span>
381                  </td>                  </td>
382  <!--  <!--
383                  <td width='100' align='right' class='small'>                  <td width='100' align='right' class='small'>
# Line 310  foreach($vms_array as $vm) { Line 385  foreach($vms_array as $vm) {
385                          <span id='vps_net_usage_txt_UID'>na</span>                          <span id='vps_net_usage_txt_UID'>na</span>
386                  </td>                  </td>
387  -->  -->
388                  <td width='100' align='right' class='small' valign='top'>                  <td width='100' align='right' class='small' valign='bottom'>
389                          <img src='gfx/icon-disk.png' style='vertical-align: middle;'>                          <img src='gfx/icon-disk.png' style='vertical-align: middle;'>
390                          <span id='vps_disk_usage_txt_UID'><?php echo format_storage($harddrive_size); ?></span>                          <span id='vps_disk_usage_txt_UID'><?php echo format_storage($harddrive_size); ?></span>
391                  </td>                  </td>
# Line 322  foreach($vms_array as $vm) { Line 397  foreach($vms_array as $vm) {
397    
398  <?PHP } ?>  <?PHP } ?>
399  </td></tr></table>  </td></tr></table>
400    
401    <ul id="menu">
402            <li><a href="#">Item 1</a></li>
403            <li><a href="#">Item 2</a></li>
404            <li><a href="#">Item 3</a>
405                    <ul>
406                            <li><a href="#">Item 3-1</a></li>
407                            <li><a href="#">Item 3-2</a></li>
408                            <li><a href="#">Item 3-3</a></li>
409                            <li><a href="#">Item 3-4</a></li>
410                            <li><a href="#">Item 3-5</a></li>
411                    </ul>
412            </li>
413            <li><a href="#">Item 4</a></li>
414            <li><a href="#">Item 5</a></li>
415    </ul>
416    
417  </body></html>  </body></html>
418    

Legend:
Removed from v.1893  
changed lines
  Added in v.1956

  ViewVC Help
Powered by ViewVC 1.1.20