3ware RAID monitoring script
3ware RAID cards are used by the majority of Data Centers (Layeredtech, Softlayer, etc.) so if you have a RAID card installed (which is always a good idea) you might have a 3ware card.
I don’t know if you know or not (many people don’t) but it’s your responsibility to monitor the RAID array. There will be no errors on screen if something is wrong with the array until it’s too late and your system will not boot.
3ware has a nice monitoring and management tool for Linux called tw_cli. While this comes with a monitoring script I found it hard to setup so I thought that I will write a personalized monitoring script that will check the status of the array and it will send me an email when the array is degraded.
Here are the simple steps that you have to fallow to setup this script:
- First you must have a 3ware RAID card. you can check this by running
- Install tw_cli
- Write a bash file with the fallowing
- Schedule a cron to run this script every day or so. You can do something like this:
- Restart crond
lspci | grep 3ware
If it outputs something about a 3ware RAID card you have one.
wget http://www.3ware.com/download/Escalade9500SSeries/9.3.0.4/tw_cli-linux-x86-9.3.0.4.tgz
gzip -d tw_cli-linux-x86-9.3.0.4.tgz
tar -xf tw_cli-linux-x86-9.3.0.4.tar
Note the path to tw_cli !
#!/bin/bash
com=`/path_to_ tw_cli/tw_cli info c0 u0 status | awk ‘{print $4}’`
echo $com
if [ "$com" = "DEGRADED" ];
then
mail -s “RAID Warning” you@domain.com < body
fi
Note: You also have to make a file called “body” that will have the body of the warning email.
Also replace you@domain.com with your email.
crontab -e
Add a line like:
0 11,23 * * * /path_to_script/test
This will test the array at 11:00 and 23:00 and will email you if it detects any problems.
service crond restart
Hope it helps !
If you have any suggestions to improve the script please leave a comment.
If you enjoyed this post, make sure you subscribe to my RSS feed!
- December 26th


(1 votes, average: 4 out of 5)














Leave a Reply