diff --git a/README.md b/README.md index ba54917..0af67b6 100644 --- a/README.md +++ b/README.md @@ -61,4 +61,37 @@ This condenses MegaCLI's default detailed information about drives within the ar alias raidinfo="sudo megacli -LDInfo -Lall -aALL" ``` -This provides information about the array itself including the array's usable size, parity size, sector size, state and encryption type. \ No newline at end of file +This provides information about the array itself including the array's usable size, parity size, sector size, state and encryption type. + +## Automated Monitoring + +To automate monitoring of the RAID array's health and drive status I created a Bash script to email me, [utilizing my self hosted mail accounts](https://git.tobiastime.xyz/Tobias/Mail-Server), if any drive has a S.M.A.R.T alert or if the RAID array's health is reported as anything but optimal via MegaCLI. + +This saves me having to manually monitor and check the health of the drives and array, but will still bring anything requiring direct intervention to my attention affording me apt time to respond before an incident occurs. + +Script: + +``` bash +#/bin/bash + +#If any drive returns yes for a S.M.A.R.T alert email my account tobias@tobiastime.xyz + +megacli -PDList -aALL | grep -i 's.m.a.r.t' | grep -i 'yes' &&\ +\ +echo -e "To: tobias@tobiastime.xyz\nFrom: snorlax@tobiastime.xyz\nSubject: RAID Drives\nA RAID Drive on Snorlax has had a flagged S.M.A.R.T alert at $(date)" | ssmtp tobias@tobiastime.xyz + +#If raid health is anything but optimal email my account tobias@tobiastime.xyz + +raidhealth=$(megacli -LDInfo -Lall -aALL | awk 'NR==11 {print $3}') + +[ "$raidhealth" != "Optimal" ] && \ +echo -e "To: tobias@tobiastime.xyz\nFrom: snorlax@tobiastime.xyz\nSubject: RAID Array\nMegaCLI has reported the RAID array is not currently operating in an optimal state at $(date)" | ssmtp tobias@tobiastime.xyz +``` + +Crontab Entry: + +``` +0 */3 * * * /home/charizard/myscripts/raidnotifier +``` + +This runs the check every 3 hours.