Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
nagios plugin for monitoring mdraid mismatch count
#!/bin/bash
# stolen from https://www.thomas-krenn.com/en/wiki/Mdadm_checkarray
# template from http://www.juliux.de/nagios-plugin-vorlage-bash
# modified to work with more than one array by ursetto
set -e
WARN_LIMIT=$1
CRIT_LIMIT=$2
if [ -z $WARN_LIMIT ] || [ -z $CRIT_LIMIT ]; then
echo "Usage: check_linux_raid_mismatch WARNLIMIT CRITLIMIT"
exit 3;
fi
DATA=0
PERF_DATA=""
for file in /sys/block/md*/md/mismatch_cnt
do
if [ ! -f $file ]; then
echo "UNKNOWN - $file not found | "
exit 3;
fi
DATA=$((DATA + $(cat $file)))
MD_NAME=$(echo $file | awk -F/ '{ print $4 }')
PERF_DATA+="$MD_NAME=$(cat $file) "
done
if [ $DATA -lt $WARN_LIMIT ]; then
echo "OK - all software raid mismatch_cnts are smaller than $WARN_LIMIT | $PERF_DATA"
exit 0;
fi
if [ $DATA -ge $WARN_LIMIT ] && [ $DATA -lt $CRIT_LIMIT ]; then
echo "WARNING - software raid mismatch_cnts are greater or equal than $WARN_LIMIT | $PERF_DATA"
exit 1;
fi
if [ $DATA -ge $CRIT_LIMIT ]; then
echo "CRITICAL - software raid mismatch_cnts are greater or equal than $CRIT_LIMIT | $PERF_DATA"
exit 2;
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment