`
275553385
  • 浏览: 705707 次
  • 性别: Icon_minigender_1
  • 来自: 无锡
文章分类
社区版块
存档分类
最新评论

Tsung配置文件详解

阅读更多
<?xml version="1.0"?>
<!DOCTYPE tsung SYSTEM "/usr/local/share/tsung/tsung-1.0.dtd"[
<!ENTITY ecstore SYSTEM "/root/.tsung/ecstore.xml">
]>
<!-- loglevel:工具写日志的标识,级别默认是"info",长时间运行建议调整为error -->
<!-- dumptraffic:运行的调试信息dump文件,如需要看脚本是否正确可以设置为"true",级别默认是"false",长时间运行建议调整为false -->
<tsung loglevel="notice" version="1.0">

  <!-- Client side setup -->
  <!-- 集群Client设置 -->
  <!-- host必须是主机名,不能是IP地址 -->
  <!-- weight: 节点上面用户的比例,一般设置为1即可 -->
  <!-- maxusers: 一般设置为800,3000即可,根据机器配置来设置大小 超过这个数目
       会自动开启更多的节点-->
  <!-- cpu: 根据机器硬件配置来设置,如果是4核CPU,最佳设置为3,以此类推 -->

  <clients>
    <client host="localhost" use_controller_vm="true"></client>
  </clients>

  <!-- Server side setup -->
  <!-- host: 填别名,需要先去host文件配置 -->
  <!-- port: 填可用对外端口,一般80 -->
  <!-- type: 协议类型,tsung支持tcp/udp,根据自己的需要 -->
  <!-- weight 设置权重,整数型 -->
<servers>
  <server host="192.168.1.3" port="80" type="tcp"></server>
</servers>

  <!-- 监控(cpu, network, memory). 使用erlang或SNMP,erlang是默认值 
  但是要保证监控的机器和server可以互相访问,装有erlang,否则用snmp -->
  <!-- 默认的snmp端口是161 默认的版本是v1 -->
  <monitoring>
    <monitor host="192.168.1.3" type="snmp">
      <snmp version="v2" community="public" port="161">
       <!-- 统计IO读,单位是blocks/s -->
       <oid name="io_sent" value=".1.3.6.1.4.1.2021.11.5.0" ></oid>
       <!-- 统计IO写,单位是blocks/s -->
       <oid name="io_receive" value=".1.3.6.1.4.1.2021.11.6.0" ></oid>
      </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 -->
  <!-- phase:阶段,填数字即可,系统会按顺序执行,可以设置多个阶段组合场景 -->
  <!-- duration:持续时段,填数字即可,单位是unit="minute"设置,是分钟 
  也可设置小时,天,详细情况参考API -->
  <!-- arrivalrate:虚拟用户数,填写数字即可,一般最大800,如过机器配置好,可自己调试最佳参数 
  有效单位unit="second" 是秒,每秒虚拟300个虚拟用户,实际执行情况可能超过,也可能达不到,需要根据调试得到最佳参数 -->
  <!-- interarrival: 时间间隔默认是2秒产生一个用户 这个选项可以和arrivalrate互相调换 -->
  <!-- maxnumber: 这个是设置最大用户数,所产生的总用户数不会超过这个 -->
   <arrivalphase phase="1" duration="10" unit="minute">
     <users arrivalrate="50" unit="second"></users>
   </arrivalphase>
   <!-- 如果你想设置分时间阶段的会话可以这样,这个这里的session必须是录制的脚本或者自己添加的session  -->
   <user session="session1" start_time="185" unit="second"></user>
   <user session="session2" start_time="10" unit="minute"></user>
   <user session="session3" start_time="11" unit="minute"></user>
  </load>

  <options>
   <option type="ts_http" name="user_agent">
    <!-- 设置浏览器类型 probability为所占总的浏览器类别的百分比 -->
    <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
       weight 权重 -->
  <session name="session1" weight="2" type="ts_http">

   <!-- 变量的设置需要在session中设置 -->

   <!-- 如果是引用外部的csv文件需要先设置fileid-->
   <options>
    <option name="file_server" id="user_list" value="users.csv"></option>
   </options>
   <!-- sourcetype:根据需求,参考API,我这里是csv文件 -->
   <!-- fileid:根据tsung.xml内的option文件操作的id一致 -->
   <!-- order:我这里选择的random随机,根据需求参考API -->
   <!-- delimiter: 设置分割符 也就是上边csv文件中存储的账号密码之间的连接符 -->
   <!-- name:这个变量的名称 -->
   <setdynvars sourcetype="file" fileid="user_list" order="random">
    <var name="userid" ></var>
   </setdynvars>
   <!-- sourcetype:根据需求,参考API,我这里是csv文件 -->
   <!-- fileid:根据tsung.xml内的option文件操作的id一致 -->
   <!-- order:我这里选择的random随机,根据需求参考API -->
   <!-- name:这个变量的名称 -->
   <setdynvars sourcetype="file" fileid="userdb" order="random">
    <var name="user" ></var>
   </setdynvars>
   <!-- sourcetype:根据需求,参考API,random_number随机数字 -->
   <!-- start:开始数字 -->
   <!-- end:结束数字 -->
   <!-- name:这个变量的名称 -->
   <setdynvars sourcetype="random_number" start="1" end="40">
    <var name="rndint" ></var>
   </setdynvars>
   <!-- 在request中需要指定subst="true"来使用替换 -->
   <request subst="true"></request>
   <!-- 在手动指定的session中的某个请求中加入等待时间,也可以在录制的脚本中加入,下面是随机等待时间 -->
   <thinktime value='%%_rndthink%%' random='true'></thinktime>
  </session>
  <session name="session2" weight="1" type="ts_http"></session>
  <!-- 只有一个录制的session的时候可以这样调用 -->
  &ecstore;
 </sessions>
</tsung>



<?xml version="1.0"?>
<!DOCTYPE tsung SYSTEM "/usr/local/share/tsung/tsung-1.0.dtd">
<tsung loglevel="notice" version="1.0">

  <!-- Client side setup -->
  <clients>
      <client host="localhost" use_controller_vm="true"  maxusers="9999"/>
        </clients>
          
  <!-- Server side setup -->
<servers>
  <server host="www.demo.com" 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 --> 
  
  <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 -->
 <arrivalphase phase="1" duration="120" unit="minute">
<users arrivalrate="15" unit="second"/>
           </arrivalphase>
<arrivalphase phase="2" duration="120" unit="minute">
<users arrivalrate="20" unit="second"/>
</arrivalphase>
<arrivalphase phase="3" duration="120" unit="minute">
<users arrivalrate="25" unit="second"/>
</arrivalphase>
<arrivalphase phase="4" duration="120" unit="minute">
<users arrivalrate="30" unit="second"/>
</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>
                   <option name="file_server" id="productname" value="/root/.tsung/productname.csv"/>
                        <option name="file_server" id="productid" value="/root/.tsung/productid.csv"/>
                          </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='index' probability='20'  type='ts_http'>
                    <request>
                                    <http url='/index.php' version='1.1' method='GET'>
                                                    <http_header name="Accept-Encoding" value="gzip,deflate"/>
                                                                    </http>
                                                                                </request>
                                                                                        </session>

		 <session name='search' probability='50'  type='ts_http'>
		             <setdynvars sourcetype="file" fileid="productname" delimiter=";"  order="iter">
		                             <var name="goods_name" />
		                                         </setdynvars>
		                                                     <request  subst="true">
		                                                                     <http url='/index.php/gallery.html?scontent=%%_goods_name%%' version='1.1' method='GET'>
		                                                                                     <http_header name="Accept-Encoding" value="gzip,deflate"/>
		                                                                                                     </http>
		                                                                                                                 </request>
		                                                                                                                         </session>

        <session name='product' probability='21'  type='ts_http'>
                    <setdynvars sourcetype="file" fileid="productid"  delimiter=";" order="iter">
                                    <var name="random_id" />
                                                </setdynvars>
                                                            <request subst="true">
                                                                            <http url='/?product-%%_random_id%%.html' version='1.1' method='GET'>
                                                                                            <http_header name="Accept-Encoding" value="gzip,deflate"/>
                                                                                                            </http>
                                                                                                                        </request>

        </session>

        <session name='radom' probability='3'  type='ts_http'>
                    <request>
                                    <http url='/article-help-l-1.html' version='1.1' method='GET'>
                                                    <http_header name="Accept-Encoding" value="gzip,deflate"/>
                                                                    </http>
                                                                                </request>
                                                                                        </session>

        <session name='radom1' probability='3'  type='ts_http'>
                <request>
                                <http url='/article-news-55.html' version='1.1' method='GET'>
                                                <http_header name="Accept-Encoding" value="gzip,deflate"/>
                                                                </http>
                                                                            </request>
                                                                                    </session>

        <session name='radom2' probability='3'  type='ts_http'>
                    <request>
                                    <http url='/article-news-l-11.html' version='1.1' method='GET'>
                                                    <http_header name="Accept-Encoding" value="gzip,deflate"/>
                                                                    </http>
                                                                                </request>
                                                                                        </session>



     </sessions>
     </tsung>

分享到:
评论
2 楼 JYY282 2013-11-21  
1 楼 275553385 2013-11-05  
http://tsung.erlang-projects.org/

Tsung压力测试工具的工作原理介绍
(1)  Tsung的每一个虚拟用户就是一个erlang的轻量进程。这点和loadrunner有大区别。
(2)  虚拟用户完成session后就消失。
(3)  大量的虚拟用户(erlang轻量进程)建立在erlangVM上。

Tsung安装包、erlang安装包、Perl ( 生成报告所需模块)、图形库gnuplot等
1.erlang
2.perl
3.gnuplot

yum install gd libpng zlib

erlang安装:
http://www.erlang.org/download/otp_src_R15B02.tar.gz
tar zxvf otp_src_R15B02.tar.gz
cd otp_src_R15B02
./configure
make
make install

gnuplot安装:
wget http://nchc.dl.sourceforge.net/project/gnuplot/gnuplot/4.4.0/gnuplot-4.4.0.tar.gz
tar -zxvf gnuplot-4.4.0.tar.gz
cd gnuplot-4.4.0
./configure
make
make install

template-toolki安装:
wget http://www.cpan.org/modules/by-module/Template/Template-Toolkit-2.24.tar.gz
tar zxf Template-Toolkit-2.24.tar.gz
cd Template-Toolkit-2.24
perl Makefile.PL
make
make install

配置Tsung:

~/.tsung/tsung.xml为tsung默认的配置文件,但我们安装后会发现这个目录和文件并不存在,那就由我们手动来创建这个目录。
mkdir /home/.tsung

在/usr/share/doc/tsung/examples/中有一些示例文件,可以参考jabber_register.xml文件来编写自己的tsung.xml。
cp /usr/share/doc/tsung/examples/jabber_register.xml ~/.tsung/tsung.xml

启动Tsung
tsung start/stop/debug/status
tsung -f /home/.tsung/tsung.xml start

进入日志目录
cd /root/.tsung/log/20120913-1436

运行脚本生成报表文件
/usr/local/lib/tsung/bin/tsung_stats.pl

相关推荐

    Openfire 3.9.3 Load Test Tsung配置xml

    Openfire 3.9.3 Load Test Tsung配置xml,10万用户下集群测试的Tsung压力测试工具的jabber_cluster.xml,session 5分钟

    tsung安装相关文件

    相关文件列表 ------ | —tsung-1.5.0.tar.gz —libtemplate-perl_2.20.orig.tar.gz —gnuplot-4.4.0.tar.gz —otp_src_R15B.tar.gz —perl-HTML-Tagset-3.10-2.1.1.noarch.rpm —perl-...

    Tsung安装使用详细解说

    Tsung安装使用的详细解说,主要针对xmpp的服务端(比如openfire的测试),编写测试场景的脚本配置详细说明。本人使用的是ubuntu操作系统、Tsung1.4.1

    tsung+erlang包

    tsung+erlang测试工具,初学者应用必备,内部放置tsung源程序文件和erlang文件

    tsung用户手册 linux

    压力测试 压力测试 tsung linux

    tsung脚本及说明

    tsung的测试脚本,包含发送单人消息,群组消息,获取花名册等

    tsung里面测试websocket的插件

    tsung里面测试websocket的插件含 websocket.xml 等

    MQTT压力测试之Tsung的使用

    MQTT压力测试之Tsung的使用 MQTT压力测试之Tsung的使用

    Tsung_测试XMPP_安装使用说明

    tsung是用erlang开发的一款简单易用的压力测试工具,目前仅支持linux各版本系统安装,有tar.gz和deb两种安装文件, 目前我们测试用的是CentOS或RedHat两种操作系统,因此选择tar.gz安装文件,总的来说tsung工具有...

    Tsung负载测试tigase

    tsung是一个非常好用的压力测试软件,基于erlang语言,支持多种...在Ubuntu上装好tsung之后,首先要用ulimit修改系统支持的最大fd数量(ulimit-n 20480),否则tsung最多只能创建不到1024个连接,测试脚本是一个xml文件

    tsung测试总结

    tsung 测试 java erlang

    tsung1.6.0

    tsung为一个开源的多协议分布式负载测试工具,使用erlang语言开发的。具体安装使用可以参考URL:http://www.51ste.com/share/det-222.html

    tsung安装使用

    关于tsung工具的安装步骤以及使用过程中会遇到的常见问题解答

    tsung高并发测试工具搭建(自己亲测,详细的一逼)

    tsung高并发测试工具搭建(自己亲测,详细的一逼),改文档是自己一步一步摸索出来的,主要是安装tsung整个过程很详细,搭过的人,知道tsung的搭建依赖很恶心,不是一时半会能搞出来的

    tsung最新用户手册

    tsung最新用户手册,包含HTTP, WebDAV, SOAP, PostgreSQL, MySQL, LDAP, and Jabber/XMPP servers压力测试模版,错误说明等。

    tsung安装使用说明

    tsung安装使用,参数说明,模拟openfire注册用户,模拟用户openfire登录、状态更改、发送消息,对openfire长时间压力测试

    tigase及tsung安装笔记

    包括tigase的安装运行,tsung的安装运行,压测结果的信息解析等;

    tsung-react-stats:从 json 报告中显示 tsung 统计信息

    tsung-react-stats 从 json 报告中显示 tsung 统计信息

    tsung-1.3.3

    tsung安装包,linux下进行压力测试的工具

    tsung_user_guide

    支持各种协议的压力测试工具,如HTTP/XMPP等

Global site tag (gtag.js) - Google Analytics