Problem with php-virt-control
by Quentin Jeauffroy
Hi,
I'm starting to use php-virt-control for my summer internship, so excuse my
silly questions but I'm really struggling with this issue :
I used Xen Hypervisor 4.1 and try to control it with libvirt-php.
After installing php-virt-control, nothing appear on the main page : "No
connection defined", but Domains are detected on "Domain list". On the
"Information" page, I have everything right and had set the right "ISO
image path".
That is a little disturbing but everything seems good.
My problem is when I want to create a new VM.
I'm using a normal iso of ubuntu 12.04 desktop i386, and have set a new
setup disk image.
It give me the error : "internal error unexpected domain type kvm,
expecting xen"
I've then modify the XML of ./classes/libvirt.php and replace kvm by xen on
"<domain type=" by instinct.
A new error appear : "POST operation failed: xend_post: error from xen
daemon: (xend.err "Error creating domain: device model '\n\n \n \n x86_64\n
\n \n \n \n \n \n \n \n \n \n \n \n xenmigr\n \n \n \n\n \n xen\n \n 64\n
/usr/lib/xen-default/bin/qemu-
dm\n xenpv\n \n \n \n \n\n \n xen\n \n 32\n
/usr/lib/xen-default/bin/qemu-dm\n xenpv\n \n \n \n \n \n \n \n\n \n hvm\n
\n 32\n /usr/lib/xen-default/bin/qemu-dm\n
/usr/lib/xen-default/boot/hvmloader\n xenfv\n \n \n \n \n \n \n \n \n \n \n
\n \n\n \n hvm\n \n 64\n /usr/lib/xen-default/bin/qemu-dm\n
/usr/lib/xen-default/boot/hvmloader\n xenfv\n \n \n \n \n \n \n \n \n \n
\n\n\n' not found")"
Any ideas ?
Can we speak about it on an irc chan ?
Thank you for your help.
Regards,
Quentin
10 years, 9 months
He Gained Nearly 2 Inches
by Gera Wynn
Viagrow is the only pill that can guarantee fast enlargemnt... gain 10 inches in few weeks!
Best and cheaperst GROW PRODUCT in a super offer for you today!
It's so very easy - like 123!
http://sadwgi.viagrowafg.ru
went countenance fertile graffing shrunk arch oracles night from precks.
basche for proof continually custom sausage figure exonerate passion belly.
10 years, 9 months
I have already seen gains after just a couple of days
by Saira Dutton
Viagrow is the only pill that can guarantee fast enlargemnt... gain 10 inches in few weeks!
Best and cheaperst GROW PRODUCT in a super offer for you today!
It's so very easy - like 123!
http://fjrofgdue.viagrowafs.ru
respectfully before wellpaid silvered used former himself outrage mountainous land.
characters presidents murder spoke asked divarication skin draught give related.
10 years, 9 months
[PATCH] change Libvirt::node_get_cpu_stats() output
by Olivier Doucet
Handle node_get_cpu_stats() output change
---
classes/libvirt.php | 39 +++++++++++++++++++++++----------------
lang/en.php | 2 +-
pages/info.php | 30 ++++++++----------------------
3 files changed, 32 insertions(+), 39 deletions(-)
diff --git a/classes/libvirt.php b/classes/libvirt.php
index e8fce08..46da82b 100644
--- a/classes/libvirt.php
+++ b/classes/libvirt.php
@@ -1601,20 +1601,27 @@
$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();
- }
- }
-?>
+ $tmp = libvirt_node_get_cpu_stats($this->conn);
+ if (!$tmp) return $this->_set_last_error();
+
+ // tmp has two array, collected at 1sec delay. Make a diff
+ $newvalues = array();
+ foreach ($tmp[0] as $key => $elem) {
+ $newvalues[$key] = $tmp[1][$key] - $elem;
+ }
+ return $newvalues;
+ }
+
+ 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();
+ }
+ }
+?>
\ No newline at end of file
diff --git a/lang/en.php b/lang/en.php
index 931f92c..dbd8fde 100644
--- a/lang/en.php
+++ b/lang/en.php
@@ -301,7 +301,7 @@
'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',
+ 'cpu_stats' => 'Node CPU stats (one second average)',
'mem_stats' => 'Node memory stats',
'system_information' => 'System information',
'date-format' => 'Y-m-d H:i:s',
diff --git a/pages/info.php b/pages/info.php
index ac20183..b02b72d 100644
--- a/pages/info.php
+++ b/pages/info.php
@@ -125,34 +125,20 @@
</div>
<div class="section"><?php echo $lang->get('cpu_stats'); ?></div>
-<?php
+<?php
$tmp = $lv->node_get_cpu_stats();
-foreach ($tmp as $id => $data) {
- echo '<div class="label">'.$lang->get('run').' #'.$id.'</div>';
- echo '<div class="value">';
- foreach ($data as $key => $val) {
- if ($key != 'time')
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.$val.'</div>';
- else
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.@Date($lang->get('date-format'), $val).'</div>';
- }
- echo '</div><br />';
+if (is_array($tmp)) foreach ($tmp as $name => $value) {
+ echo '<div class="label">'.$name.'</div>';
+ echo '<div class="value">'.$value.'</div><div class="nl">';
}
?>
<div style="clear:both"></div>
<div class="section"><?php echo $lang->get('mem_stats'); ?></div>
-<?php
+<?php
$tmp = $lv->node_get_mem_stats();
-foreach ($tmp as $id => $data) {
- echo '<div class="label">'.$lang->get('run').' #'.$id.'</div>';
- echo '<div class="value">';
- foreach ($data as $key => $val) {
- if ($key != 'time')
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.$val.'</div>';
- else
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.@Date($lang->get('date-format'), $val).'</div>';
- }
- echo '</div><br />';
+if (is_array($tmp)) foreach ($tmp as $name => $value) {
+ echo '<div class="label">'.$name.'</div>';
+ echo '<div class="value">'.$value.'</div><div class="nl">';
}
?>
<div style="clear:both"></div>
--
1.7.4
10 years, 9 months
[PATCH] change Libvirt::node_get_cpu_stats() output[PATCH] change Libvirt::node_get_cpu_stats() output[PATCH] change Libvirt::node_get_cpu_stats() output
by Olivier Doucet
Handle node_get_cpu_stats() output change
---
classes/libvirt.php | 39 +++++++++++++++++++++++----------------
lang/en.php | 2 +-
pages/info.php | 30 ++++++++----------------------
3 files changed, 32 insertions(+), 39 deletions(-)
diff --git a/classes/libvirt.php b/classes/libvirt.php
index e8fce08..46da82b 100644
--- a/classes/libvirt.php
+++ b/classes/libvirt.php
@@ -1601,20 +1601,27 @@
$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();
- }
- }
-?>
+ $tmp = libvirt_node_get_cpu_stats($this->conn);
+ if (!$tmp) return $this->_set_last_error();
+
+ // tmp has two array, collected at 1sec delay. Make a diff
+ $newvalues = array();
+ foreach ($tmp[0] as $key => $elem) {
+ $newvalues[$key] = $tmp[1][$key] - $elem;
+ }
+ return $newvalues;
+ }
+
+ 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();
+ }
+ }
+?>
\ No newline at end of file
diff --git a/lang/en.php b/lang/en.php
index 931f92c..dbd8fde 100644
--- a/lang/en.php
+++ b/lang/en.php
@@ -301,7 +301,7 @@
'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',
+ 'cpu_stats' => 'Node CPU stats (one second average)',
'mem_stats' => 'Node memory stats',
'system_information' => 'System information',
'date-format' => 'Y-m-d H:i:s',
diff --git a/pages/info.php b/pages/info.php
index ac20183..b02b72d 100644
--- a/pages/info.php
+++ b/pages/info.php
@@ -125,34 +125,20 @@
</div>
<div class="section"><?php echo $lang->get('cpu_stats'); ?></div>
-<?php
+<?php
$tmp = $lv->node_get_cpu_stats();
-foreach ($tmp as $id => $data) {
- echo '<div class="label">'.$lang->get('run').' #'.$id.'</div>';
- echo '<div class="value">';
- foreach ($data as $key => $val) {
- if ($key != 'time')
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.$val.'</div>';
- else
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.@Date($lang->get('date-format'), $val).'</div>';
- }
- echo '</div><br />';
+if (is_array($tmp)) foreach ($tmp as $name => $value) {
+ echo '<div class="label">'.$name.'</div>';
+ echo '<div class="value">'.$value.'</div><div class="nl">';
}
?>
<div style="clear:both"></div>
<div class="section"><?php echo $lang->get('mem_stats'); ?></div>
-<?php
+<?php
$tmp = $lv->node_get_mem_stats();
-foreach ($tmp as $id => $data) {
- echo '<div class="label">'.$lang->get('run').' #'.$id.'</div>';
- echo '<div class="value">';
- foreach ($data as $key => $val) {
- if ($key != 'time')
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.$val.'</div>';
- else
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.@Date($lang->get('date-format'), $val).'</div>';
- }
- echo '</div><br />';
+if (is_array($tmp)) foreach ($tmp as $name => $value) {
+ echo '<div class="label">'.$name.'</div>';
+ echo '<div class="value">'.$value.'</div><div class="nl">';
}
?>
<div style="clear:both"></div>
--
1.7.4
Handle node_get_cpu_stats() output change
---
classes/libvirt.php | 39 +++++++++++++++++++++++----------------
lang/en.php | 2 +-
pages/info.php | 30 ++++++++----------------------
3 files changed, 32 insertions(+), 39 deletions(-)
diff --git a/classes/libvirt.php b/classes/libvirt.php
index e8fce08..46da82b 100644
--- a/classes/libvirt.php
+++ b/classes/libvirt.php
@@ -1601,20 +1601,27 @@
$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();
- }
- }
-?>
+ $tmp = libvirt_node_get_cpu_stats($this->conn);
+ if (!$tmp) return $this->_set_last_error();
+
+ // tmp has two array, collected at 1sec delay. Make a diff
+ $newvalues = array();
+ foreach ($tmp[0] as $key => $elem) {
+ $newvalues[$key] = $tmp[1][$key] - $elem;
+ }
+ return $newvalues;
+ }
+
+ 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();
+ }
+ }
+?>
\ No newline at end of file
diff --git a/lang/en.php b/lang/en.php
index 931f92c..dbd8fde 100644
--- a/lang/en.php
+++ b/lang/en.php
@@ -301,7 +301,7 @@
'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',
+ 'cpu_stats' => 'Node CPU stats (one second average)',
'mem_stats' => 'Node memory stats',
'system_information' => 'System information',
'date-format' => 'Y-m-d H:i:s',
diff --git a/pages/info.php b/pages/info.php
index ac20183..b02b72d 100644
--- a/pages/info.php
+++ b/pages/info.php
@@ -125,34 +125,20 @@
</div>
<div class="section"><?php echo $lang->get('cpu_stats'); ?></div>
-<?php
+<?php
$tmp = $lv->node_get_cpu_stats();
-foreach ($tmp as $id => $data) {
- echo '<div class="label">'.$lang->get('run').' #'.$id.'</div>';
- echo '<div class="value">';
- foreach ($data as $key => $val) {
- if ($key != 'time')
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.$val.'</div>';
- else
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.@Date($lang->get('date-format'), $val).'</div>';
- }
- echo '</div><br />';
+if (is_array($tmp)) foreach ($tmp as $name => $value) {
+ echo '<div class="label">'.$name.'</div>';
+ echo '<div class="value">'.$value.'</div><div class="nl">';
}
?>
<div style="clear:both"></div>
<div class="section"><?php echo $lang->get('mem_stats'); ?></div>
-<?php
+<?php
$tmp = $lv->node_get_mem_stats();
-foreach ($tmp as $id => $data) {
- echo '<div class="label">'.$lang->get('run').' #'.$id.'</div>';
- echo '<div class="value">';
- foreach ($data as $key => $val) {
- if ($key != 'time')
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.$val.'</div>';
- else
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.@Date($lang->get('date-format'), $val).'</div>';
- }
- echo '</div><br />';
+if (is_array($tmp)) foreach ($tmp as $name => $value) {
+ echo '<div class="label">'.$name.'</div>';
+ echo '<div class="value">'.$value.'</div><div class="nl">';
}
?>
<div style="clear:both"></div>
--
1.7.4
Handle node_get_cpu_stats() output change
---
classes/libvirt.php | 39 +++++++++++++++++++++++----------------
lang/en.php | 2 +-
pages/info.php | 30 ++++++++----------------------
3 files changed, 32 insertions(+), 39 deletions(-)
diff --git a/classes/libvirt.php b/classes/libvirt.php
index e8fce08..46da82b 100644
--- a/classes/libvirt.php
+++ b/classes/libvirt.php
@@ -1601,20 +1601,27 @@
$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();
- }
- }
-?>
+ $tmp = libvirt_node_get_cpu_stats($this->conn);
+ if (!$tmp) return $this->_set_last_error();
+
+ // tmp has two array, collected at 1sec delay. Make a diff
+ $newvalues = array();
+ foreach ($tmp[0] as $key => $elem) {
+ $newvalues[$key] = $tmp[1][$key] - $elem;
+ }
+ return $newvalues;
+ }
+
+ 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();
+ }
+ }
+?>
\ No newline at end of file
diff --git a/lang/en.php b/lang/en.php
index 931f92c..dbd8fde 100644
--- a/lang/en.php
+++ b/lang/en.php
@@ -301,7 +301,7 @@
'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',
+ 'cpu_stats' => 'Node CPU stats (one second average)',
'mem_stats' => 'Node memory stats',
'system_information' => 'System information',
'date-format' => 'Y-m-d H:i:s',
diff --git a/pages/info.php b/pages/info.php
index ac20183..b02b72d 100644
--- a/pages/info.php
+++ b/pages/info.php
@@ -125,34 +125,20 @@
</div>
<div class="section"><?php echo $lang->get('cpu_stats'); ?></div>
-<?php
+<?php
$tmp = $lv->node_get_cpu_stats();
-foreach ($tmp as $id => $data) {
- echo '<div class="label">'.$lang->get('run').' #'.$id.'</div>';
- echo '<div class="value">';
- foreach ($data as $key => $val) {
- if ($key != 'time')
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.$val.'</div>';
- else
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.@Date($lang->get('date-format'), $val).'</div>';
- }
- echo '</div><br />';
+if (is_array($tmp)) foreach ($tmp as $name => $value) {
+ echo '<div class="label">'.$name.'</div>';
+ echo '<div class="value">'.$value.'</div><div class="nl">';
}
?>
<div style="clear:both"></div>
<div class="section"><?php echo $lang->get('mem_stats'); ?></div>
-<?php
+<?php
$tmp = $lv->node_get_mem_stats();
-foreach ($tmp as $id => $data) {
- echo '<div class="label">'.$lang->get('run').' #'.$id.'</div>';
- echo '<div class="value">';
- foreach ($data as $key => $val) {
- if ($key != 'time')
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.$val.'</div>';
- else
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.@Date($lang->get('date-format'), $val).'</div>';
- }
- echo '</div><br />';
+if (is_array($tmp)) foreach ($tmp as $name => $value) {
+ echo '<div class="label">'.$name.'</div>';
+ echo '<div class="value">'.$value.'</div><div class="nl">';
}
?>
<div style="clear:both"></div>
--
1.7.4
10 years, 9 months
[PATCH] change Libvirt::node_get_cpu_stats() output[PATCH] change Libvirt::node_get_cpu_stats() output
by Olivier Doucet
Handle node_get_cpu_stats() output change
---
classes/libvirt.php | 39 +++++++++++++++++++++++----------------
lang/en.php | 2 +-
pages/info.php | 30 ++++++++----------------------
3 files changed, 32 insertions(+), 39 deletions(-)
diff --git a/classes/libvirt.php b/classes/libvirt.php
index e8fce08..46da82b 100644
--- a/classes/libvirt.php
+++ b/classes/libvirt.php
@@ -1601,20 +1601,27 @@
$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();
- }
- }
-?>
+ $tmp = libvirt_node_get_cpu_stats($this->conn);
+ if (!$tmp) return $this->_set_last_error();
+
+ // tmp has two array, collected at 1sec delay. Make a diff
+ $newvalues = array();
+ foreach ($tmp[0] as $key => $elem) {
+ $newvalues[$key] = $tmp[1][$key] - $elem;
+ }
+ return $newvalues;
+ }
+
+ 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();
+ }
+ }
+?>
\ No newline at end of file
diff --git a/lang/en.php b/lang/en.php
index 931f92c..dbd8fde 100644
--- a/lang/en.php
+++ b/lang/en.php
@@ -301,7 +301,7 @@
'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',
+ 'cpu_stats' => 'Node CPU stats (one second average)',
'mem_stats' => 'Node memory stats',
'system_information' => 'System information',
'date-format' => 'Y-m-d H:i:s',
diff --git a/pages/info.php b/pages/info.php
index ac20183..b02b72d 100644
--- a/pages/info.php
+++ b/pages/info.php
@@ -125,34 +125,20 @@
</div>
<div class="section"><?php echo $lang->get('cpu_stats'); ?></div>
-<?php
+<?php
$tmp = $lv->node_get_cpu_stats();
-foreach ($tmp as $id => $data) {
- echo '<div class="label">'.$lang->get('run').' #'.$id.'</div>';
- echo '<div class="value">';
- foreach ($data as $key => $val) {
- if ($key != 'time')
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.$val.'</div>';
- else
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.@Date($lang->get('date-format'), $val).'</div>';
- }
- echo '</div><br />';
+if (is_array($tmp)) foreach ($tmp as $name => $value) {
+ echo '<div class="label">'.$name.'</div>';
+ echo '<div class="value">'.$value.'</div><div class="nl">';
}
?>
<div style="clear:both"></div>
<div class="section"><?php echo $lang->get('mem_stats'); ?></div>
-<?php
+<?php
$tmp = $lv->node_get_mem_stats();
-foreach ($tmp as $id => $data) {
- echo '<div class="label">'.$lang->get('run').' #'.$id.'</div>';
- echo '<div class="value">';
- foreach ($data as $key => $val) {
- if ($key != 'time')
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.$val.'</div>';
- else
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.@Date($lang->get('date-format'), $val).'</div>';
- }
- echo '</div><br />';
+if (is_array($tmp)) foreach ($tmp as $name => $value) {
+ echo '<div class="label">'.$name.'</div>';
+ echo '<div class="value">'.$value.'</div><div class="nl">';
}
?>
<div style="clear:both"></div>
--
1.7.4
Handle node_get_cpu_stats() output change
---
classes/libvirt.php | 39 +++++++++++++++++++++++----------------
lang/en.php | 2 +-
pages/info.php | 30 ++++++++----------------------
3 files changed, 32 insertions(+), 39 deletions(-)
diff --git a/classes/libvirt.php b/classes/libvirt.php
index e8fce08..46da82b 100644
--- a/classes/libvirt.php
+++ b/classes/libvirt.php
@@ -1601,20 +1601,27 @@
$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();
- }
- }
-?>
+ $tmp = libvirt_node_get_cpu_stats($this->conn);
+ if (!$tmp) return $this->_set_last_error();
+
+ // tmp has two array, collected at 1sec delay. Make a diff
+ $newvalues = array();
+ foreach ($tmp[0] as $key => $elem) {
+ $newvalues[$key] = $tmp[1][$key] - $elem;
+ }
+ return $newvalues;
+ }
+
+ 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();
+ }
+ }
+?>
\ No newline at end of file
diff --git a/lang/en.php b/lang/en.php
index 931f92c..dbd8fde 100644
--- a/lang/en.php
+++ b/lang/en.php
@@ -301,7 +301,7 @@
'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',
+ 'cpu_stats' => 'Node CPU stats (one second average)',
'mem_stats' => 'Node memory stats',
'system_information' => 'System information',
'date-format' => 'Y-m-d H:i:s',
diff --git a/pages/info.php b/pages/info.php
index ac20183..b02b72d 100644
--- a/pages/info.php
+++ b/pages/info.php
@@ -125,34 +125,20 @@
</div>
<div class="section"><?php echo $lang->get('cpu_stats'); ?></div>
-<?php
+<?php
$tmp = $lv->node_get_cpu_stats();
-foreach ($tmp as $id => $data) {
- echo '<div class="label">'.$lang->get('run').' #'.$id.'</div>';
- echo '<div class="value">';
- foreach ($data as $key => $val) {
- if ($key != 'time')
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.$val.'</div>';
- else
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.@Date($lang->get('date-format'), $val).'</div>';
- }
- echo '</div><br />';
+if (is_array($tmp)) foreach ($tmp as $name => $value) {
+ echo '<div class="label">'.$name.'</div>';
+ echo '<div class="value">'.$value.'</div><div class="nl">';
}
?>
<div style="clear:both"></div>
<div class="section"><?php echo $lang->get('mem_stats'); ?></div>
-<?php
+<?php
$tmp = $lv->node_get_mem_stats();
-foreach ($tmp as $id => $data) {
- echo '<div class="label">'.$lang->get('run').' #'.$id.'</div>';
- echo '<div class="value">';
- foreach ($data as $key => $val) {
- if ($key != 'time')
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.$val.'</div>';
- else
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.@Date($lang->get('date-format'), $val).'</div>';
- }
- echo '</div><br />';
+if (is_array($tmp)) foreach ($tmp as $name => $value) {
+ echo '<div class="label">'.$name.'</div>';
+ echo '<div class="value">'.$value.'</div><div class="nl">';
}
?>
<div style="clear:both"></div>
--
1.7.4
10 years, 9 months
[PATCH] change Libvirt::node_get_cpu_stats() output
by Olivier Doucet
Handle node_get_cpu_stats() output change
---
classes/libvirt.php | 39 +++++++++++++++++++++++----------------
lang/en.php | 2 +-
pages/info.php | 30 ++++++++----------------------
3 files changed, 32 insertions(+), 39 deletions(-)
diff --git a/classes/libvirt.php b/classes/libvirt.php
index e8fce08..46da82b 100644
--- a/classes/libvirt.php
+++ b/classes/libvirt.php
@@ -1601,20 +1601,27 @@
$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();
- }
- }
-?>
+ $tmp = libvirt_node_get_cpu_stats($this->conn);
+ if (!$tmp) return $this->_set_last_error();
+
+ // tmp has two array, collected at 1sec delay. Make a diff
+ $newvalues = array();
+ foreach ($tmp[0] as $key => $elem) {
+ $newvalues[$key] = $tmp[1][$key] - $elem;
+ }
+ return $newvalues;
+ }
+
+ 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();
+ }
+ }
+?>
\ No newline at end of file
diff --git a/lang/en.php b/lang/en.php
index 931f92c..dbd8fde 100644
--- a/lang/en.php
+++ b/lang/en.php
@@ -301,7 +301,7 @@
'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',
+ 'cpu_stats' => 'Node CPU stats (one second average)',
'mem_stats' => 'Node memory stats',
'system_information' => 'System information',
'date-format' => 'Y-m-d H:i:s',
diff --git a/pages/info.php b/pages/info.php
index ac20183..b02b72d 100644
--- a/pages/info.php
+++ b/pages/info.php
@@ -125,34 +125,20 @@
</div>
<div class="section"><?php echo $lang->get('cpu_stats'); ?></div>
-<?php
+<?php
$tmp = $lv->node_get_cpu_stats();
-foreach ($tmp as $id => $data) {
- echo '<div class="label">'.$lang->get('run').' #'.$id.'</div>';
- echo '<div class="value">';
- foreach ($data as $key => $val) {
- if ($key != 'time')
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.$val.'</div>';
- else
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.@Date($lang->get('date-format'), $val).'</div>';
- }
- echo '</div><br />';
+if (is_array($tmp)) foreach ($tmp as $name => $value) {
+ echo '<div class="label">'.$name.'</div>';
+ echo '<div class="value">'.$value.'</div><div class="nl">';
}
?>
<div style="clear:both"></div>
<div class="section"><?php echo $lang->get('mem_stats'); ?></div>
-<?php
+<?php
$tmp = $lv->node_get_mem_stats();
-foreach ($tmp as $id => $data) {
- echo '<div class="label">'.$lang->get('run').' #'.$id.'</div>';
- echo '<div class="value">';
- foreach ($data as $key => $val) {
- if ($key != 'time')
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.$val.'</div>';
- else
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.@Date($lang->get('date-format'), $val).'</div>';
- }
- echo '</div><br />';
+if (is_array($tmp)) foreach ($tmp as $name => $value) {
+ echo '<div class="label">'.$name.'</div>';
+ echo '<div class="value">'.$value.'</div><div class="nl">';
}
?>
<div style="clear:both"></div>
--
1.7.4
10 years, 9 months
[PATCH] change Libvirt::node_get_cpu_stats() output[PATCH] change Libvirt::node_get_cpu_stats() output[PATCH] change Libvirt::node_get_cpu_stats() output
by Olivier Doucet
Handle node_get_cpu_stats() output change
---
classes/libvirt.php | 39 +++++++++++++++++++++++----------------
lang/en.php | 2 +-
pages/info.php | 30 ++++++++----------------------
3 files changed, 32 insertions(+), 39 deletions(-)
diff --git a/classes/libvirt.php b/classes/libvirt.php
index e8fce08..46da82b 100644
--- a/classes/libvirt.php
+++ b/classes/libvirt.php
@@ -1601,20 +1601,27 @@
$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();
- }
- }
-?>
+ $tmp = libvirt_node_get_cpu_stats($this->conn);
+ if (!$tmp) return $this->_set_last_error();
+
+ // tmp has two array, collected at 1sec delay. Make a diff
+ $newvalues = array();
+ foreach ($tmp[0] as $key => $elem) {
+ $newvalues[$key] = $tmp[1][$key] - $elem;
+ }
+ return $newvalues;
+ }
+
+ 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();
+ }
+ }
+?>
\ No newline at end of file
diff --git a/lang/en.php b/lang/en.php
index 931f92c..dbd8fde 100644
--- a/lang/en.php
+++ b/lang/en.php
@@ -301,7 +301,7 @@
'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',
+ 'cpu_stats' => 'Node CPU stats (one second average)',
'mem_stats' => 'Node memory stats',
'system_information' => 'System information',
'date-format' => 'Y-m-d H:i:s',
diff --git a/pages/info.php b/pages/info.php
index ac20183..b02b72d 100644
--- a/pages/info.php
+++ b/pages/info.php
@@ -125,34 +125,20 @@
</div>
<div class="section"><?php echo $lang->get('cpu_stats'); ?></div>
-<?php
+<?php
$tmp = $lv->node_get_cpu_stats();
-foreach ($tmp as $id => $data) {
- echo '<div class="label">'.$lang->get('run').' #'.$id.'</div>';
- echo '<div class="value">';
- foreach ($data as $key => $val) {
- if ($key != 'time')
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.$val.'</div>';
- else
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.@Date($lang->get('date-format'), $val).'</div>';
- }
- echo '</div><br />';
+if (is_array($tmp)) foreach ($tmp as $name => $value) {
+ echo '<div class="label">'.$name.'</div>';
+ echo '<div class="value">'.$value.'</div><div class="nl">';
}
?>
<div style="clear:both"></div>
<div class="section"><?php echo $lang->get('mem_stats'); ?></div>
-<?php
+<?php
$tmp = $lv->node_get_mem_stats();
-foreach ($tmp as $id => $data) {
- echo '<div class="label">'.$lang->get('run').' #'.$id.'</div>';
- echo '<div class="value">';
- foreach ($data as $key => $val) {
- if ($key != 'time')
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.$val.'</div>';
- else
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.@Date($lang->get('date-format'), $val).'</div>';
- }
- echo '</div><br />';
+if (is_array($tmp)) foreach ($tmp as $name => $value) {
+ echo '<div class="label">'.$name.'</div>';
+ echo '<div class="value">'.$value.'</div><div class="nl">';
}
?>
<div style="clear:both"></div>
--
1.7.4
Handle node_get_cpu_stats() output change
---
classes/libvirt.php | 39 +++++++++++++++++++++++----------------
lang/en.php | 2 +-
pages/info.php | 30 ++++++++----------------------
3 files changed, 32 insertions(+), 39 deletions(-)
diff --git a/classes/libvirt.php b/classes/libvirt.php
index e8fce08..46da82b 100644
--- a/classes/libvirt.php
+++ b/classes/libvirt.php
@@ -1601,20 +1601,27 @@
$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();
- }
- }
-?>
+ $tmp = libvirt_node_get_cpu_stats($this->conn);
+ if (!$tmp) return $this->_set_last_error();
+
+ // tmp has two array, collected at 1sec delay. Make a diff
+ $newvalues = array();
+ foreach ($tmp[0] as $key => $elem) {
+ $newvalues[$key] = $tmp[1][$key] - $elem;
+ }
+ return $newvalues;
+ }
+
+ 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();
+ }
+ }
+?>
\ No newline at end of file
diff --git a/lang/en.php b/lang/en.php
index 931f92c..dbd8fde 100644
--- a/lang/en.php
+++ b/lang/en.php
@@ -301,7 +301,7 @@
'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',
+ 'cpu_stats' => 'Node CPU stats (one second average)',
'mem_stats' => 'Node memory stats',
'system_information' => 'System information',
'date-format' => 'Y-m-d H:i:s',
diff --git a/pages/info.php b/pages/info.php
index ac20183..b02b72d 100644
--- a/pages/info.php
+++ b/pages/info.php
@@ -125,34 +125,20 @@
</div>
<div class="section"><?php echo $lang->get('cpu_stats'); ?></div>
-<?php
+<?php
$tmp = $lv->node_get_cpu_stats();
-foreach ($tmp as $id => $data) {
- echo '<div class="label">'.$lang->get('run').' #'.$id.'</div>';
- echo '<div class="value">';
- foreach ($data as $key => $val) {
- if ($key != 'time')
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.$val.'</div>';
- else
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.@Date($lang->get('date-format'), $val).'</div>';
- }
- echo '</div><br />';
+if (is_array($tmp)) foreach ($tmp as $name => $value) {
+ echo '<div class="label">'.$name.'</div>';
+ echo '<div class="value">'.$value.'</div><div class="nl">';
}
?>
<div style="clear:both"></div>
<div class="section"><?php echo $lang->get('mem_stats'); ?></div>
-<?php
+<?php
$tmp = $lv->node_get_mem_stats();
-foreach ($tmp as $id => $data) {
- echo '<div class="label">'.$lang->get('run').' #'.$id.'</div>';
- echo '<div class="value">';
- foreach ($data as $key => $val) {
- if ($key != 'time')
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.$val.'</div>';
- else
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.@Date($lang->get('date-format'), $val).'</div>';
- }
- echo '</div><br />';
+if (is_array($tmp)) foreach ($tmp as $name => $value) {
+ echo '<div class="label">'.$name.'</div>';
+ echo '<div class="value">'.$value.'</div><div class="nl">';
}
?>
<div style="clear:both"></div>
--
1.7.4
Handle node_get_cpu_stats() output change
---
classes/libvirt.php | 39 +++++++++++++++++++++++----------------
lang/en.php | 2 +-
pages/info.php | 30 ++++++++----------------------
3 files changed, 32 insertions(+), 39 deletions(-)
diff --git a/classes/libvirt.php b/classes/libvirt.php
index e8fce08..46da82b 100644
--- a/classes/libvirt.php
+++ b/classes/libvirt.php
@@ -1601,20 +1601,27 @@
$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();
- }
- }
-?>
+ $tmp = libvirt_node_get_cpu_stats($this->conn);
+ if (!$tmp) return $this->_set_last_error();
+
+ // tmp has two array, collected at 1sec delay. Make a diff
+ $newvalues = array();
+ foreach ($tmp[0] as $key => $elem) {
+ $newvalues[$key] = $tmp[1][$key] - $elem;
+ }
+ return $newvalues;
+ }
+
+ 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();
+ }
+ }
+?>
\ No newline at end of file
diff --git a/lang/en.php b/lang/en.php
index 931f92c..dbd8fde 100644
--- a/lang/en.php
+++ b/lang/en.php
@@ -301,7 +301,7 @@
'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',
+ 'cpu_stats' => 'Node CPU stats (one second average)',
'mem_stats' => 'Node memory stats',
'system_information' => 'System information',
'date-format' => 'Y-m-d H:i:s',
diff --git a/pages/info.php b/pages/info.php
index ac20183..b02b72d 100644
--- a/pages/info.php
+++ b/pages/info.php
@@ -125,34 +125,20 @@
</div>
<div class="section"><?php echo $lang->get('cpu_stats'); ?></div>
-<?php
+<?php
$tmp = $lv->node_get_cpu_stats();
-foreach ($tmp as $id => $data) {
- echo '<div class="label">'.$lang->get('run').' #'.$id.'</div>';
- echo '<div class="value">';
- foreach ($data as $key => $val) {
- if ($key != 'time')
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.$val.'</div>';
- else
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.@Date($lang->get('date-format'), $val).'</div>';
- }
- echo '</div><br />';
+if (is_array($tmp)) foreach ($tmp as $name => $value) {
+ echo '<div class="label">'.$name.'</div>';
+ echo '<div class="value">'.$value.'</div><div class="nl">';
}
?>
<div style="clear:both"></div>
<div class="section"><?php echo $lang->get('mem_stats'); ?></div>
-<?php
+<?php
$tmp = $lv->node_get_mem_stats();
-foreach ($tmp as $id => $data) {
- echo '<div class="label">'.$lang->get('run').' #'.$id.'</div>';
- echo '<div class="value">';
- foreach ($data as $key => $val) {
- if ($key != 'time')
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.$val.'</div>';
- else
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.@Date($lang->get('date-format'), $val).'</div>';
- }
- echo '</div><br />';
+if (is_array($tmp)) foreach ($tmp as $name => $value) {
+ echo '<div class="label">'.$name.'</div>';
+ echo '<div class="value">'.$value.'</div><div class="nl">';
}
?>
<div style="clear:both"></div>
--
1.7.4
10 years, 9 months
[PATCH] change Libvirt::node_get_cpu_stats() output[PATCH] change Libvirt::node_get_cpu_stats() output
by Olivier Doucet
Handle node_get_cpu_stats() output change
---
classes/libvirt.php | 39 +++++++++++++++++++++++----------------
lang/en.php | 2 +-
pages/info.php | 30 ++++++++----------------------
3 files changed, 32 insertions(+), 39 deletions(-)
diff --git a/classes/libvirt.php b/classes/libvirt.php
index e8fce08..46da82b 100644
--- a/classes/libvirt.php
+++ b/classes/libvirt.php
@@ -1601,20 +1601,27 @@
$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();
- }
- }
-?>
+ $tmp = libvirt_node_get_cpu_stats($this->conn);
+ if (!$tmp) return $this->_set_last_error();
+
+ // tmp has two array, collected at 1sec delay. Make a diff
+ $newvalues = array();
+ foreach ($tmp[0] as $key => $elem) {
+ $newvalues[$key] = $tmp[1][$key] - $elem;
+ }
+ return $newvalues;
+ }
+
+ 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();
+ }
+ }
+?>
\ No newline at end of file
diff --git a/lang/en.php b/lang/en.php
index 931f92c..dbd8fde 100644
--- a/lang/en.php
+++ b/lang/en.php
@@ -301,7 +301,7 @@
'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',
+ 'cpu_stats' => 'Node CPU stats (one second average)',
'mem_stats' => 'Node memory stats',
'system_information' => 'System information',
'date-format' => 'Y-m-d H:i:s',
diff --git a/pages/info.php b/pages/info.php
index ac20183..b02b72d 100644
--- a/pages/info.php
+++ b/pages/info.php
@@ -125,34 +125,20 @@
</div>
<div class="section"><?php echo $lang->get('cpu_stats'); ?></div>
-<?php
+<?php
$tmp = $lv->node_get_cpu_stats();
-foreach ($tmp as $id => $data) {
- echo '<div class="label">'.$lang->get('run').' #'.$id.'</div>';
- echo '<div class="value">';
- foreach ($data as $key => $val) {
- if ($key != 'time')
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.$val.'</div>';
- else
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.@Date($lang->get('date-format'), $val).'</div>';
- }
- echo '</div><br />';
+if (is_array($tmp)) foreach ($tmp as $name => $value) {
+ echo '<div class="label">'.$name.'</div>';
+ echo '<div class="value">'.$value.'</div><div class="nl">';
}
?>
<div style="clear:both"></div>
<div class="section"><?php echo $lang->get('mem_stats'); ?></div>
-<?php
+<?php
$tmp = $lv->node_get_mem_stats();
-foreach ($tmp as $id => $data) {
- echo '<div class="label">'.$lang->get('run').' #'.$id.'</div>';
- echo '<div class="value">';
- foreach ($data as $key => $val) {
- if ($key != 'time')
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.$val.'</div>';
- else
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.@Date($lang->get('date-format'), $val).'</div>';
- }
- echo '</div><br />';
+if (is_array($tmp)) foreach ($tmp as $name => $value) {
+ echo '<div class="label">'.$name.'</div>';
+ echo '<div class="value">'.$value.'</div><div class="nl">';
}
?>
<div style="clear:both"></div>
--
1.7.4
Handle node_get_cpu_stats() output change
---
classes/libvirt.php | 39 +++++++++++++++++++++++----------------
lang/en.php | 2 +-
pages/info.php | 30 ++++++++----------------------
3 files changed, 32 insertions(+), 39 deletions(-)
diff --git a/classes/libvirt.php b/classes/libvirt.php
index e8fce08..46da82b 100644
--- a/classes/libvirt.php
+++ b/classes/libvirt.php
@@ -1601,20 +1601,27 @@
$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();
- }
- }
-?>
+ $tmp = libvirt_node_get_cpu_stats($this->conn);
+ if (!$tmp) return $this->_set_last_error();
+
+ // tmp has two array, collected at 1sec delay. Make a diff
+ $newvalues = array();
+ foreach ($tmp[0] as $key => $elem) {
+ $newvalues[$key] = $tmp[1][$key] - $elem;
+ }
+ return $newvalues;
+ }
+
+ 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();
+ }
+ }
+?>
\ No newline at end of file
diff --git a/lang/en.php b/lang/en.php
index 931f92c..dbd8fde 100644
--- a/lang/en.php
+++ b/lang/en.php
@@ -301,7 +301,7 @@
'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',
+ 'cpu_stats' => 'Node CPU stats (one second average)',
'mem_stats' => 'Node memory stats',
'system_information' => 'System information',
'date-format' => 'Y-m-d H:i:s',
diff --git a/pages/info.php b/pages/info.php
index ac20183..b02b72d 100644
--- a/pages/info.php
+++ b/pages/info.php
@@ -125,34 +125,20 @@
</div>
<div class="section"><?php echo $lang->get('cpu_stats'); ?></div>
-<?php
+<?php
$tmp = $lv->node_get_cpu_stats();
-foreach ($tmp as $id => $data) {
- echo '<div class="label">'.$lang->get('run').' #'.$id.'</div>';
- echo '<div class="value">';
- foreach ($data as $key => $val) {
- if ($key != 'time')
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.$val.'</div>';
- else
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.@Date($lang->get('date-format'), $val).'</div>';
- }
- echo '</div><br />';
+if (is_array($tmp)) foreach ($tmp as $name => $value) {
+ echo '<div class="label">'.$name.'</div>';
+ echo '<div class="value">'.$value.'</div><div class="nl">';
}
?>
<div style="clear:both"></div>
<div class="section"><?php echo $lang->get('mem_stats'); ?></div>
-<?php
+<?php
$tmp = $lv->node_get_mem_stats();
-foreach ($tmp as $id => $data) {
- echo '<div class="label">'.$lang->get('run').' #'.$id.'</div>';
- echo '<div class="value">';
- foreach ($data as $key => $val) {
- if ($key != 'time')
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.$val.'</div>';
- else
- echo '<div class="label">'.$key.'</div><div class="value" style="text-align: right">'.@Date($lang->get('date-format'), $val).'</div>';
- }
- echo '</div><br />';
+if (is_array($tmp)) foreach ($tmp as $name => $value) {
+ echo '<div class="label">'.$name.'</div>';
+ echo '<div class="value">'.$value.'</div><div class="nl">';
}
?>
<div style="clear:both"></div>
--
1.7.4
10 years, 9 months
[PATCH] Added support for node_get_cpu_stats ; node_get_mem_stats ; connect_get_sysinfo
by Olivier Doucet
---
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>
--
1.7.4
10 years, 9 months