Admins eHow SysAdmin Tips & Tricks

September 1, 2014

Send email alerts if Adaptec raid fails in Linux

Filed under: linux — Tags: , , , , — admin @ 10:56 am

For Adaptec Raid you need arcconf tool to check the raid status, you can install it based on the instructions provided on this link (For Debian) :
http://hwraid.le-vert.net/wiki/DebianPackages
After you have arcconf installed, create /usr/bin/raidcheck with following content and make it executable :

#!/bin/bash
RESULT=$(arcconf GETCONFIG 1 | grep Status | grep -v "Not Installed" | grep -v Optimal)
if [ -n "$RESULT" ]; then
    wget http://domain.com/notify.php?m=RAID_ERROR -O /dev/null
    else echo "Raid is OK"
fi

Note : In my script I have chosen to use a php script on another server to send the alert, this way I wont need to install a mail server on every server which I am monitoring. you can do the same or change the wget line to whatever you want.
Put the script in the cron to check the raid status every 12 hours :

0 */12 * * * /usr/bin/raidcheck

July 20, 2014

Send email alerts when HP Proliant RAID fails in Linux

Filed under: linux — Tags: , , , , , , , — admin @ 7:51 pm

As a minimalist person, I am not a fan of running heavy monitoring tools of HP on my server. so I have written a very small bash script to monitor my server RAID status and send me email alerts if it fails.
For this script to work, first you need to install hpacucli (HP Array Configuration Utility) on your server. you can download it from HP website for your Linux distribution.
The script is very easy to understand but you may need to tweak it a little bit to fit your server.
The heart is this line :

hpacucli ctrl slot=1 pd all show

which returns following on my server :

\\ EMPTY LINE
Smart Array P222 in Slot 1

   array A

      physicaldrive 2I:1:1 (port 2I:box 1:bay 1, SATA, 3 TB, OK)
      physicaldrive 2I:1:2 (port 2I:box 1:bay 2, SATA, 3 TB, OK)
      physicaldrive 2I:1:3 (port 2I:box 1:bay 3, SATA, 3 TB, OK)
      physicaldrive 2I:1:4 (port 2I:box 1:bay 4, SATA, 3 TB, OK)

but we only need lines 6-9 which are showing the drives status. It is where you may need to tweak it as you may have more or less drives.
So it may not be 6-9 for you and you may need to change 6,9 in sed command.
Here is the final script :

#!/bin/bash
MAIL=mail@domain.com
RESULT=`hpacucli ctrl slot=1 pd all show | sed -n '6,9 p' | grep -v OK`
if [ -n "$RESULT" ]; then
	echo "$RESULT" | mail -s 'Raid Error' "$MAIL"
	else echo "Raid is OK"
fi

Dont forget to change MAIL variable to your own email address.
You may test the script once to make sure your server is able to send emails and you actually receive them.
Finally save the script in a file and put it in cronjob. I have chosen to run it every 12 hours :

0 */12 * * * /usr/bin/raidcheck

February 26, 2012

How to update Adaptec raid driver on Centos & RHEL5

Filed under: CentOS,General — Tags: , , , , , , , — admin @ 6:51 pm

Download the driver RPMs from adaptec website, as I have 5805z controller, I downloaded the drivers from here :

http://www.adaptec.com/en-us/support/raid/sas_raid/sas-5805z
http://www.adaptec.com/en-us/downloads/rh/rhel_5/productid=sas-5805z&dn=adaptec+raid+5805z.html

You will get a file like this :

aacraid_linux_rpms_v1.1.7-28700.tgz

unpack it :

tar zxvf aacraid_linux_rpms_v1.1.7-28700.tgz

to get :

aacraid-1.1.7-28700.rpm

install rpm :

rpm -ivh --force aacraid-1.1.7-28700.rpm

it will only extract the files to /opt/Adaptec/aacraid :

cd /opt/Adaptec/aacraid
mkdir mods
mv aacraid_prebuilt.tgz mods
cd mods
tar zxvf aacraid_prebuilt.tgz
rm *.tgz

now you have prebuilt module for different kernels, copy the appropriate kernel module to aacraid.ko path, a command like :

cp aacraid-2.6.18-238.el5xen-x86_64 /lib/modules/2.6.18-274.18.1.el5xen/kernel/drivers/scsi/aacraid/aacraid.ko

if you have locate package installed, you can easy find all aacraid.ko files :

locate aacraid.ko | xargs -n1 modinfo | grep vers

when it is complete, reboot the server.

Powered by WordPress