Tsung使用笔记

安装

  1. 安装tsung及其依赖

    1
    agt-get install tsung
  2. 基于已安装的tsung安装Tsung1.6

    1
    2
    3
    4
    5
    6
    7
    8
    9
    apt-get remove tsung
    wget http://tsung.erlang-projects.org/dist/tsung-1.6.0.tar.gz
    tar xvf tsung-1.6.0.tar.gz -C /usr/local
    cd /usr/local/tsung-1.6.0
    ./configure
    make
    make install

启动Tsung

简单执行Tsuing:tsung -f [配置文件地址] start
Tsung执行结束后,依然运行dashboard:tsung -f [配置文件地址] -k start
dashboard地址:http://[机器ip]:8091

内容示例

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
48
49
50
51
52
53
54
55
<?xml version="1.0"?>
<!DOCTYPE tsung SYSTEM "/usr/share/tsung/tsung-1.0.dtd">
<tsung loglevel="notice" version="1.0">
<!-- Client side setup -->
<clients>
<client host="localhost" use_controller_vm="true" maxusers="600000"/>
</clients>
<!-- Server side setup -->
<servers>
<server host="xxx.xxx.xxx.xxx" port="80" type="tcp"></server>
</servers>
<!-- to start os monitoring (cpu, network, memory). Use an erlang
agent on the remote machine or SNMP. erlang is the default -->
<monitoring>
<monitor host="myserver" type="snmp"></monitor>
</monitoring>
<load>
<!-- several arrival phases can be set: for each phase, you can set
the mean inter-arrival time between new clients and the phase
duration -->
<!-- 每秒生成1000个用户,最多生成600000个用户,持续10分钟 -->
<arrivalphase phase="1" duration="10" unit="minute">
<users maxnumber="600000" arrivalrate="1000" unit="second"></users>
</arrivalphase>
</load>
<options>
<option type="ts_http" name="user_agent">
<user_agent probability="80">Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050513 Galeon/1.3.21</user_agent>
<user_agent probability="20">Mozilla/5.0 (Windows; U; Windows NT 5.2; fr-FR; rv:1.7.8) Gecko/20050511 Firefox/1.0.4</user_agent>
</option>
</options>
<!-- start a session for a http user. the probability is the
frequency of this type os session. The sum of all session's
probabilities must be 100 -->
<sessions>
<session name="http-example" probability="100" type="ts_http">
<!-- full url with server name, this overrides the "server" config value -->
<request> <http url="/" method="GET" version="1.1"></http> </request>
<request>
<http url="/callback/baidu" method="POST" version="1.1" content_type="application/json" contents='{"key":"value"}'></http>
</request>
<request> <http url="/moment/12" method="DELETE" version="1.1"></http> </request>
</session>
</sessions>
</tsung>