您的位置:首页 > 运维架构 > Linux

CentOS压力测试工具Tsung安装、使用和图形报表生成

2015-01-16 21:25 633 查看
最近需要测试一下Openfire服务器的性能,然后就选择了用Tsung这个鼎鼎大名的工具来进行测试,只不过Tsung的安装需要CentOS系统,并且,安装过程也不是那么容易的,所以这里参考了一下别人的博客,现在记录如下。

转载地址:http://blog.csdn.net/flyforqie/article/details/38640069,如转载请注明原文出处。


一、安装

安装环境:

[plain] view
plaincopy

LSB Version:    :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch  

Distributor ID: CentOS  

Description:    CentOS release 6.5 (Final)  

Release:        6.5  

Codename:       Final  

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

[plain] view
plaincopy

yum install gcc -y  

yum install perl -y  

yum install unixODBC  

yum install unixODBC-devel  

下载并安装erlang

[plain] view
plaincopy

# wget http://www.erlang.org/download/otp_src_R14B04.tar.gz  

# tar -zxvf otp_src_R14B04.tar.gz  

# cd otp_src_R14B04  

# ./configure --prefix=/usr/local/erlang  

# make  

# make install  

注意:如果出现 "configure: error: No curses library functions found "错误,尝试安装:

[plain] view
plaincopy

yum install -y ncurses-devel  

下载并安装Tsung

[plain] view
plaincopy

# wget http://tsung.erlang-projects.org/dist/tsung-1.4.2.tar.gz  

# tar -zxvf tsung-1.4.2.tar.gz  

# cd tsung-1.4.2  

# ./configure --prefix=/usr/local/tsung --with-erlang=/usr/local/erlang  

# make  

# make install  

下载并安装perl Template,用于生成报告模版

[plain] view
plaincopy

# wget http://cpan.org/modules/by-module/Template/Template-Toolkit-2.24.tar.gz  

# tar -zxvf Template-Toolkit-2.24.tar.gz  

# cd Template-Toolkit-2.24  

# perl Makefile.PL  

# make  

# make test  

# make install  

下载并安装gnuplot,用于聊天生成

[plain] view
plaincopy

# yum install -y gnuplot gd libpng zlib  

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

[plain] view
plaincopy

# vim /etc/profile   

export PATH=$PATH:$JAVA_HOME/bin:/usr/local/erlang/bin:/usr/local/tsung/bin:/usr/local/nginx/sbin:$PATH(修改自己实际变量)  

:x保存,退出  

# source /etc/profile   

不报错则成功  

# tsung -v   

# erl -v  

测试  

二、使用

在root文件夹下新建.tsung目录,用于存放log和xml配置,测试配置文件可参考/usr/local/tsung/share/doc/tsung/examples/目录下配置

[plain] view
plaincopy

<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

<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

# tsung start  

Starting Tsung  

"Log directory is: /root/.tsung/log/20140817-1801"  

更多命令:

[plain] view
plaincopy

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  

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

[plain] view
plaincopy

# cd  /root/.tsung/log/20140817-1801  

[plain] view
plaincopy

# ls -a  

match.log  tsung_1b.xml  tsung_controller@iZ234cp44ihZ.log  tsung.log  

生成图形报表,需要依赖项 gnuplot、perl5及template模板

[plain] view
plaincopy

# yum -y install perl5 gnuplot libtemplate-perl    

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

[plain] view
plaincopy

# /usr/local/tsung/lib/tsung/bin/tsung_stats.pl  

creating subdirectory data   

creating subdirectory gnuplot_scripts   

creating subdirectory images   

warn, last interval (0) not equal to the first, use the first one (10)  

No data for Event  

No data for Errors  

[plain] view
plaincopy

# ls   

data    nuplot_scripts  images     report.html   tsung_controller@iZ234cp44ihZ.log  

gnuplot.log  graph.html       match.log  tsung_1b.xml  tsung.log  

架设一个Http服务器打开report.html就可以看到生成的报表了.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Tsung Openfire