Tsung 是一個壓力測試工具,能夠測試包括HTTP, WebDAV, PostgreSQL, MySQL, LDAP, and XMPP/Jabber等服務器。針對 HTTP 測試,Tsung 支持
HTTP 1.0/1.1 ,包含一個代理模式的會話記錄、支持 GET、POST 和 PUT 以及 DELETE 方法,支持 Cookie 和基本的WWW 認證,同時還支持 SSL。html
tsung的工做原理
(1) Tsung的每個虛擬用戶就是一個erlang的輕量進程。這點和loadrunner有很大的區別。
(2) 虛擬用戶完成session後就消失。
(3) 大量的虛擬用戶(erlang輕量進程)創建在erlangVM上。
(4) 一臺測試機能夠啓多個erlangVM,目前按照1個cpu啓動1個erlangVM。node
在安裝以前確保安裝瞭如下工具:nginx
下載並安裝erlangshell
1 # wget http://www.erlang.org/download/otp_src_R14B04.tar.gz 2 # tar -zxvf otp_src_R14B04.tar.gz 3 # cd otp_src_R14B04 4 # ./configure --prefix=/usr/local/erlang
1 #檢查erlang目錄是否存在,不存在則mkdir. 2 # make 3 # make install
注意:若是出現 "configure: error: No curses library functions found "錯誤,嘗試安裝:vim
yum install -y ncurses-devel
下載並安裝Tsungwindows
# wget http://tsung.erlang-projects.org/dist/tsung-1.6.0.tar.gz # tar -zxvf tsung-1.6.0.tar.gz # cd tsung-1.6.0 # ./configure --prefix=/usr/local/tsung --with-erlang=/usr/local/erlang # make # make install
下載並安裝perl Template,用於生成報告模版服務器
# wget http://cpan.org/modules/by-module/Template/Template-Toolkit-2.26.tar.gz # tar -zxvf Template-Toolkit-2.26.tar.gz # cd Template-Toolkit-2.26 # perl Makefile.PL #perl出錯不可用時先執行: $ yum install perl-ExtUtils-MakeMaker 安裝Perl. # make # make test # make install
注意:若是出現 如下提示:session
[root@localhost Template-Toolkit-2.24]# perl Makefile.PL Can't locate ExtUtils/MakeMaker.pm in @INC (@INC contains: ./lib /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at Makefile.PL line 11. BEGIN failed--compilation aborted at Makefile.PL line 11.
解決辦法:ssh
yum install perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker
下載並安裝gnuplot,用於聊天生成async
# yum install -y gnuplot gd libpng zlib
安裝成後添加erlang、tsung環境變量
[root@localhost local]# vim /etc/profile export PATH=$PATH:$JAVA_HOME/bin:/usr/local/erlang/bin:/usr/local/tsung/bin:/usr/local/nginx/sbin:$PATH(修改本身實際變量) :wq保存,退出 [root@localhost local]# source /etc/profile 不報錯則成功 [root@localhost local]# tsung -v Tsung version 1.4.2 [root@localhost local]# erl -v Erlang R14B04 (erts-5.8.5) [source] [64-bit] [rq:1] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.8.5 (abort with ^G) 1>
[root@localhost local]# perl -v 命令查看顯示perl 當前版本信息。 [root@localhostlocal]# gnuplot 命令查看gnuplot 的安裝版本 [root@localhost local]# erl 命令查看erlang的安裝版本 Erlang R14B04 (erts-5.8.5) [source] [64-bit] [rq:1] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.8.5 (abort with ^G) [root@localhost local]# tsung -v 命令查看tsung 的安裝版本 Tsung version 1.4.2
一、在root文件夾下新建.tsung目錄,用於存放log和xml配置,測試配置文件可參考/usr/local/tsung/share/doc/tsung/examples/目錄下配置
[root@localhost local]#mkdir ~/.tsung
[root@localhost local]#cp /usr/local/tsung/share/doc/tsung/examples/http_simple.xml ~/.tsung/tsung.xml
二、運行,默認執行腳本~/.tsung/tsung.xml配置
[root@localhost local]# tsung start Starting Tsung "Log directory is: /root/.tsung/log/20150311-0536"
三、進入Log目錄下能夠看到生成的報表信息
[root@localhost 20150311-0536]# cd /root/.tsung/log/20150311-0536 [root@localhost 20150311-0536]# ls -a . .. match.log tsung_controller@localhost.log tsung.log tsung.xml
四、進入須要生成圖形報表的Log目錄,如/root/.tsung/log/20150311-0536
[root@localhost 20150311-0536]# /usr/local/tsung/lib/tsung/bin/tsung_stats.pl creating subdirectory data creating subdirectory gnuplot_scripts creating subdirectory images No data for Session No data for Perfs No data for Transactions No data for Match No data for Event No data for Async No data for Size size_rcv is equal to 0 ! size_sent is equal to 0 ! [root@localhost 20150311-0536]# ls data gnuplot.log gnuplot_scripts graph.html images match.log report.html tsung_controller@localhost.log tsung.log tsung.xml
五、將report.html拖到windows系統中,直接打開便可查看。
Usage: tsung <options> start|stop|debug|status Options: -f <file> set configuration file (default is ~/.tsung/tsung.xml) (use - for standard input) -l <logdir> set log directory (default is ~/.tsung/log/YYYYMMDD-HHMM/) -i <id> set controller id (default is empty) -r <command> set remote connector (default is ssh) -s enable erlang smp on client nodes -p <max> set maximum erlang processes per vm (default is 250000) -m <file> write monitoring output on this file (default is tsung.log) (use - for standard output) -F use long names (FQDN) for erlang nodes -w warmup delay (default is 10 sec) -v print version information and exit -6 use IPv6 for Tsung internal communications -h display this help and exit