#!/bin/bash #if [ `uname -m` = x86_64 ]; then # /opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -Lall -a0 > /var/log/raidstatus #else # /opt/MegaRAID/MegaCli/MegaCli -LDInfo -Lall -a0 > /var/log/raidstatus #fi /opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -Lall -a0 > /var/log/raidstatus sleep 5 status=$(/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -Lall -a0 | awk '/State/ {print $2}' | uniq) hname=$(hostname) ipinfo=$(ifconfig br0 | awk '/inet/ {print x}; { x=$0 }') if [ "$status" != "Optimal" ]; then echo -e "Megaraid Hardware RAID Alarm Detected on $hname Details: \n $ipinfo `cat /var/log/raidstatus` " | mail -s "Megaraid SAS RAID Alarm on $hostname" support@example.com fi exit 0