nagios: check_mdadm

#supports multiple mdadm arrays

root@backupsrv:~# cat /usr/local/ncpa/plugins/check_mdadm
#!/bin/bash
arrays=$(df | grep md | cut -d ‘ ‘ -f 1)
msg=””
for array in $arrays; do
state=$(sudo mdadm -D $array | grep -i “State :” | cut -d ‘:’ -f 2)
if [[ $state -ne “clean” ]]; then
msg+=”ERROR: $array is $state”
error=1
else
msg+=”OK: $array is $state”
ok=0
fi
done

echo $msg

if [[ -x $error ]]; then
exit $error
else
exit $ok
fi

root@backupsrv:~# /usr/local/ncpa/plugins/check_mdadm
OK: /dev/md127p1 is clean OK: /dev/md0p1 is clean, resyncing

Leave a Reply