Subject: | Sys::Statistics::Linux::DiskStats fails to parse /proc/diskstats for kernel v4.18+ |
According to https://www.kernel.org/doc/Documentation/iostats.txt, 4 new fields were added to /proc/diskstats for kernel version 4.18. As a result, device names and the "old" attribute fields are misparsed by the (very narrow) regexes in Sys/Statistics/Linux/DiskStats.pm . The attached patch appears to fix the problem.
marmosets,
Bryan / moocow
Subject: | Sys-Statistics-Linux-0.66-DiskStats.diff |
--- Sys-Statistics-Linux-0.66/lib/Sys/Statistics/Linux/DiskStats.pm 2019-03-21 10:12:36.584677649 +0100
+++ Sys-Statistics-Linux-0.66_patched/lib/Sys/Statistics/Linux/DiskStats.pm 2019-03-21 10:13:20.236575029 +0100
@@ -239,9 +239,9 @@
if (open $fh, '<', $file_diskstats) {
while (my $line = <$fh>) {
- # -- -- -- F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11
- # $1 $2 $3 $4 -- $5 -- $6 -- $7 -- -- -- --
- if ($line =~ /^\s+(\d+)\s+(\d+)\s+(.+?)\s+(\d+)\s+\d+\s+(\d+)\s+\d+\s+(\d+)\s+\d+\s+(\d+)\s+\d+\s+\d+\s+\d+\s+\d+$/) {
+ # -- -- -- F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 (F12..F15)?
+ # $1 $2 $3 $4 -- $5 -- $6 -- $7 -- -- -- -- (-- .. --)?
+ if ($line =~ /^\s+(\d+)\s+(\d+)\s+(.+?)\s+(\d+)\s+\d+\s+(\d+)\s+\d+\s+(\d+)\s+\d+\s+(\d+)\s+\d+\s+\d+\s+\d+\s+\d+(?:(?:\s+\d+){4})?$/) {
for my $x ($stats{$3}) { # $3 -> the device name
$x->{major} = $1;
$x->{minor} = $2;