Nagios shell plug-ins
NIC status, speed and duplex check on Solaris servers (uses dladm)
# vi libexec/check_nic
#!/usr/bin/bash
if [[ $# != 6 ]]; then
echo "Usage: check_nic -i <if> -s <10|100|1000|10G> -d <half|full>"
exit 2
fi
s=`echo $@|awk -F"-" '{I=""; S=""; D=""; for (i=1;i<=NF;i++) {split($i, arg, " ");
if (arg[1]=="i") I=arg[2]; if (arg[1]=="s") S=arg[2]; if (arg[1]=="d") D=arg[2]};
if (I=="") {print "-i <if> is required"; exit}
if (S!=10&&S!=100&&S!=1000&&S!="10G") {print "-s <10|100|1000|10G> is required"; exit}
if (D!="half"&&D!="full") {print "-d <full|half> is required"; exit}
print I, "link=up", "speed="S, "duplex="D}'`
echo $s|grep "required"
if [[ $? == 0 ]]; then
exit 2
fi
i=`echo $s|cut -f1 -d" "`
l=`echo $i|wc -m`
l=$(($l-2))
d=`echo $i|cut -c1-$l`
ei=`grep $d /etc/path_to_inst`
if [[ X${ei} != "X" ]]; then
s1=`/sbin/dladm show-dev -p $i`
else
echo "No such interface"
exit 1
fi
if [[ X${s1} == X${s} ]]; then
echo "SUCCESS: $s1"
exit 0
else
echo "FAILURE: $s1"
exit 1
fi
Solaris Volume Manager checks against know good state (uses metastat)
# vi libexec/check_svm
#!/usr/bin/bash
if [[ $# > 0 ]]; then
echo "Usage: check_svm"
exit 2
fi
known_good_state="d50 m 12GB d51 d52
d51 s 12GB c1t0d0s5
d52 s 12GB c1t1d0s5
d30 m 7.8GB d31 d32
d31 s 7.8GB c1t0d0s3
d32 s 7.8GB c1t1d0s3
d20 m 3.9GB d21 d22
d21 s 3.9GB c1t0d0s1
d22 s 3.9GB c1t1d0s1
d10 m 2.0GB d11 d12
d11 s 2.0GB c1t0d0s0
d12 s 2.0GB c1t1d0s0
d40 m 7.8GB d41 d42
d41 s 7.8GB c1t0d0s4
d42 s 7.8GB c1t1d0s4"
current_state=`/sbin/metastat -c`
if [[ ${current_state} == ${known_good_state} ]]; then
echo "SUCCESS: all metadevices are in known good state"
exit 0
else
echo "FAILURE: some metadevices have failed"
exit 1
fi
ZFS or precisely, Solaris zfs pools check (uses zpool)
# vi libexec/check_zfs
#!/usr/bin/bash
if [[ $# > 0 ]]; then
echo "Usage: check_zfs"
exit 2
fi
known_good_status="all pools are healthy"
current_status=`/sbin/zpool status -x`
if [[ $current_status == $known_good_status ]]; then
echo "SUCCESS! zpool status result: $current_status"
exit 0
else
echo "FAILURE! zpool status result: $current_status"
exit 1
fi