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

nagios: check_triplex_cctv

jjest@house-nagios:~$ cat /usr/local/nagios/libexec/check_triplex_cctv
#!/bin/bash
host=$1
if [[ ! -z $host ]]; then
ssh nagios@triplex.duckdns.org “ping -c 2 $host” > /dev/null
resultant=$?
if [[ $resultant == “0” ]]; then
echo “OK – $host”
exit 0
else
echo “ERROR – $host”
exit 1
fi
else
echo “ERROR – No host value given”
exit 1
fi