Hi Olivier,
I'm writing once again, since there are few things that are wrong:
The information on the info page doesn't mean it's CPU #0 and CPU #1.
Those are just 2 tries in the one second delay of the same thing for all
the CPUs. I'm going to fix it now. Do you want the functionality to
select the CPU ? To be able to get the information relevant to just this
one CPU? If so, the libvirt-php module is not ready for this, however it
may be a good thing. Currently, it's just doing the aggregation of
values per all memory cells and all CPUs and then it's waiting a second
and trying it again to get the delta (difference) - virsh does it
similar way according to the code so that's where I got inspired.
Do you want me to implement selecting the CPUs/memory cells ? I need to
investigate it a little further.
I pushed a new commit to the repository to output the real and valid
information.
Also, when writing the subject of patch, please make it specify the
functionality - like "New API: Implement blah function" etc.
Thanks,
Michal
On 08/06/2012 03:35 PM, Olivier Doucet wrote:
---
classes/libvirt.php | 15 +++++++++++++++
lang/cs.php | 3 +++
lang/en.php | 3 +++
pages/info.php | 35 ++++++++++++++++++++++++++++++++++-
4 files changed, 55 insertions(+), 1 deletions(-)
diff --git a/classes/libvirt.php b/classes/libvirt.php
index d8bf892..8def902 100644
--- a/classes/libvirt.php
+++ b/classes/libvirt.php
@@ -1601,5 +1601,20 @@
$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();
+ }
}
?>
diff --git a/lang/cs.php b/lang/cs.php
index f841658..115ef27 100644
--- a/lang/cs.php
+++ b/lang/cs.php
@@ -300,5 +300,8 @@
'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' => 'Node CPU stats',
+ 'mem_stats' => 'Node memory stats',
+ 'system_information' => 'System information',
);
?>
diff --git a/lang/en.php b/lang/en.php
index e178067..45d54a4 100644
--- a/lang/en.php
+++ b/lang/en.php
@@ -301,5 +301,8 @@
'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',
);
?>
diff --git a/pages/info.php b/pages/info.php
index 00f3710..8e59f14 100644
--- a/pages/info.php
+++ b/pages/info.php
@@ -122,5 +122,38 @@
<?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>
_______________________________________________
php-virt-control mailing list
php-virt-control(a)lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/php-virt-control
--
Michal Novotny <minovotn(a)redhat.com>, RHCE, Red Hat
Virtualization | libvirt-php bindings |
php-virt-control.org