[pve-devel] [PATCH 2/2] monitor diskio with qmp command
Alexandre Derumier
aderumier at odiso.com
Fri Jun 29 12:34:56 CEST 2012
Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
PVE/QemuServer.pm | 19 +++++++++----------
1 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 89b8454..a0d3a80 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -1970,17 +1970,16 @@ sub vmstatus {
my $pid = $d->{pid};
next if !$pid;
- if (my $fh = IO::File->new("/proc/$pid/io", "r")) {
- my $data = {};
- while (defined(my $line = <$fh>)) {
- if ($line =~ m/^([rw]char):\s+(\d+)$/) {
- $data->{$1} = $2;
- }
- }
- close($fh);
- $d->{diskread} = $data->{rchar} || 0;
- $d->{diskwrite} = $data->{wchar} || 0;
+ my $blockstats = vm_mon_cmd($vmid, "query-blockstats");
+
+ my $totalrdbytes = 0;
+ my $totalwrbytes = 0;
+ for my $blockstat ( @$blockstats ) {
+ $totalrdbytes = $totalrdbytes + $blockstat->{stats}->{rd_bytes};
+ $totalwrbytes = $totalwrbytes + $blockstat->{stats}->{wr_bytes};
}
+ $d->{diskread} = $totalrdbytes;
+ $d->{diskwrite} = $totalwrbytes;
my $pstat = PVE::ProcFSTools::read_proc_pid_stat($pid);
next if !$pstat; # not running
--
1.7.2.5
More information about the pve-devel
mailing list