LCOD 11.14.07 – Quick RAID check script for cron


This is a quick script that will let you run the new raid checks, or repair, or pause a running raid check. It doesn’t do e-mails or anything, and from what I read on this thread it’s something mdadm needs to be set to watch for. I ran the check on a RAID and received no output, so I guess it was ok?

I will update the script as I find out more. I’d like to add a simple escalation from check to rebuild? (I think it does this anyways), and an e-mail status report, or even a syslog call saying I ran all things look good.


#!/bin/bash
###############
# Quick script to use raid functionality
# Author : Jon Zobrist < jon@bluesun.netThis e-mail address is being protected from spam bots, you need JavaScript enabled to view it >
# http://www.bluesun.net/
# License : LGPL
# Version : 1.0
# Date : 11.14.07
# install/notes:
# put it somewhere, /root/bin/ is where I prefer
# put this in your root crontab to run from cron monthly
# @monthly /root/bin/checkraids check > /root/logs/cron.log 2>&1
###############

case "$1" in
check)
for raid in /sys/block/md*/md/sync_action
do
echo check > $raid
done
;;

repair)
for raid in /sys/block/md*/md/sync_action
do
echo repair > $raid
done
;;

pause)
for raid in /sys/block/md*/md/sync_action
do
echo idle > $raid
done
;;

status)
for raid in /sys/block/md*/md/sync_action
do
echo "******************************"
echo $raid `cat $raid`
echo ""
done
;;

*)
echo "Usage : $0 check|repair|pause|status"
;;
esac

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

, , , , , ,

Easy AdSense by Unreal