Skip to content

Instantly share code, notes, and snippets.

@amosbird
Last active August 17, 2017 05:48
Show Gist options
  • Save amosbird/9f1bd182cca01db8da7d1618458685b0 to your computer and use it in GitHub Desktop.
Save amosbird/9f1bd182cca01db8da7d1618458685b0 to your computer and use it in GitHub Desktop.
check disk failures using megacli
#!/usr/bin/env bash
while [[ 1 ]]; do
nd=$(sudo /opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL | grep "Firmware state: Online, Spun Up" | wc -l)
if [[ nd -ne <YOU DISK NUM> ]];
then
echo "check it using sudo /opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL" | mail -s "$HOSTNAME has disk failure!!" <YOU EMAIL ADDRESS>
sleep 3600
fi
sleep 120
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment