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

Diff of /misc/xenconsole/ajaxdata.php

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

revision 1891 by torben, Sun Dec 2 14:56:06 2012 UTC revision 1893 by torben, Mon Dec 3 11:25:39 2012 UTC
# Line 35  $host_metrics = $xenserver->host_metrics Line 35  $host_metrics = $xenserver->host_metrics
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) {
# Line 66  foreach($vms_array as $vmref => $vm) { Line 75  foreach($vms_array as $vmref => $vm) {
75                  if ($vm["guest_metrics"] != "OpaqueRef:NULL") {//guest tools installed                  if ($vm["guest_metrics"] != "OpaqueRef:NULL") {//guest tools installed
76                          $guest_metrics = $xenserver->VM_guest_metrics__get_record( $vm["guest_metrics"] );                          $guest_metrics = $xenserver->VM_guest_metrics__get_record( $vm["guest_metrics"] );
77                          $network = implode( ",",  $guest_metrics["networks"])  ;                          $network = implode( ",",  $guest_metrics["networks"])  ;
78                          $os =  $guest_metrics["os_version"]["name"];                          $tmpos =  explode('|', $guest_metrics["os_version"]["name"]);
79                            $os = $tmpos[0];
80                            
81                  }                  }
82                  $cpusum = 0.0;                  $cpusum = 0.0;
83                  for ($i=0; $i<$cpus; $i++) {                  for ($i=0; $i<$cpus; $i++) {

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

  ViewVC Help
Powered by ViewVC 1.1.20