Bug#996877: DiskStats.pm fails to parse new format of /proc/diskstats

Thomas Hoffmann (Speed4Trade GmbH) Thomas.Hoffmann at speed4trade.com
Wed Oct 20 08:01:17 BST 2021


Package: libsys-statistics-linux-perl
Version: 0.66-3

Summary:
The new linux kernel provides two additional columns in /proc/diskstats and thus the perl module DiskStats.pm has to be updated to parse/match the two additional columns.

Details:
Perl comes with the utility module /usr/share/perl5/Sys/Statistics/Linux/DiskStats.pm
In line 246 the module reads the file /proc/diskstats and tries to parse it with different regular expressions.

The first try is done with:
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})?$/) {

The new format of /proc/diskstats contains two additional columns and thus fails to parse the information.
With Debian bullseye the diskstats line looks e.g. like the following example:
11       0      sr0     15      0      0      1      0      0      0      0     0    20     1   0   0   0   0   0   0

Thus the regex fails to match. The added columns are documented at: https://www.kernel.org/doc/Documentation/ABI/testing/procfs-diskstats
If the additional params are not relevant, the regex can be changed to e.g.
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,6})?$/) {

Would be nice if someone of the maintainers can take a closer look at that issue.
Thanks, Thomas



More information about the pkg-perl-maintainers mailing list