35 |
$mem_total = $host_metrics["memory_total"]; |
$mem_total = $host_metrics["memory_total"]; |
36 |
$mem_free = $host_metrics["memory_free"]; |
$mem_free = $host_metrics["memory_free"]; |
37 |
|
|
38 |
$vms_array = $xenserver->VM__get_all_records(); |
$cpus = $host["cpu_info"]["cpu_count"]; |
39 |
|
$cpusum = 0.0; |
40 |
|
for ($i=0; $i<$cpus; $i++) { |
41 |
|
$cpusum += $xenserver->host__query_data_source($hosts_array[0], "cpu" . $i); |
42 |
|
} |
43 |
|
$cpuavg = round ( ($cpusum/$cpus) * 100); |
44 |
|
|
45 |
header("Content-Type: text/xml"); |
header("Content-Type: text/xml"); |
46 |
echo "<xen>"; |
echo "<xen>"; |
47 |
echo "<host>"; |
echo "<host>"; |
48 |
echo "<memtotal>{$mem_total}</memtotal>"; |
echo "<memtotal>{$mem_total}</memtotal>"; |
49 |
echo "<memfree>{$mem_free}</memfree>"; |
echo "<memfree>{$mem_free}</memfree>"; |
50 |
|
echo "<cpuavg>{$cpuavg}</cpuavg>"; |
51 |
echo "</host>"; |
echo "</host>"; |
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
$vms_array = $xenserver->VM__get_all_records(); |
56 |
// List all machines |
// List all machines |
57 |
foreach($vms_array as $vmref => $vm) { |
foreach($vms_array as $vmref => $vm) { |
58 |
if ($vm["is_a_template"] != 0 || $vm["is_control_domain"] != 0) { |
if ($vm["is_a_template"] != 0 || $vm["is_control_domain"] != 0) { |