#891830 check_raid/mdstat fails to parse 'sdd2[3](W)(S)'

Package:
nagios-plugins-contrib
Source:
nagios-plugins-contrib
Description:
Transitional package for monitoring-plugins-contrib
Submitter:
Damyan Ivanov
Date:
2020-12-08 20:21:04 UTC
Severity:
normal
Tags:
#891830#5
Date:
2018-03-01 10:40:50 UTC
From:
To:
Hi,

check_raid fails to parse the following:

 $ cat /proc/mdstat
 Personalities : [raid1]
 md1 : active raid1 sda2[4] sdd2[3](W)(S) sdb2[2]
       450883784 blocks super 1.2 [2/2] [UU]
       bitmap: 3/4 pages [12KB], 65536KB chunk

 $ /usr/lib/nagios/plugins/check_raid -p mdstat
 Unexpected parse at /usr/lib/nagios/plugins/check_raid line 701, <$fh> line 2.

Please find attached a quilt patch that fixes this.

Current upstream code¹ is heavily refactored, but still uses the same regular
expressions.

 ¹ https://github.com/glensc/nagios-plugin-check_raid/blob/master/lib/App/Monitoring/Plugin/CheckRaid/Plugins/mdstat.pm#L49


Thanks for considering,
    dam

#891830#10
Date:
2018-11-07 14:34:56 UTC
From:
To:
tags 891830 + upstream
thanks

Hi Damyan,

Am 01.03.18 um 11:40 schrieb Damyan Ivanov:

many thanks for bringing this to our attention. It would be very helpful
if you could raise[1] an issue upstream.

Thanks, Jan.
[1] https://github.com/glensc/nagios-plugin-check_raid/#reporting-bugs

#891830#15
Date:
2020-12-08 20:10:21 UTC
From:
To:
Dear maintainer, hi everyone,

I got the same issue and I've made a simple fix on the regex, instead of
"?" which is valid for "0" or "1" occurence, I used "*".

It seems to work well on my side, maybe you could try?

I'm using the latest version available on Debian 10.

Here is my patch:

Regards,

Aymeric.
--- /usr/lib/nagios/plugins/check_raid  2020-12-08 21:05:25.067753313 +0100 +++ /tmp/check_raid     2020-12-08 21:05:20.219799196 +0100 @@ -3558,7 +3558,7 @@                         my $re = qr{^                                 (\S+)           # devname                                 (?:\[(\d+)\])   # desc_nr -                               (?:\((.)\))?    # flags: (W|F|S) - WriteMostly, Faulty, Spare +                               (?:\((.)\))*    # flags: (W|F|S) - WriteMostly, Faulty, Spare                         $}x;                         my @disks = ();                         my $personality;