New: Make information page output information specific to each CPU too
authorMichal Novotny <minovotn@redhat.com>
Tue, 7 Aug 2012 12:48:24 +0000 (14:48 +0200)
committerMichal Novotny <minovotn@redhat.com>
Tue, 7 Aug 2012 12:48:24 +0000 (14:48 +0200)
Signed-off-by: Michal Novotny <minovotn@redhat.com>

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

index 6815b31..536f2f1 100644 (file)
                                        'no-destination-present' => 'No destination present or connected',
                                        'choose-destination' => 'Choose migration destination',
                                        'dom_migrate' => 'Migrate domain',
+                                       'cpu_stats_per_each_cpu' => 'Node CPU stats per each CPU (one second average)',
                                        );
 
                        $this->trans = $trans;
index 28b40f7..a3039e6 100644 (file)
                        return ($tmp) ? $tmp : $this->_set_last_error();
                }
 
-               function node_get_cpu_stats() {
-                       $tmp = libvirt_node_get_cpu_stats($this->conn);
+               function node_get_cpu_stats_raw($cpu = VIR_NODE_CPU_STATS_ALL_CPUS) {
+                       $tmp = libvirt_node_get_cpu_stats($this->conn, $cpu);
+                       return ($tmp) ? $tmp : $this->_set_last_error();
+               }
+
+               function node_get_cpu_stats($cpu = VIR_NODE_CPU_STATS_ALL_CPUS) {
+                       $tmp = libvirt_node_get_cpu_stats($this->conn, $cpu);
                        if (!$tmp) return $this->_set_last_error();
 
                        // tmp has two array, collected at 1sec delay. Make a diff
                        foreach ($tmp[0] as $key => $elem) {
                                $newvalues[$key] = $tmp[1][$key] - $elem;
                        }
+                       $newvalues['cpus'] = $tmp['cpus'];
                        return $newvalues;
                }
 
index aba14bd..7ccd82d 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',
+                                       'cpu_stats' => 'CPU Statistiky uzlu (průměr za sekundu)',
                                        'mem_stats' => 'Paměťové statistiky uzlu',
                                        'system_information' => 'Systémové informace',
                                        'date-format' => 'd.m.Y H:i:s',
                                        'no-destination-present' => 'Žádný cíl není dostupný či na něj nejste připojeni',
                                        'choose-destination' => 'Zvolte cíl migrace',
                                        'dom_migrate' => 'Migrovat doménu',
+                                       'cpu_stats_per_each_cpu' => 'CPU Statistiky uzlu pro jednotlivá CPU (průměr za sekundu)',
                                        );
 ?>
index 6fc30d1..bd98165 100644 (file)
                                        'no-destination-present' => 'No destination present or connected',
                                        'choose-destination' => 'Choose migration destination',
                                        'dom_migrate' => 'Migrate domain',
+                                       'cpu_stats_per_each_cpu' => 'Node CPU stats per each CPU (one second average)',
                                        );
 ?>
index 9db6306..108ce66 100644 (file)
 <div class="section"><?php echo $lang->get('cpu_stats'); ?></div>
 <?php
 $tmp = $lv->node_get_cpu_stats();
+$numCpus = $tmp['cpus'];
 if (is_array($tmp)) foreach ($tmp as $name => $value) {
     echo '<div class="label">'.$name.'</div>';
     echo '<div class="value">'.$value.'</div><div class="nl">';
 }
 ?>
+<br />
+<div class="section"><?php echo $lang->get('cpu_stats_per_each_cpu'); ?></div>
+<?php
+for ($i = 0; $i < $numCpus; $i++) {
+    $tmp = $lv->node_get_cpu_stats_raw($i);
+    $newvalues = array();
+    foreach ($tmp[0] as $key => $elem) {
+        $newvalues[$key] = $tmp[1][$key] - $elem;
+    }
+    echo '<div class="label">CPU #'.$i.'</div>';
+    echo '<div class="value">';
+    foreach ($tmp[0] as $key => $val) {
+        $v = $tmp[1][$key] - $val;
+        if ($key != 'time')
+            echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.$v.'</div>';
+    }
+    echo '</div><br />';
+}
+?>
 <div style="clear:both"></div>
 <div class="section"><?php echo $lang->get('mem_stats'); ?></div>
 <?php
 $tmp = $lv->node_get_mem_stats();
 if (is_array($tmp)) foreach ($tmp as $name => $value) {
     echo '<div class="label">'.$name.'</div>';
-    echo '<div class="value">'.$value.'</div><div class="nl">';
+
+    if ($name != 'time')
+        echo '<div class="value">'.$value.'</div><div class="nl">';
+    else
+        echo '<div class="value">'.@Date($lang->get('date-format'), $value).'</div><div class="nl">';
 }
 ?>
+<br />
 <div style="clear:both"></div>
 <div class="section"><?php echo $lang->get('system_information'); ?></div>
 <pre>