Skip Menu |

This queue is for tickets about the Sys-Statistics-Linux CPAN distribution.

Report information
The Basics
Id: 128904
Status: open
Priority: 0/
Queue: Sys-Statistics-Linux

People
Owner: Nobody in particular
Requestors: moocow [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.66
Fixed in: (no value)

Attachments


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;
Florian Schlichting has updated the patch slightly (seet attached version) for Debian. Cf. also https://bugs.debian.org/925207 Cheers, gregor
Subject: bug925207-linux-4.18-diskstats.patch
Description: Fix DiskStats on linux >= v4.18 Linux 4.18 added 4 new fields to the end of /proc/diskstats lines, causing the DiskStats.pm module to treat the first four values as part of the device name and hence report bogus values. This patch accounts for the added fields and also prevents the device name to swallow up several fields again in the future. Author: Bryan Jurish <moocow.bovine@gmail.com> Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=925207 Forwarded: https://rt.cpan.org/Public/Bug/Display.html?id=128904 --- a/lib/Sys/Statistics/Linux/DiskStats.pm +++ b/lib/Sys/Statistics/Linux/DiskStats.pm @@ -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+)\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; @@ -268,7 +268,7 @@ # ----------------------------------------------------------------------------- # -- -- -- F1 F2 F3 F4 # $1 $2 $3 $4 $5 $6 $7 - elsif ($line =~ /^\s+(\d+)\s+(\d+)\s+(.+?)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)$/) { + elsif ($line =~ /^\s+(\d+)\s+(\d+)\s+(\S+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)$/) { for my $x ($stats{$3}) { # $3 -> the device name $x->{major} = $1; $x->{minor} = $2;
Subject: Updated Regex for Linux 5.6 [rt.cpan.org #128904]
Date: Tue, 16 Jun 2020 00:21:42 +0200
To: bug-Sys-Statistics-Linux [...] rt.cpan.org
From: Linux-Fan <Ma_Sys.ma [...] web.de>
Hello, using Linux 5.6.0-2-amd64 on Debian sid, parsing /proc/diskstats fails again. I suggest that another regex is used instead. My version replaces the `{4}` by `+` to allow any number of additional fields. Rationale: It seems that new fields are added occasionally... DiskStats.pm:244 if ($line =~ /^\s+(\d+)\s+(\d+)\s+(\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+)+)?$/) { Kind regards Linux-Fan
Download (untitled)
application/pgp-signature 833b

Message body not shown because it is not plain text.