0

I'm trying to setup a script that will check the RAID status using the MegaCli command. I have 2 RAID volumes, so my script outputs the state of both volumes. What I'm trying to figure out is how to to loop through the output to check each state.

I execute:

/usr/sbin/MegaCli64 -CfgDsply -aALL -nolog |grep '^State' |awk '{print $3}'

And my output is:

Optimal
Optimal

My current script is:

#!/bin/bash
STATUS=`/usr/sbin/MegaCli64 -CfgDsply -aALL -nolog |grep '^State' |awk '{print $3}'`

if [ "$STATUS" != "Optimal" ]; then
  echo -e "Subject: RAID WARNING @ `hostname`\n\n$STATUS"|/usr/sbin/sendmail admin@abc.com
fi

Which does not work properly. I'm completely new to bash scripting and the results I've found and tried by googling just don't work either.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.