Just made a few improvements to the awk code using
this answer from jasonwryan - version 1
and this answer from Karl Peterson - version 2
version 3 with a list of elements of RAID arrays and their statuses
awk '/^md/ {printf "%s: ", $1; line=""; n=3; for (;n<=NF;n++) line=line" "$n;}; /blocks/ {printf "%s %s =%s\n", $(NF-1), $NF, line}' /proc/mdstat
sample output 3
md121: [1/1] [U] = active raid1 sdj6[2]
md122: [2/2] [UU] = active raid1 sdh5[2] sdi5[3]
md123: [2/2] [UU] = active raid1 sdf4[0] sdg4[1]
md124: [2/2] [UU] = active raid1 sdd3[0] sde3[1]
md125: [2/1] [_U] = active raid1 sdc2[1]
md126: [2/1] [_U] = active raid1 sdb1[1]
md127: [2/1] [_U] = active raid1 sda[1]
version 4 with a list of elements of RAID arrays and their human-friendly sizes and statuses
awk '/^md/ {printf "%s: ", $1; line=""; n=3; for (;n<=NF;n++) line=line" "$n;}; /blocks/ {total=$1; total_units="K"; if (total >= 1024*1024*1024) { total_units="T" ; total/= 1024*1024*1024;} else if (total >= 1024*1024) { total_units="G" ; total/= 1024*1024;} else if (total >= 1024) { total_units="M" ; total/= 1024;}; total_ident = total < 100 ? ( total < 10 ? "" : " " ) : ""; total_show = substr((total_ident total), 1, 5); printf "%s %s = %s %s =%s\n", $(NF-1), $NF, total_show, total_units"iB", line}' /proc/mdstat
sample output 4
md121: [1/1] [U] = 3.756 TiB = active raid1 sdj6[2]
md122: [2/2] [UU] = 1.456 TiB = active raid1 sdh5[2] sdi5[3]
md123: [2/2] [UU] = 543.2 GiB = active raid1 sdf4[0] sdg4[1]
md124: [2/2] [UU] = 23.4 GiB = active raid1 sdd3[0] sde3[1]
md125: [2/1] [_U] = 432.1 GiB = active raid1 sdc2[1]
md126: [2/1] [_U] = 69.7 GiB = active raid1 sdb1[1]
md127: [2/1] [_U] = 2.834 TiB = active raid1 sda[1]
and version 5 is a combination of version 4 and version 2
awk '/^md/ {printf "%s: ", $1; line=""; n=3; for (;n<=NF;n++) line=line" "$n;}; /blocks/ {total=$1; total_units="K"; if (total >= 1024*1024*1024) { total_units="T" ; total/= 1024*1024*1024;} else if (total >= 1024*1024) { total_units="G" ; total/= 1024*1024;} else if (total >= 1024) { total_units="M" ; total/= 1024;}; total_ident = total < 100 ? ( total < 10 ? "" : " " ) : ""; total_show = substr((total_ident total), 1, 5); printf "%s %s = %s %s =%s\n", $(NF-1), $NF, total_show, total_units"iB", line}' /proc/mdstat | awk '/\[U+\]/ {print "\033[32m" $0 "\033[0m"}; /\[.*_.*\]/ {print "\033[31m" $0 "\033[0m"}'
sample output 5 - same as output 4 but colored
from Karl Peterson
This prints the array name and member status in green if all members are up. If a member fails, then it's printed in red.