File /proc/mdstat indicates a dying RAID device with an output section such as

 md3 : active raid1 sdg6[0]
       871885632 blocks super 1.0 [2/1] [U_]
       bitmap: 4/7 pages [16KB], 65536KB chunk

Note the [U-]. The "-" says /dev/sdh is dead. I would like to scan /proc/mdstat and set a flag if [U-], [-U] or [--] occur. My current attempt is

 #! /bin/bash -u
 set -x
 BAD=0;
 while  read L;
 do if [[ $L == *"[U-]"* ]]; then B=1; fi;
    if [[ $L == *"[-U]"* ]]; then B=1; fi;
    if [[ $L == *"[--]"* ]]; then B=1; fi;
 done < /proc/mdstat;
 echo $BAD

Far from elegant, but I still can't get it to work.
The trace contains lines such as

 + 1164021 1164021 [4]read L
 + 1164021 1164021 [5][[ 20970368 blocks super 1.0 [2/1] [U_] == *\[\U\-\]* ]]

The test always fails, but I can't see why.  Any hint would be very welcome.

Roger

Reply via email to