Created
August 8, 2015 00:24
-
-
Save ursetto/cb91eb62896090b70306 to your computer and use it in GitHub Desktop.
nagios plugin for monitoring mdraid mismatch count
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 | |
# 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