Tsung简易教程-CentOS版

官网地址:http://tsung.erlang-projects.org/

Tsung压力测试工具的工作原理介绍

(1)  Tsung的每一个虚拟用户就是一个erlang的轻量进程。这点和loadrunner有大区别。

(2)  虚拟用户完成session后就消失。

(3)  大量的虚拟用户(erlang轻量进程)建立在erlangVM上。


CentOS下安装步骤:

一、安装

安装环境:

  1. LSB Version:    :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch  
  2. Distributor ID: CentOS  
  3. Description:    CentOS release 6.5 (Final)  
  4. Release:        6.5  
  5. Codename:       Final  

在安装之前确保安装了以下工具:

  1. yum install gcc -y  
  2. yum install perl -y  
  3. yum install unixODBC  
  4. yum install unixODBC-devel  

 

 

下载并安装erlang
[plain] view plaincopy
  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  
  5. # make  
  6. # make install  
注意:如果出现 " configure: error: No curses library functions found "错误,尝试安装:
[plain] view plaincopy
  1. yum install -y ncurses-devel  
下载并安装Tsung
[plain] view plaincopy
  1. # wget http://tsung.erlang-projects.org/dist/tsung-1.4.2.tar.gz  
  2. # tar -zxvf tsung-1.4.2.tar.gz  
  3. # cd tsung-1.4.2  
  4. # ./configure --prefix=/usr/local/tsung --with-erlang=/usr/local/erlang  
  5. # make  
  6. # make install  
下载并安装 perl Template,用于生成报告模版
[plain] view plaincopy
  1. # wget http://cpan.org/modules/by-module/Template/Template-Toolkit-2.24.tar.gz  
  2. # tar -zxvf Template-Toolkit-2.24.tar.gz  
  3. # cd Template-Toolkit-2.24  
  4. # perl Makefile.PL  
  5. # make  
  6. # make test  
  7. # make install  
下载并安装 gnuplot,用于聊天生成
[plain] view plaincopy
  1. # yum install -y gnuplot gd libpng zlib  

注意:安装成后添加erlang、tsung环境变量

 

[plain] view plaincopy
  1. # vim /etc/profile   
  2. export PATH=$PATH:$JAVA_HOME/bin:/usr/local/erlang/bin:/usr/local/tsung/bin:/usr/local/nginx/sbin:$PATH(修改自己实际变量)  
  3. :x保存,退出  
  4. # source /etc/profile   
  5. 不报错则成功  
  6. # tsung -v   
  7. # erl -v  
  8. 测试  

 

二、使用

在root文件夹下新建.tsung目录,用于存放log和xml配置, 测试配置文件可参考 /usr/local/tsung/share/doc/tsung/examples/目录下配置
[plain] view plaincopy
  1. <pre name="code" class="plain" style="color: rgb(51, 51, 51); font-size: 13px; line-height: 19.046875px;">#<span style="font-family: SimSun;"> mkdir ~/.tsung</span>  
[plain] view plaincopy
  1. <span style="font-family: SimSun;"># cp /usr/local/tsung/share/doc/tsung/examples/http_simple.xml ~/.tsung/tsung.xml</span>  
 
 
运行,默认执行脚本~/.tsung/ tsung.xml配置
[plain] view plaincopy
  1. # tsung start  
  2. Starting Tsung  
  3. "Log directory is: /root/.tsung/log/20140817-1801"  

更多命令:

[plain] view plaincopy
  1. Usage: tsung <options> start|stop|debug|status  
  2. Options:  
  3.     -f <file>     set configuration file (default is ~/.tsung/tsung.xml)  
  4.                    (use - for standard input)  
  5.     -l <logdir>   set log directory (default is ~/.tsung/log/YYYYMMDD-HHMM/)  
  6.     -i <id>       set controller id (default is empty)  
  7.     -r <command>  set remote connector (default is ssh)  
  8.     -s            enable erlang smp on client nodes  
  9.     -p <max>      set maximum erlang processes per vm (default is 250000)  
  10.     -m <file>     write monitoring output on this file (default is tsung.log)  
  11.                    (use - for standard output)  
  12.     -F            use long names (FQDN) for erlang nodes  
  13.     -w            warmup delay (default is 10 sec)  
  14.     -v            print version information and exit  
  15.     -6            use IPv6 for Tsung internal communications  
  16.     -h            display this help and exit  

 

进入Log目录下可以看到生成的报表信息

 

[plain] view plaincopy
  1. # cd  /root/.tsung/log/20140817-1801  
[plain] view plaincopy
  1. # ls -a  
  2. match.log  tsung_1b.xml  tsung_controller@iZ234cp44ihZ.log  tsung.log  
生成图形报表,需要 依赖项 gnuplot、perl5及template模板

 

 

[plain] view plaincopy
  1. # yum -y install perl5 gnuplot libtemplate-perl    

 

进入需要生成图形报表的Log目录,如/root/.tsung/log/20140817-1801

 

[plain] view plaincopy
  1. # /usr/local/tsung/lib/tsung/bin/tsung_stats.pl  
  2. creating subdirectory data   
  3. creating subdirectory gnuplot_scripts   
  4. creating subdirectory images   
  5. warn, last interval (0) not equal to the first, use the first one (10)  
  6. No data for Event  
  7. No data for Errors  
[plain] view plaincopy
  1. # ls   
  2. data    nuplot_scripts  images     report.html   tsung_controller@iZ234cp44ihZ.log  
  3. gnuplot.log  graph.html       match.log  tsung_1b.xml  tsung.log  

 

浏览器打开report.html就可以看到生成的报表了.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值