| Below is server status checking code can run on LINUX. #!/bin/sh
host=$1
server=$2
# 현재시간을 nano초 단위로 얻는다.
time1=`date +%s.%N`
result=`nslookup -timeout=5 -retry=0 $host $server`
# checking time out string in output string
echo $result | grep "timed out" > /dev/null
status=$?
# set current time by nano seconds
time2=`date +%s.%N`
# get the duration by bc(:12)
diff=`echo "$time2 - $time1" | bc`
# if time out, display FAILURE
# if not, display OK
# if successful, display reply time
if [ $status -eq 0 ]
then
echo "DNS LOOKUP FAILURE|status=0"
else
echo "DNS LOOKUP OK|time=$diff status=1"
fi |