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