Friday, August 29, 2008

queryperf: 測試DNS Server的效能/壓力工具

今天找到了一個對於DNS Server做stress test的好工具: queryperf,這個工具事實上內建於bind套件中,不過我的Centos5.2與OpenSUSE10是透過rpm安裝bind的,利用rpm -ql | grep -i queryperf卻找不到相關的檔案?於是乎我去抓了bind tarball檔,將queryperf compile起來,產生queryperf binary file就可以使用了。

使用的語法也不難主要如下:

./queryperf -d -s

-d 是讀取測試RR文檔的意思
-s 是指定所要測試的DNS Server

RR_document的格式也是很簡單的,請參考以下範例:
server1.example.com A -> query server1.example.com A Record
example.com MX -> query example.com domain mx Record
mail.example.com CNAME -> query mail.example.com CNAME
server1.example.com TXT -> query server1.example.com TXT Record
example.com TXT -> query example.com domain TXT Record
example.com NS -> query example.com domain NS Record
100.10.10.10.in-addr.arpa PTR -> query 10.10.10.100 PTR Record
101.10.10.10.in-addr.arpa PTR -> query 10.10.10.101 PTR Record

Note: ->是說明,不需要加入到RR_document

執行結果:
Statistics:

Parse input file: once
Ended due to: reaching end of file

Queries sent: 8 queries
Queries completed: 8 queries
Queries lost: 0 queries
Queries delayed(?): 0 queries

RTT max: 0.033874 sec
RTT min: 0.013128 sec
RTT average: 0.023992 sec
RTT std deviation: 0.007508 sec
RTT out of range: 0 queries

Percentage completed: 100.00%
Percentage lost: 0.00%

Started at: Mon Aug 25 03:33:47 2008
Finished at: Mon Aug 25 03:33:47 2008
Ran for: 0.034861 seconds

Queries per second: 229.482803 qps

緊接著來寫個簡單的script讓他不斷的執行queryperf吧!
#!/bin/bash
while true
do
./queryperf -d dnstest -s $1 -v
done

把DNS所有的RR都寫入RR_document,這麼一來,就可以來試看看你的DNS Server耐不耐操了 XD!

No comments: