summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKoen Kooi <koen@dominion.thruhere.net>2018-11-05 15:17:16 +0000
committerGiampaolo Rodola <g.rodola@gmail.com>2018-11-05 07:17:16 -0800
commit8f99f3782663959062ee868bbfdbc336307a3a4d (patch)
tree5a0ef7f3d48eebbd7474e70fcaac6b8824db99f3
parent7ddfa9a637f56dbe236dde285991569783fe444e (diff)
downloadpsutil-8f99f3782663959062ee868bbfdbc336307a3a4d.tar.gz
Fix #1354 [Linux] disk_io_counters() fails on Linux kernel 4.18+ (#1360)
Linux kernel 4.18+ added 4 fields, ingore them and parse the rest as usual.
-rw-r--r--psutil/_pslinux.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/psutil/_pslinux.py b/psutil/_pslinux.py
index ecc4c703..b775d39a 100644
--- a/psutil/_pslinux.py
+++ b/psutil/_pslinux.py
@@ -1060,6 +1060,8 @@ def disk_io_counters(perdisk=False):
# ...unless (Linux 2.6) the line refers to a partition instead
# of a disk, in which case the line has less fields (7):
# "3 1 hda1 8 8 8 8"
+ # 4.18+ has 4 fields added:
+ # "3 0 hda 8 8 8 8 8 8 8 8 8 8 8 0 0 0 0"
# See:
# https://www.kernel.org/doc/Documentation/iostats.txt
# https://www.kernel.org/doc/Documentation/ABI/testing/procfs-diskstats
@@ -1074,7 +1076,7 @@ def disk_io_counters(perdisk=False):
reads = int(fields[2])
(reads_merged, rbytes, rtime, writes, writes_merged,
wbytes, wtime, _, busy_time, _) = map(int, fields[4:14])
- elif flen == 14:
+ elif flen == 14 or flen == 18:
# Linux 2.6+, line referring to a disk
name = fields[2]
(reads, reads_merged, rbytes, rtime, writes, writes_merged,