我运行TSung的机器装的是Ubuntu 10.04 Server amd64。以下是从安装Tsung到使用Tsung对Openfire进行压力测试的步骤。
1. 下载并安装Tsung.
//安装Erlang及相关组件(必装) apt-get install erlang erlang-nox erlang-dev erlang-parsetools //安装生成报表必须的软件 apt-get install perl5 gnuplot libtemplate-perl //下载Tsung的deb包 wget http://tsung.erlang-projects.org/dist/ubuntu/lucid/tsung_1.4.1-1_all.deb //安装Tsung dpkg -i tsung_1.4.1-1_all.deb
2. 配置Tsung
~/.tsung/tsung.xml为tsung默认的配置文件,但我们安装后会发现这个目录和文件并不存在,那就由我们手动来创建这个目录。
mkdir ~/.tsung
在/usr/share/doc/tsung/examples/中有一些示例文件,可以参考jabber_register.xml文件来编写自己的tsung.xml。
cp /usr/share/doc/tsung/examples/jabber_register.xml ~/.tsung/tsung.xml
打开这个文件看一下,做一些修改。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
<?
xml
version
=
"1.0"
?>
<!DOCTYPE tsung SYSTEM "/usr/share/tsung/tsung-1.0.dtd">
<
tsung
loglevel
=
"notice"
dumptraffic
=
"false"
version
=
"1.0"
>
<
clients
>
<
client
host
=
"localhost"
use_controller_vm
=
"true"
>
</
client
>
</
clients
>
<
servers
>
<
server
host
=
'127.0.0.1'
port
=
'5222'
type
=
'tcp'
/>
</
servers
>
<!-- register 200000 users in less than 15 minutes -->
<
load
>
<
arrivalphase
phase
=
"1"
duration
=
"15"
unit
=
"minute"
>
<
users
maxnumber
=
"200000"
interarrival
=
"0.0025"
unit
=
"second"
></
users
>
</
arrivalphase
>
</
load
>
<
options
>
<
option
type
=
"ts_jabber"
name
=
"global_number"
value
=
"5"
></
option
>
<
option
type
=
"ts_jabber"
name
=
"userid_max"
value
=
"200000"
></
option
>
<
option
type
=
"ts_jabber"
name
=
"domain"
value
=
"erlang-projects.org"
></
option
>
<
option
type
=
"ts_jabber"
name
=
"username"
value
=
"tsung"
></
option
>
<
option
type
=
"ts_jabber"
name
=
"passwd"
value
=
"tsung"
></
option
>
</
options
>
<
sessions
>
<
session
probability
=
"100"
name
=
"jabber-example"
type
=
"ts_jabber"
>
<
request
>
<
jabber
type
=
"connect"
ack
=
"local"
></
jabber
>
</
request
>
<
request
>
<
match
do
=
"abort"
when
=
"match"
>error</
match
>
<
jabber
type
=
"register"
ack
=
"local"
id
=
"new"
></
jabber
>
</
request
>
<
request
>
<
jabber
type
=
"close"
ack
=
"local"
></
jabber
>
</
request
>
</
session
>
</
sessions
>
</
tsung
>
|
配置文件中确定好server的host和port,通过<users maxnumber…>来设置要注册的最大用户数即可。
3. 启动Tsung
tsung start/stop/debug/status
运行中,可从openfire的界面上看到不断增加的用户。
4. 生成报表
//进入日志目录 cd ~/.tsung/log/20120728-0511 //运行脚本生成报表文件 /usr/lib/tsung/bin/tsung_stats.pl
5. 查看生成的报表
//安装apache2 apt-get install apache2 //建立符号链接 cd /var/www ln -s ~/.tsung/log/ tsungreport
这是就可以访问:http://localhost/tsungreport/20120728-0511/report.html来访问报表了。
原文地址:http://zhangxiaodong.me/?p=160