[pve-devel] [PATCH container 1/2] Add disk operations to vmstatus

Tobias Böhm tb at robhost.de
Mon Jun 19 12:10:10 CEST 2017


Currently, only read/write bytes are extracted from cgroups stats.
In order to provide IO operation stats these counters need to be
read as well.

Signed-off-by: Tobias Böhm <tb at robhost.de>
---
 src/PVE/LXC.pm | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index 32b0318..8e1043a 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -183,6 +183,9 @@ sub vmstatus {
 	$d->{diskread} = 0;
 	$d->{diskwrite} = 0;
 
+	$d->{ioread} = 0;
+	$d->{iowrite} = 0;
+
 	$d->{template} = PVE::LXC::Config->is_template($conf);
     }
 
@@ -210,6 +213,15 @@ sub vmstatus {
 	    }
 	}
 
+	my $blkio_opers = read_cgroup_value('blkio', $vmid, 'blkio.throttle.io_serviced', 1);
+	my @opers = split(/\n/, $blkio_opers);
+	foreach my $oper (@opers) {
+	    if (my ($key, $value) = $oper =~ /(Read|Write)\s+(\d+)/) {
+		$d->{ioread} = $2 if $key eq 'Read';
+		$d->{iowrite} = $2 if $key eq 'Write';
+	    }
+	}
+
 	my $pstat = &$parse_cpuacct_stat($vmid);
 
 	my $used = $pstat->{utime} + $pstat->{stime};
-- 
2.11.0




More information about the pve-devel mailing list