Last active
April 21, 2025 19:35
-
-
Save ericbarch/2d1953c0af2459c89ab87a3064fdb2a0 to your computer and use it in GitHub Desktop.
Dead simple alerts when your mdadm array degrades without setting up a full blown MTA
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# dead simple mdadm alerts via webhook | |
# by eric barch [v1.0 -- 2018.11.26] | |
# 1. place this file in ~/chkraid.sh | |
# chmod +x ~/chkraid.sh | |
# 2. drop this in your crontab: | |
# 0 * * * * /home/<your_username>/chkraid.sh | |
# 3. get free account at http://healthchecks.io (no affiliation) | |
# then create a new healh check (period: one hour) and paste the URL below | |
SUCCESS_URL_HEALTHCHECK="https://hc-ping.com/YOUR_CHECK_URL" | |
# 4. fill in the substring that represents your healthy array | |
# helpful info on the output of /proc/mdstat here: | |
# https://raid.wiki.kernel.org/index.php/Mdstat#md_config.2Fstatus_line | |
# example: a dual RAID array (U represents a drive that is up) | |
RAID_HEALTHY_SUBSTRING="[UU]" | |
# 5. make sure you have curl installed | |
echo "Checking status of RAID array..." | |
raid_status=$(cat /proc/mdstat) | |
if [[ $raid_status == *"$RAID_HEALTHY_SUBSTRING"* ]]; then | |
echo "It's good!" | |
/usr/bin/curl $SUCCESS_URL_HEALTHCHECK | |
else | |
echo "Ahhhhh!" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment