Monday, August 24, 2020
RAID STATS
Added a RAID 5 array to my storage units and needed to be able to gather
more information than just the cat /proc/mdstat. So I use a combination of
mdadm
smartctl
I wrote a little shelll script. It’s not very efficient, but I dont’ have time right now to make it more efficient, and it does the job. Yeah, it’s making lots of calls but Oh well, it’s not a busy drive right now and the system is basically empty 1 TB used on a 16 TB System, with nobody really using it. So it’s empty.
#!/bin/bash
##########################################################
# Use Smartctl to get RAID Infor / Stat / Temp / Hours
##########################################################
GREP=/usr/bin/grep
ECHO=/usr/bin/echo
SCTL="/usr/sbin/smartctl --all"
FIND1="ature_Cels"
FIND2="Power_On"
DATE=`/usr/bin/date +"%m.%d.%y.%H.%M"`
AWK=/usr/bin/awk
CAT=/usr/bin/cat
MDADM="/sbin/mdadm --detail /dev/md127"
DRIVES=(/dev/sda /dev/sdb /dev/sdc /dev/sdd /dev/sde /dev/sdf)
#
# RAID STATS
#
$ECHO "=================================="
$CAT /proc/mdstat
$ECHO "=================================="
$ECHO "Drive STATUS:"
$MDADM | $GREP clean
$MDADM | $GREP Failed
$ECHO "=================================="
$ECHO "Active DRIVE(s):"
$MDADM | $GREP active
$ECHO "=================================="
#
# TEMP Stats
#
$ECHO "DRIVE Temperature(s):"
for i in "${DRIVES[@]}"
do
TEMP=`$SCTL $i | $GREP $FIND1 | $AWK -F- '{print $2}' | $AWK '{print $1}'`
if [ ! -z "$TEMP" ]
then
echo $DATE:$i:$TEMP
fi
done
#
# HOURS Stats
#
$ECHO "=================================="
#
$ECHO "Power ON HOUR(s):"
for i in "${DRIVES[@]}"
do
TEMP=`$SCTL $i | $GREP $FIND2 | $AWK -F- '{print $2}' | $AWK '{print $1}'`
if [ ! -z "$TEMP" ]
then
echo $DATE:$i:$TEMP
fi
done
Which gives me a nice result…
root@nas4:~/bin# ./raidstat ================================== Personalities : [raid6] [raid5] [raid4] md127 : active raid5 sdc1[2] sdb1[1] sde1[5] sdd1[3] sda1[0] 15627540480 blocks super 1.2 level 5, 512k chunk, algorithm 2 [5/5] [UUUUU] bitmap: 0/30 pages [0KB], 65536KB chunk unused devices: <none> ================================== State : clean Failed Devices : 0 ================================== Active DRIVE 0 8 1 0 active sync /dev/sda1 1 8 17 1 active sync /dev/sdb1 2 8 33 2 active sync /dev/sdc1 3 8 49 3 active sync /dev/sdd1 5 8 65 4 active sync /dev/sde1 ================================== DRIVE Temperatures: 08.24.20.08.27:/dev/sda:38 08.24.20.08.27:/dev/sdb:37 08.24.20.08.27:/dev/sdc:34 08.24.20.08.27:/dev/sdd:37 08.24.20.08.27:/dev/sde:36 ================================== Power ON HOURS: 08.24.20.08.27:/dev/sda:576 08.24.20.08.27:/dev/sdb:517 08.24.20.08.27:/dev/sdc:517 08.24.20.08.27:/dev/sdd:516 08.24.20.08.27:/dev/sde:517
So Now I have a nice little script I’m going to setup a cron job to run and then every morning It’ll e-mail me a copy of the results for me to check out and make sure there isn’t any problems with the NAS drive. I’m not actively on these NAS devices so I want to make sure that nothing happens to the RAID Array while I’m watching TV or something else. I just want to set it up and forget about it. Stick more stuff on it and have it do it’s thing in the background.
====================
So now I have 4 RAID systems in the Da Attic
N1 RAID 1 16TB Active 16TB Mirroring
N2 RAID 1 8TB Active 8 TB Mirroring
N3 RAID 1 16TB Active 16TB Mirroring
N4 RAID 5 16TB Active
====================
Grand total of 56TB Protected raid. I’m thinking about moving some of the RAID 1 to RAID 5. I just haven’t decided if I trust RAID 5 yet. I’ve been running it for a few weeks. I just don’t have any way to backup the system. So If I loose it I loose it. Right now I’m not really needing it, so I have it running and I’m playing with it to see if I loose anything on it. I’m thinking the first time I loose it I’ll probably nix the idea of using RAID 5. I’ve had that problem in the past. But that was 13 years ago. RAID has come a long way since then. I guess I’ll wait and see.