使用bind  自带测试软件queryperf

1.安装:

http://download.chinaunix.net/download/0001000/6.shtml

下载bind-9.8.2.tar.gz 

# tar  xf  bind-9.8.2.tar.gz

# cd bind-9.8.2/contrib/queryperf

# ./configure

# make

# cp  queryperf  /usr/bin/


2.使用

  格式:queryperf [-d datafile] [-s server_addr] [-p port] [-q num_queries]

  -d: 后面接上一个文件,文件的内容是用户对DNS的请求,一行为一条请求,所以为了测试,我们可以       在里面写上几千几万条。
  -s: DNS服务器地址
  -p: DNS服务器端口
  -q: 请求多少次
  测试 :

 如果要测试 www.abc.com

# cat  abctest.txt

www.abc.com     A

..

..

 ----------一行一条,测试前可以预估有多少请求来测试;除了A记录外 也可以添加NS  CNAME 等;


# queryperf -d abctest.txt  -s DNS_IP 

~~~~~~~~~测试下在本地,设置不同DNS时域名的解析情况,如每秒可以处理多少个请求~~~~~~~~

~~~~~~~~~~以下只是把queryperf 命令的输出写到以各DNS服务器IP命名的文件中~~~~~~~~~~~~~~

#cat dns_test.sh

#!/bin/sh


while read line

do

{

 exec  6>&1

 exec >> /root/workstation/result/${line}.log


 CURRENT_TIME=`date  +%Y年%m月%d日%H时%M分`

 echo $CURRENT_TIME 

 echo "---------------------------" 

 queryperf -d /root/workstation/test.txt  -s $line 

 wait

 echo "###################################################" 


exec 1>&6 6>&-


}


done</root/workstation/test_dns.txt


exit 0



~~~~~~~~~~~~~~~~~~~~ 找出感兴趣的数值,通过排序,找出最大最小平均值~~~~~~~~~~~~~~~~~~

#cat  data_result.sh

#!/bin/sh


while read line

do

{

 exec  6>&1

 exec >> /root/workstation/test-result/dns_test_result.txt

echo "=========================================="

 echo $line  

min=`grep  qps  /root/workstation/result/$line.log | awk '{print $4}'| cut -d. -f1| sort -n | head -n1`

echo min=${min}

max=`grep  qps  /root/workstation/result/$line.log | awk '{print $4}'| cut -d. -f1 | sort -n| tail -n1`

echo max=${max}


grep  qps  /root/workstation/result/$line.log | awk '{print $4}'| cut -d. -f1| awk '{sum+=$1} END {print "Average = ", sum/NR}'

echo "=========================================="


exec 1>&6 6>&-


}


done</root/workstation/test_dns.txt


exit 0

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~