#!/bin/bash # Script for monitoring software RAID devices using md5 checksums of the # /proc/mdstat file. Set up a cron job to run this script as often as you'd # like to check the RAID status. Requires sendmail (or equivalent) on the # local machine. Contributed by Stian Barmen. # Set a value for tmp and email header file tmp=/root/scripts/raidcheck header=$tmp/header # First time tool is run this will fail, but after next time # this will compare the md5 of /proc/mdstat to the saved # value of the md5sum file. a=`md5sum -c $tmp/md5sum` if [ "$a" = "/proc/mdstat: OK" ] then echo "RAID Check: All status OK" else # Send mail that status changed, attaching a standard email header # from the file header (see the attached example) plus the status # from /proc/mdstat. a=`cat /proc/mdstat` `echo -e "Subject: RAID Check warning!\n\n"\ "Check the status of the RAID below!\n\n"$a\ | sendmail root` # Add new md5 key to checkfile (this is now status OK) `md5sum /proc/mdstat > /root/scripts/raidcheck/md5sum` fi