검사 자체는 nslookup 명령의 무한 while 루프입니다. while 루프 앞에서 nslookup 응답을 저장하기 위한 임시 파일이 설정됩니다. probefail 및 retries 변수는 0으로 초기화됩니다.
# Set up a temporary file for the nslookup replies. DNSPROBEFILE=/tmp/.$RESOURCE_NAME.probe probefail=0 retries=0 |
검사의 일지 정지 간격을 설정합니다.
Probe_timeout 값을 전달하고 대상 호스트를 식별하는 nslookup을 hatimerun을 사용하여 시작합니다.
nslookup 반환 코드의 성공 또는 실패에 기초하여 probefail 변수를 설정합니다.
probefail이 1(실패)로 설정된 경우 다른 DNS 서버가 아닌 샘플 데이터 서비스에서 nslookup에 대한 응답이 오는지 확인합니다.
다음은 while 루프 코드입니다.
while : do # The interval at which the probe needs to run is specified in the # property THOROUGH_PROBE_INTERVAL. Therefore, set the probe to sleep # for a duration of THOROUGH_PROBE_INTERVAL. sleep $PROBE_INTERVAL # Run an nslookup command of the IP address on which DNS is serving. hatimerun -t $PROBE_TIMEOUT /usr/sbin/nslookup $DNS_HOST $DNS_HOST \ > $DNSPROBEFILE 2>&1 retcode=$? if [ $retcode -ne 0 ]; then probefail=1 fi # Make sure that the reply to nslookup comes from the HA-DNS # server and not from another nameserver mentioned in the # /etc/resolv.conf file. if [ $probefail -eq 0 ]; then # Get the name of the server that replied to the nslookup query. SERVER=` awk ' $1=="Server:" { print $2 }' \ $DNSPROBEFILE | awk -F. ' { print $1 } ' ` if [ -z "$SERVER" ]; then probefail=1 else if [ $SERVER != $DNS_HOST ]; then probefail=1 fi fi fi |