DNS服务解析检测脚本:

DNS服务解析检测脚本:

#!/bin/bash
###############################
#by:xingyaodong               #
#Email:osx1260@163.com     #
###############################
checkdns () {
read -p "Please input the dns ipaddress:" ip
read -p "Please input the dns name:" dnsname
TARGETHOST=$ip
CHECKNAME=$dnsname
DIGCOM=$(dig \@$TARGETHOST $CHECKNAME | grep ";; ANSWER" | wc -l)
if [ $DIGCOM -lt 1 ]; then
        STATUS=2
        STATUSPRINT=CRITICAL
else
        STATUS=0
        STATUSPRINT=OK
fi

echo "$STATUSPRINT - DNS resolution for $CHECKNAME"
exit $STATUS
}

while getopts :h: OPTIONS
do
case $OPTIONS in
        h) TARGETHOST=$OPTARG;;
        *) echo "Invalid Command Line Option";;
esac
done
checkdns

 

posted @ 2013-06-13 05:05  osxlinux  阅读(521)  评论(0编辑  收藏  举报