Home > Linux, SLES, SSH > Arcconf Bash Reporting Script

Arcconf Bash Reporting Script

February 24th, 2009

Monitor your RAID Controller at all times!
There is no need to tell you that Monitoring your RAID is of great importance.

Another important thing that I would like to say is that RAID is Not a Backup solution.

So just don’t use it is one or the chances are you will recall these words with bitter regret when you least expect it.
The above sounds like a curse, doesn’t it 🙂
And “when you least expect it” could be an uncomfortable period time for you [no internet, vacation to a deserted destination with no network coverage what so ever, no laptop or mobile device that could allow you to react,… here you can let your imagination lose for a moment and you might get a grasp of all the bad moments to have a RAID problem, or any other problem with your service but this article focuses on the RAID…]

When I first decided to write a bash script few days ago I searched the Internet for something similar that I could reuse and edit a bit. Of course I found this article:

http://wiki.w0wdx.com/Hobbit_script_to_monitor_Adaptec_Raid_Controllers_using_adaptec_arccon

My version is slightly edited since the results from the arcconf getconfig 1 command are different on the Adaptec 3405 controller that I use.

The script creates a file in the /var/tmp folder and stores the output of the arcconf getconfig 1 al command inside that file. Then the other variables are assigned values grepped from the output of that command. I have examined the normal output and configured a rule-set that will send me an e-mail if the output differs from the so called NORMAL output.

I have also installed the script as a daily cron and this is the sole reason to get e-mails from it ONLY if the output is different than expected.

Don’t foget to chmod +x adaptecchk.sh before you try to execute it.

#!/bin/bash

MSG=”Adaptec 3405 Raid Status \n”

RAID=/var/tmp/adaptec3405.$$

/usr/StorMan/arcconf getconfig 1 al > $RAID

CTRLSTAT= `grep “Controller Status” $RAID| cut -d\: -f2`
CTRLBATINFO= `grep -A 2 “Controller Battery” $RAID|grep “Status”| cut -d\: -f2`
CTRTEMP= `grep “Temperature” $RAID| cut -d\: -f2|awk ‘{print $5}’`
LOGICSTAT= `grep “Status of logical device” $RAID| cut -d\: -f2`
LOGICSTR= `grep “Failed stripes” $RAID| cut -d\: -f2`
DRIVE0= `grep -A 2 “Device #0” $RAID|grep “State”| cut -d\: -f2`
DRIVE1= `grep -A 2 “Device #1” $RAID|grep “State”| cut -d\: -f2`

if [ $CTRLSTAT != “Optimal” ]
then
MSG=”${MSG}
`cat ${RAID}`

echo $MSG |mail -s “RAID DAILY INFO ${HOSTMANE} `date`” admin@unix.soteks.org

fi
if [ $CTRLBATINFO != “Optimal” ]
then
MSG=”${MSG}
`cat ${RAID}`

echo $MSG |mail -s “RAID DAILY INFO ${HOSTMANE} `date`” admin@unix.soteks.org
fi
if [ $CTRTEMP != “(Normal)”]
then
MSG=”${MSG}
`cat ${RAID}`

echo $MSG |mail -s “RAID DAILY INFO ${HOSTMANE} `date`” admin@unix.soteks.org
fi
if [ $LOGICSTAT != “Optimal”]
then
MSG=”${MSG}
`cat ${RAID}`

echo $MSG |mail -s “RAID DAILY INFO ${HOSTMANE} `date`” admin@unix.soteks.org
fi
if [ $LOGICSTR != “No”]
then
MSG=”${MSG}
`cat ${RAID}`

echo $MSG |mail -s “RAID DAILY INFO ${HOSTMANE} `date`” admin@unix.soteks.org
fi
if [ $DRIVE0 != “Online”]
then
MSG=”${MSG}
`cat ${RAID}`

echo $MSG |mail -s “RAID DAILY INFO ${HOSTMANE} `date`” admin@unix.soteks.org
fi
if [ $DRIVE1 != “Online”]
then
MSG=”${MSG}
`cat ${RAID}`

echo $MSG |mail -s “RAID DAILY INFO ${HOSTMANE} `date`” admin@unix.soteks.org
fi

rm $RAID

exit 0

I strongly suggest you to examine the output of the arcconf command on your system before you use the script and to edit it if necessary.

Let me know if you have other ideas about such notifications and ways to construct and utilize them!

Categories: Linux, SLES, SSH Tags: , , , , ,
  1. March 4th, 2010 at 08:27 | #1

    I have modernized the script to support several logical devices and many disks. The script is packaged in a debian package together with adaptec management tools over here:
    http://skliarie.blogspot.com/2010/03/adaptec-cli-management-tool.html

  2. March 4th, 2010 at 23:56 | #2

    Howdy Arie,

    Thanks for the input! Great stuff that people can take advantage of the whole package for debian.
    I am interested in your rconf script in clear text. To be honest I don’t use debian to check out what you have done.
    Thanks again and I hope people will be happy with the raid tools.
    — S

  3. Ihchrisw
    May 21st, 2010 at 13:31 | #3

    #!/bin/bash

    TITLE=”Adaptec 52445 Raid Status:”
    MAILTO=$1
    if [ -z “$MAILTO” ];
    then
    MAILTO=root
    fi

    RAID=/var/tmp/adaptec52445.$$

    /usr/sbin/arcconf getconfig 1 al > $RAID

    MSG=””
    CTRLSTAT=$(grep “Controller Status” $RAID| cut -d\: -f2)
    [ $CTRLSTAT != “Optimal” ] && MSG=”$MSG\nController Status is not Optimal”

    CTRLBATINFO=$(grep -A 2 “Controller Battery” $RAID|grep “Status”| cut -d\: -f2)
    [ $CTRLBATINFO != “Optimal” ] && MSG=”$MSG\nController Battery is not Optimal”

    CTRTEMP=$(grep “Temperature” $RAID| cut -d\: -f2|awk ‘{print $5}’)
    [ $CTRTEMP != “(Normal)” ] && MSG=”$MSG\nController Temperature is not Normal”

    let iLOGICALDEV=0
    grep “Status of logical device” $RAID | cut -d\: -f2 | while read STATUS; do
    [ $STATUS != “Optimal” ] && MSG=”$MSG\nStatus of logical device $iLOGICALDEV not optimal”
    let iLOGICALDEV++
    done

    let iLOGICALDEV=0
    grep “Failed stripes” $RAID| cut -d\: -f2 | while read STATUS; do
    [ $STATUS != “No” ] && MSG=”$MSG\nFailed stripes on device $iLOGICALDEV”
    let iLOGICALDEV++
    done

    let iDEVICE=0
    grep “Device #” $RAID | while read DEVICE; do
    STATUS=$(grep -A 2 “$DEVICE” $RAID | tail -1 | cut -d\: -f2)
    [ $STATUS != “Online” ] && MSG=”$MSG\nDEVICE $DEVICE not online”
    let iDEVICE++
    done

    TTY=”$(tty)”
    if [ “$TTY” == “not a tty” ];
    then
    if [ -n “$MSG” ];
    then
    (echo -e “$TITLE\n$MSG”; cat $RAID;) |
    mail -s “RAID WARNING from $HOSTNAME” $MAILTO
    rm $RAID
    fi
    else
    echo $MSG
    echo “See full status in file $RAID”
    fi

    exit 0

  4. aprogrammer
    March 19th, 2014 at 05:01 | #4

    Thanks but I was using this instruction – http://sysadmin.te.ua/linux/aacraid-monitoring.html . There is much more info about Adaptec AAC-Raid monitoring.

Comments are closed.