[Pkg-nagios-devel] Bug#891830: check_raid/mdstat fails to parse 'sdd2[3](W)(S)'

Damyan Ivanov dmn at debian.org
Thu Mar 1 10:40:50 UTC 2018


Package: nagios-plugins-contrib
Version: 14.20141104
Severity: normal
Tags: upstream patch

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

-- System Information:
Debian Release: buster/sid
  APT prefers unstable-debug
  APT policy: (500, 'unstable-debug'), (500, 'unstable'), (500, 'stable'), (500, 'oldstable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 4.14.0-3-amd64 (SMP w/4 CPU cores)
Locale: LANG=bg_BG.UTF-8, LC_CTYPE=bg_BG.UTF-8 (charmap=UTF-8), LANGUAGE=bg_BG.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

nagios-plugins-contrib depends on no packages.

Versions of packages nagios-plugins-contrib recommends:
ii  bind9-host                                         1:9.11.2.P1-1
ii  binutils                                           2.30-5
ii  freeipmi-tools                                     1.5.7-2
ii  ldap-utils                                         2.4.45+dfsg-1
ii  libc6                                              2.26-6
pn  libdata-validate-domain-perl                       <none>
pn  libdata-validate-ip-perl                           <none>
ii  libdate-manip-perl                                 6.60-1
ii  libdbd-mysql-perl                                  4.046-1
ii  libio-socket-ssl-perl                              2.056-1
ii  libipc-run-perl                                    0.96-1
ii  liblocale-gettext-perl                             1.07-3+b3
pn  liblwp-useragent-determined-perl                   <none>
ii  libmail-imapclient-perl                            3.39-1
ii  libmemcached11                                     1.0.18-4.2
pn  libmemcachedutil2                                  <none>
pn  libmonitoring-plugin-perl | libnagios-plugin-perl  <none>
pn  libnagios-plugin-perl                              <none>
pn  libnet-cups-perl                                   <none>
ii  libnet-dns-perl                                    1.10-2
pn  libnet-dns-sec-perl                                <none>
ii  libnet-smtp-ssl-perl                               1.04-1
pn  libnet-smtp-tls-perl                               <none>
pn  libnet-smtpauth-perl                               <none>
ii  libnet-snmp-perl                                   6.0.1-3
ii  libnet-ssleay-perl                                 1.84-1
ii  libreadonly-perl                                   2.050-1
pn  libredis-perl                                      <none>
ii  libsocket-perl                                     2.027-1
ii  libtimedate-perl                                   2.3000-2
pn  libvarnishapi1                                     <none>
pn  libwebinject-perl                                  <none>
ii  libxml-simple-perl                                 2.24-1
ii  libyaml-syck-perl                                  1.29-1+b3
ii  lsof                                               4.89+dfsg-0.1
pn  nagios-plugins-basic                               <none>
ii  openssl                                            1.1.0g-2
ii  perl                                               5.26.1-5
ii  perl-base [libsocket-perl]                         5.26.1-5
ii  procps                                             2:3.3.12-4
ii  python                                             2.7.14-4
pn  python-pymongo                                     <none>
ii  ruby                                               1:2.5~1
pn  snmp                                               <none>
ii  whois                                              5.3.0

Versions of packages nagios-plugins-contrib suggests:
pn  backuppc                   <none>
pn  cciss-vol-status           <none>
pn  expect                     <none>
pn  libsys-virt-perl           <none>
ii  moreutils                  0.60-1
pn  mpt-status                 <none>
pn  nagios-plugin-check-multi  <none>
pn  percona-toolkit            <none>
ii  perl-doc                   5.26.1-5
ii  python2.7                  2.7.14-6
pn  smstools                   <none>
-------------- next part --------------
Description: check_raid: support multiple disk flags
 Component devices may have more than one flag, for example:
   md1 : active raid1 sda2[4] sdd2[3](W)(S) sdb2[2]
 (write-mostly and spare)
Author: Damyan Ivanov <dmn at debian.org>

--- a/check_raid/check_raid
+++ b/check_raid/check_raid
@@ -3539,7 +3539,8 @@ $fatpacked{"App/Monitoring/Plugin/CheckR
   			my $re = qr{^
   				(\S+)           # devname
   				(?:\[(\d+)\])   # desc_nr
-  				(?:\((.)\))?    # flags: (W|F|S) - WriteMostly, Faulty, Spare
+  				((?:\(.\))+)?   # flags: (W|F|S) - WriteMostly, Faulty, Spare
+						#        possibly several
   			$}x;
   			my @disks = ();
   			my $personality;
@@ -3550,10 +3551,11 @@ $fatpacked{"App/Monitoring/Plugin/CheckR
   					last;
   				}
   				my($dev, $number, $flags) = $disk =~ $re;
+				my @flags = $flags ? $flags =~ /\((.)\)/g : ();
   				push(@disks, {
   					'dev' => $dev,
   					'number' => int($number),
-  					'flags' => $flags || '',
+  					'flags' => join('', @flags),
   				});
   			}
   


More information about the Pkg-nagios-devel mailing list