[pve-devel] [PATCH] lxc : vmstatus : add disk read|write stats

Alexandre Derumier aderumier at odiso.com
Sun Jun 21 13:06:27 CEST 2015


using cgroup blkio.throttle.io_service_bytes

They are also another cgroup blkio.io_service_bytes,
but it's only work with cfq io scheduler.

blkio.throttle.io_service_bytes works with any io scheduler

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 src/PVE/LXC.pm | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index 0f21bcb..30f735c 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -752,6 +752,14 @@ sub vmstatus {
 
 	$d->{mem} = read_cgroup_value('memory', $vmid, 'memory.usage_in_bytes');
 	$d->{swap} = read_cgroup_value('memory', $vmid, 'memory.memsw.usage_in_bytes') - $d->{mem};
+
+	my $blkio_bytes = read_cgroup_value('blkio', $vmid, 'blkio.throttle.io_service_bytes', 1);
+	my @bytes = split /\n/, $blkio_bytes;
+	foreach my $byte (@bytes) {
+	    my ($key, $value) = $byte =~ /(Read|Write) (\d+)/;
+	    $d->{diskread} = $2 if $key eq 'Read';
+	    $d->{diskwrite} = $2 if $key eq 'Write';
+	}
     }
     
     return $list;
-- 
2.1.4




More information about the pve-devel mailing list