Here is a Bash Script that checks the status of a Linux software RAID using MDADM and Smart.

#!/bin/bash
#A Bash Script that will check the status of a Linux software RAID
#Version 1.0
#Copyright (c) Jason C. Brown (2009)
#Released under the GNU GPLv3 license
#Tested under RHEL 5

DAY=$(date +%D)
RAID=md0
HD=$(/sbin/mdadm –detail /dev/$RAID | grep active | awk -F ” ” ‘{ print $7 }’ | sed ’s/\/dev\///g’)
LEVEL=$(/sbin/mdadm –detail /dev/$RAID | grep “Raid Level” | awk -F “:” ‘{ print $2 }’)
HN=$(uname -n | awk -F “.” ‘{ print $1 }’)
SYSUPTIME=$(uptime | awk ‘{ print $3 ” ” $4 ” ” $5 ” hours”}’ | sed ’s/\,//g’)

echo “”

echo “RAID health check for” $HN “on” $DAY
echo “System uptime: ” $SYSUPTIME
echo “”
echo “File System”
df -H | grep -vE ‘^Filesystem|tmpfs|cdrom’ | awk ‘{ print $1 ” ” $5 }’ | column -t
echo ” “

echo “Checking” $LEVEL “Consistency”
echo “———————————————————-”
echo $RAID
/sbin/mdadm –detail /dev/$RAID | grep -E ‘State|Checksum|Device Size|Raid Devices|Active Devices|Working Devices|Failed Devices
|Persistence’ | grep -v ” Number Major Minor RaidDevice State”
echo “”

for drive in $HD;
do
echo $drive;
/sbin/mdadm –examine /dev/$drive | grep -E ‘State|Checksum|Device Size’ | grep -v ” Number Major Minor RaidDevice
State” | column -t
/usr/sbin/smartctl -a /dev/$drive | grep ‘SMART overall-health self-assessment test result’ | awk -F ” ” ‘{ print $1 ” “
$2 ” ” $5 ” ” $6}’
/usr/sbin/smartctl -a /dev/$drive | grep ‘Temperature_Celsius’ | awk -F ” ” ‘{ print $2 ” ” $4 }’
echo “”
done

echo “I/O stats for main drive”
echo “———————————————————-”
iostat -p /dev/hdc | grep -vE ‘Linux’
echo “I/O stats for raid drive”
echo “———————————————————-”
iostat -p /dev/md0 | grep -vE ‘Linux’