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 |
|
var menu_uuid = ''; |
62 |
|
|
63 |
$(document).ready( function() { |
$(document).ready( function() { |
64 |
|
$("#menu").hide(); |
65 |
setInterval(refreshData, 60000); |
setInterval(refreshData, 60000); |
66 |
refreshData(); |
refreshData(); |
67 |
$('.console').click( function() { |
$('.console').click( function() { |
68 |
var session = $(this).data('session'); |
var session = $(this).data('session'); |
69 |
var conurl = $(this).data('conurl'); |
var conurl = $(this).data('conurl'); |
70 |
console(conurl,session); |
var name = $(this).data('name'); |
71 |
|
openConsole(conurl,session,name); |
72 |
}); |
}); |
73 |
|
|
74 |
$('#logo').click( function() { |
$('#logo').click( function() { |
75 |
refreshData(); |
refreshData(); |
76 |
}); |
}); |
77 |
|
|
78 |
|
$('.settings').click( function(event) { |
79 |
|
menu_uuid = $(this).attr('uuid'); |
80 |
|
|
81 |
|
$('#menu').menu( { |
82 |
|
select: function(event2,ui) { |
83 |
|
var action = $(ui.item).attr("action"); |
84 |
|
if (action == "memory") { |
85 |
|
doAction("setMemory", menu_uuid, ""); |
86 |
|
} |
87 |
|
if (action == "cpu") { |
88 |
|
doAction("setCPU", menu_uuid, ""); |
89 |
|
} |
90 |
|
}, |
91 |
|
create: function(event3,ui) { |
92 |
|
menu = 1; |
93 |
|
} |
94 |
|
/*position: { |
95 |
|
my: "left", of: event |
96 |
|
}*/ |
97 |
|
}); |
98 |
|
$('#menu').show().position( {my: "left top", of: event} ); |
99 |
|
event.stopPropagation(); |
100 |
|
}); |
101 |
|
|
102 |
|
$(document).click( function(event) { |
103 |
|
closeMenu(); |
104 |
|
}); |
105 |
|
|
106 |
}); |
}); |
107 |
|
|
108 |
|
function closeMenu() { |
109 |
|
if (menu > 0) { |
110 |
|
$("#menu").menu("destroy").hide(); |
111 |
|
menu = 0; |
112 |
|
} |
113 |
|
} |
114 |
|
|
115 |
function refreshData() { |
function refreshData() { |
116 |
|
$("#logo").hide(); |
117 |
$.get('ajaxdata.php', function(xml) { |
$.get('ajaxdata.php', function(xml) { |
118 |
$(xml).find('host').each(function() { |
$(xml).find('host').each(function() { |
119 |
var memtotal = $(this).find('memtotal').text(); |
var memtotal = $(this).find('memtotal').text(); |
146 |
var conurl = $(this).find('conurl').text(); |
var conurl = $(this).find('conurl').text(); |
147 |
var session = $(this).find('session').text(); |
var session = $(this).find('session').text(); |
148 |
var os = $(this).find('os').text(); |
var os = $(this).find('os').text(); |
149 |
|
var guestversion = $(this).find('guestversion').text(); |
150 |
var cpuavg = $(this).find('cpuavg').text(); |
var cpuavg = $(this).find('cpuavg').text(); |
151 |
|
var curmem = $(this).find('curmem').text(); |
152 |
|
var maxmem = $(this).find('maxmem').text(); |
153 |
|
var cpus = $(this).find('cpus').text(); |
154 |
|
|
155 |
|
var mempercent = Math.round( (curmem*100) / maxmem ); |
156 |
|
|
157 |
name = name.replace(" ", "_"); |
name = name.replace(" ", "_"); |
158 |
name = name.replace(".", "_"); |
name = name.replace(".", "_"); |
161 |
|
|
162 |
var vm = $(id); |
var vm = $(id); |
163 |
|
|
164 |
|
if (guestversion != '') { |
165 |
|
os += ' Guest Tools: ' + guestversion; |
166 |
|
} |
167 |
|
|
168 |
|
vm.find('.vps_memory_usage_txt_UID').text( maxmem + " MB"); |
169 |
|
vm.find('.vps_cpu_usage_txt_UID').text( cpus + " VCPU"); |
170 |
|
|
171 |
if (state == "Running") { |
if (state == "Running") { |
172 |
vm.find('.state').css("background-image", "url('gfx/vps_topgreen.png')"); |
vm.find('.state').css("background-image", "url('gfx/vps_topgreen.png')"); |
173 |
vm.find('.network').show(); |
vm.find('.network').show(); |
175 |
vm.find('.console').show(); |
vm.find('.console').show(); |
176 |
vm.find('.console').data('conurl', conurl); |
vm.find('.console').data('conurl', conurl); |
177 |
vm.find('.console').data('session', session); |
vm.find('.console').data('session', session); |
178 |
|
vm.find('.console').data('name', name); |
179 |
|
vm.find('.settings').hide(); |
180 |
vm.find('.actionstop').show(); |
vm.find('.actionstop').show(); |
181 |
vm.find('.actionstart').hide(); |
vm.find('.actionstart').hide(); |
182 |
vm.find('.os').text(' - ' + os); |
vm.find('.os').text(' - ' + os); |
185 |
vm.find('.cpu_graph').show(); |
vm.find('.cpu_graph').show(); |
186 |
vm.find('.cpu_graph').attr('src', 'usagebar.php?usage=' + cpuavg); |
vm.find('.cpu_graph').attr('src', 'usagebar.php?usage=' + cpuavg); |
187 |
vm.find('.cpu_graph').attr('title', cpuavg + '%'); |
vm.find('.cpu_graph').attr('title', cpuavg + '%'); |
188 |
|
|
189 |
vm.find('.mem_graph').show(); |
vm.find('.mem_graph').show(); |
190 |
|
vm.find('.mem_graph').attr('src', 'usagebar.php?usage=' + mempercent); |
191 |
|
vm.find('.mem_graph').attr('title', curmem + ' / ' + maxmem + ' MB' ); |
192 |
} else { |
} else { |
193 |
if (state == "Halted") { |
if (state == "Halted") { |
194 |
vm.find('.state').css("background-image", "url('gfx/vps_topred.png')"); |
vm.find('.state').css("background-image", "url('gfx/vps_topred.png')"); |
195 |
} else { |
} else { |
196 |
vm.find('.state').css("background-image", "url('gfx/vps_topyellow.png')"); |
vm.find('.state').css("background-image", "url('gfx/vps_topyellow.png')"); |
197 |
} |
} |
198 |
|
vm.find('.os').text(''); |
199 |
|
|
200 |
vm.find('.network').hide(); |
vm.find('.network').hide(); |
201 |
vm.find('.console').hide(); |
vm.find('.console').hide(); |
202 |
|
vm.find('.settings').show(); |
203 |
vm.find('.actionstop').hide(); |
vm.find('.actionstop').hide(); |
204 |
vm.find('.actionstart').show(); |
vm.find('.actionstart').show(); |
205 |
vm.find('.cpu_graph').hide(); |
vm.find('.cpu_graph').hide(); |
206 |
vm.find('.mem_graph').hide(); |
vm.find('.mem_graph').hide(); |
207 |
} |
} |
208 |
|
|
209 |
}) |
}); |
210 |
|
$('#logo').show(); |
211 |
}); |
}); |
212 |
} |
} |
213 |
|
|
214 |
function doAction(action, uuid, vm) { |
function doAction(action, uuid, vm) { |
215 |
|
var val=""; |
216 |
|
|
217 |
var key = prompt("Key"); |
var key = prompt("Key"); |
218 |
if (key == "" || key == null) { |
if (key == "" || key == null) { |
219 |
return; |
return; |
221 |
document.body.style.cursor = 'wait'; |
document.body.style.cursor = 'wait'; |
222 |
$('#vm_' + vm).find('.state').css("background-image", "url('gfx/vps_topyellow.png')"); |
$('#vm_' + vm).find('.state').css("background-image", "url('gfx/vps_topyellow.png')"); |
223 |
|
|
224 |
var url = "action.php?action=" + action + "&uuid=" + uuid + "&key=" + key; |
if (action == "setMemory") { |
225 |
|
val = prompt("Set memory target"); |
226 |
|
val *= (1024*1024); |
227 |
|
if (val == "" || val == null) { |
228 |
|
return; |
229 |
|
} |
230 |
|
} |
231 |
|
if (action == "setCPU") { |
232 |
|
val = prompt("Set CPU count"); |
233 |
|
if (val == "" || val == null) { |
234 |
|
return; |
235 |
|
} |
236 |
|
} |
237 |
|
|
238 |
|
var url = "action.php?action=" + action + "&uuid=" + uuid + "&key=" + key + "&val=" + val;; |
239 |
var response = $.get(url, function(data) { |
var response = $.get(url, function(data) { |
240 |
if (data != 'OK') { |
if (data != 'OK') { |
241 |
alert(data); |
alert(data); |
246 |
}); |
}); |
247 |
} |
} |
248 |
|
|
249 |
function console(url, session) { |
function openConsole(url, session, name) { |
250 |
if (url == '') |
if (url == '') |
251 |
return; |
return; |
252 |
|
|
254 |
if (key == "" || key == null) { |
if (key == "" || key == null) { |
255 |
return; |
return; |
256 |
} |
} |
257 |
var url = "console.php?url=" + url + "&session=" + session + "&key=" + key; |
var url = "console.php?url=" + url + "&session=" + session + "&key=" + key + "&name=" + name; |
258 |
|
|
259 |
//window.location = url; |
//window.location = url; |
260 |
//$('#mainwindow').load(url); |
//$('#mainwindow').load(url); |
304 |
<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'> |
305 |
<tr> |
<tr> |
306 |
<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> |
307 |
<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> |
308 |
</tr> |
</tr> |
309 |
<tr> |
<tr> |
310 |
|
<td width='150'></td> |
311 |
|
<td width='150'></td> |
312 |
<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'> |
313 |
<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> |
314 |
|
|
315 |
<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'> |
316 |
<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> |
317 |
|
<!-- |
318 |
<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'> |
319 |
<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> |
320 |
<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'> |
321 |
<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> |
|
|
|
322 |
</td> |
</td> |
323 |
|
--> |
324 |
</tr></table> |
</tr></table> |
325 |
|
|
326 |
|
|
333 |
} |
} |
334 |
|
|
335 |
$name = $vm["name_label"]; |
$name = $vm["name_label"]; |
336 |
|
$description = $vm["name_description"]; |
337 |
$uuid = $vm["uuid"]; |
$uuid = $vm["uuid"]; |
338 |
$state = $vm["power_state"] ; |
$state = $vm["power_state"] ; |
339 |
$memory = $vm['memory_target']; |
$memory = $vm['memory_target']; |
359 |
<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;?>'> |
360 |
<tr background='gfx/vps_topbg.png' > |
<tr background='gfx/vps_topbg.png' > |
361 |
<td width='10' class='small state'> </td> |
<td width='10' class='small state'> </td> |
362 |
<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> |
363 |
<td colspan='2' class='small' align='right'> |
<td colspan='2' class='small' align='right'> |
364 |
<span class='network'></span> |
<span class='network'></span> |
365 |
<a href='#' style='display:none;' class='console'> |
<a href='#' style='display:none;' class='console'> |
366 |
<img src='gfx/icon-terminal.png' style='vertical-align: middle;'> |
<img src='gfx/icon-terminal.png' style='vertical-align: middle;'> |
367 |
</a> |
</a> |
368 |
|
<a href='#' style='display:none;' class='settings' uuid='<?php echo $uuid;?>'> |
369 |
|
<img src='gfx/icon-settings16.png' style='vertical-align: middle;'> |
370 |
|
</a> |
371 |
</td> |
</td> |
372 |
</tr> |
</tr> |
373 |
|
|
392 |
<td width='100' align='right' class='small' valign='top'> |
<td width='100' align='right' class='small' valign='top'> |
393 |
<img src='usagebar.php?usage=1' width='102' height='16' title='static dummy data' class='cpu_graph'><br> |
<img src='usagebar.php?usage=1' width='102' height='16' title='static dummy data' class='cpu_graph'><br> |
394 |
<img src='gfx/icon-cpu.png' style='vertical-align: middle;'> |
<img src='gfx/icon-cpu.png' style='vertical-align: middle;'> |
395 |
<span id='vps_cpu_usage_txt_UID'><?php echo $cpu_count; ?> VCPU</span> |
<span class='vps_cpu_usage_txt_UID'><?php echo $cpu_count; ?> VCPU</span> |
396 |
</td> |
</td> |
397 |
<td width='100' align='right' class='small'> |
<td width='100' align='right' class='small'> |
398 |
<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> |
399 |
<img src='gfx/icon-memory.png' style='vertical-align: middle;'> |
<img src='gfx/icon-memory.png' style='vertical-align: middle;'> |
400 |
<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> |
401 |
</td> |
</td> |
402 |
<!-- |
<!-- |
403 |
<td width='100' align='right' class='small'> |
<td width='100' align='right' class='small'> |
405 |
<span id='vps_net_usage_txt_UID'>na</span> |
<span id='vps_net_usage_txt_UID'>na</span> |
406 |
</td> |
</td> |
407 |
--> |
--> |
408 |
<td width='100' align='right' class='small' valign='top'> |
<td width='100' align='right' class='small' valign='bottom'> |
409 |
<img src='gfx/icon-disk.png' style='vertical-align: middle;'> |
<img src='gfx/icon-disk.png' style='vertical-align: middle;'> |
410 |
<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> |
411 |
</td> |
</td> |
417 |
|
|
418 |
<?PHP } ?> |
<?PHP } ?> |
419 |
</td></tr></table> |
</td></tr></table> |
420 |
|
|
421 |
|
<br> |
422 |
|
|
423 |
|
<ul id="menu"> |
424 |
|
<li action="memory"><a href="#">Set Memory Size</a></li> |
425 |
|
<li action="cpu"><a href="#">Set CPU Count</a></li> |
426 |
|
|
427 |
|
|
428 |
|
<!-- <li><a href="#">Item 3</a> |
429 |
|
<ul> |
430 |
|
<li><a href="#">Item 3-1</a></li> |
431 |
|
<li><a href="#">Item 3-2</a></li> |
432 |
|
<li><a href="#">Item 3-3</a></li> |
433 |
|
<li><a href="#">Item 3-4</a></li> |
434 |
|
<li><a href="#">Item 3-5</a></li> |
435 |
|
</ul> |
436 |
|
</li> |
437 |
|
<li><a href="#">Item 4</a></li> |
438 |
|
<li><a href="#">Item 5</a></li>--> |
439 |
|
</ul> |
440 |
|
|
441 |
</body></html> |
</body></html> |
442 |
|
|