New API: Add support for node_get_cpu_stats, node_get_mem_stats and connect_get_sysinfo
authorOlivier Doucet <odoucet@php.net>
Mon, 6 Aug 2012 12:57:12 +0000 (14:57 +0200)
committerMichal Novotny <minovotn@redhat.com>
Mon, 6 Aug 2012 12:57:12 +0000 (14:57 +0200)
This commit is adding support for functions to get node CPU and memory
statistics and node information.

Signed-off-by: Michal Novotny <minovotn@redhat.com>

classes/libvirt.php
lang/cs.php
lang/en.php
pages/info.php

index d8bf892..8def902 100644 (file)
                        $tmp = libvirt_node_get_info($this->conn);
                        return ($tmp) ? $tmp : $this->_set_last_error();
                }
+        
+        function node_get_cpu_stats() {
+            $tmp = libvirt_node_get_cpu_stats($this->conn);
+            return ($tmp) ? $tmp : $this->_set_last_error();
+        }
+        
+        function node_get_mem_stats() {
+            $tmp = libvirt_node_get_mem_stats($this->conn);
+            return ($tmp) ? $tmp : $this->_set_last_error();
+        }
+        
+        function connect_get_sysinfo() {
+            $tmp = libvirt_connect_get_sysinfo($this->conn);
+            return ($tmp) ? $tmp : $this->_set_last_error();
+        }
        }
 ?>
index f841658..5f604a4 100644 (file)
                                        'password_mismatch' => 'Heslo nebylo ověřeno',
                                        'screenshot-settings-auto-release' => 'Automaticky poslat událost uvolnění tlačítka myši',
                                        'screenshot-delay' => 'Interval byl změněn na %d sekund',
+                                       'cpu_stats' => 'CPU Statistiky uzlu',
+                                       'mem_stats' => 'Paměťové statistiky uzlu',
+                                       'system_information' => 'Systémové informace',
                                        );
 ?>
index e178067..7c7893b 100644 (file)
                                        'password_mismatch' => 'Password mismatch',
                                        'screenshot-settings-auto-release' => 'Send automatic mouse pointer release event',
                                        'screenshot-delay' => 'Delay has been changed to %d second(s)',
+                                       'cpu_stats' => 'Node CPU stats',
+                                       'mem_stats' => 'Node memory stats',
+                                       'system_information' => 'System information',
                                        );
 ?>
index 00f3710..8e59f14 100644 (file)
 <?php unset($tmp) ?>
 <div class="section"><?php echo $lang->get('modinfo') ?></div>
 <?php echo $out ?>
-
 </div>
+
+<div class="section"><?php echo $lang->get('cpu_stats'); ?></div>
+<?php 
+$tmp = $lv->node_get_cpu_stats();
+foreach ($tmp as $id => $data) {
+    echo '<div class="label">CPU #'.$id.'</div>';
+    echo '<div class="value">';
+    foreach ($data as $key => $val) {
+        echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.$val.'</div>';
+    }
+    echo '</div>';
+}
+?>
+<div style="clear:both"></div>
+<div class="section"><?php echo $lang->get('mem_stats'); ?></div>
+<?php 
+$tmp = $lv->node_get_mem_stats();
+foreach ($tmp as $id => $data) {
+    echo '<div class="label">CPU #'.$id.'</div>';
+    echo '<div class="value">';
+    foreach ($data as $key => $val) {
+        echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.$val.'</div>';
+    }
+    echo '</div>';
+}
+?>
+<div style="clear:both"></div>
+<div class="section"><?php echo $lang->get('system_information'); ?></div>
+<pre>
+<?php
+    $tmp = $lv->connect_get_sysinfo();
+    echo htmlentities($tmp);
+?>
+</pre>