天天看點

CentOS壓力測試工具Tsung安裝、使用和圖形報表生成

一、安裝

安裝環境:

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
           

在安裝之前確定安裝了以下工具:

yum install gcc -y
yum install perl -y
yum install unixODBC
yum install unixODBC-devel
           

下載下傳并安裝erlang

# 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 "錯誤,嘗試安裝:

yum install -y ncurses-devel
           

下載下傳并安裝Tsung

# 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,用于生成報告模版

# 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,用于聊天生成

# yum install -y gnuplot gd libpng zlib
           

注意:安裝成後添加erlang、tsung環境變量

# 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/目錄下配置

<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>
           
<span style="font-family: SimSun;"># cp /usr/local/tsung/share/doc/tsung/examples/http_simple.xml ~/.tsung/tsung.xml</span>
           

運作,預設執行腳本~/.tsung/ tsung.xml配置

# tsung start
Starting Tsung
"Log directory is: /root/.tsung/log/20140817-1801"
           

更多指令:

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目錄下可以看到生成的報表資訊

# cd  /root/.tsung/log/20140817-1801
           
# ls -a
match.log  tsung_1b.xml  [email protected]  tsung.log
           

生成圖形報表,需要 依賴項 gnuplot、perl5及template模闆

# yum -y install perl5 gnuplot libtemplate-perl  
           

進入需要生成圖形報表的Log目錄,如/root/.tsung/log/20140817-1801

# /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
           
# ls 
data    nuplot_scripts  images     report.html   [email protected]
gnuplot.log  graph.html       match.log  tsung_1b.xml  tsung.log
           

架設一個Http伺服器打開report.html就可以看到生成的報表了.

繼續閱讀