• CentOS压力测试工具Tsung安装和图形报表生成Tsung安装配置


    Tsung 是一个压力测试工具,可以测试包括HTTP, WebDAV, PostgreSQL, MySQL, LDAP, and XMPP/Jabber等服务器。针对 HTTP 测试,Tsung 支持
    HTTP 1.0/1.1 ,包含一个代理模式的会话记录、支持 GET、POST 和 PUT 以及 DELETE 方法,支持 Cookie 和基本的WWW 认证,同时还支持 SSL。

    tsung的工作原理
    (1) Tsung的每一个虚拟用户就是一个erlang的轻量进程。这点和loadrunner有很大的区别。
    (2) 虚拟用户完成session后就消失。
    (3) 大量的虚拟用户(erlang轻量进程)建立在erlangVM上。
    (4) 一台测试机可以启多个erlangVM,目前按照1个cpu启动1个erlangVM。

    一、安装环境:

    clipboard[3]

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

    1. yum install gcc -y  
    2. yum install perl -y  
    3. yum install unixODBC  
    4. yum install unixODBC-devel 

    下载并安装erlang

    1 # wget http://www.erlang.org/download/otp_src_R14B04.tar.gz  
    2 # tar -zxvf otp_src_R14B04.tar.gz  
    3 # cd otp_src_R14B04  
    4 # ./configure --prefix=/usr/local/erlang  
    1 #检查erlang目录是否存在,不存在则mkdir.
    2 # make  
    3 # make install 

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

    yum install -y ncurses-devel 

    下载并安装Tsung

    # wget http://tsung.erlang-projects.org/dist/tsung-1.6.0.tar.gz  
    # tar -zxvf tsung-1.6.0.tar.gz  
    # cd tsung-1.6.0  
    # ./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.26.tar.gz  
    # tar -zxvf Template-Toolkit-2.26.tar.gz  
    # cd Template-Toolkit-2.26  
    # perl Makefile.PL   
    #perl出错不可用时先执行:
    $ yum install perl-ExtUtils-MakeMaker  安装Perl.
    
    # make  
    # make test  
    # make install

    注意:如果出现 以下提示:

    [root@localhost Template-Toolkit-2.24]# perl Makefile.PL
    Can't locate ExtUtils/MakeMaker.pm in @INC (@INC contains: ./lib /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at Makefile.PL line 11.
    BEGIN failed--compilation aborted at Makefile.PL line 11.
    
    

    解决办法:

    yum install perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker

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

    # yum install -y gnuplot gd libpng zlib

    二、安装后设置环境变量

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

    [root@localhost local]# vim /etc/profile   
    export PATH=$PATH:$JAVA_HOME/bin:/usr/local/erlang/bin:/usr/local/tsung/bin:/usr/local/nginx/sbin:$PATH(修改自己实际变量)  
    :wq保存,退出  
    [root@localhost local]# source /etc/profile   
    不报错则成功  
    [root@localhost local]# tsung -v   
    Tsung version 1.4.2
    [root@localhost local]# erl -v  
    Erlang R14B04 (erts-5.8.5) [source] [64-bit] [rq:1] [async-threads:0] [hipe] [kernel-poll:false]
    Eshell V5.8.5 (abort with ^G)
    1>

    三、检查是否安装成功

    [root@localhost local]# perl -v      命令查看显示perl 当前版本信息。
    [root@localhostlocal]# gnuplot       命令查看gnuplot 的安装版本
    [root@localhost local]# erl          命令查看erlang的安装版本
    Erlang R14B04 (erts-5.8.5) [source] [64-bit] [rq:1] [async-threads:0] [hipe] [kernel-poll:false]
    Eshell V5.8.5 (abort with ^G)
    [root@localhost local]# tsung -v 命令查看tsung 的安装版本 
    Tsung version 1.4.2 

    四、使用并生成报表

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

    [root@localhost local]#mkdir ~/.tsung
    [root@localhost local]#cp /usr/local/tsung/share/doc/tsung/examples/http_simple.xml ~/.tsung/tsung.xml

    2、运行,默认执行脚本~/.tsung/tsung.xml配置

    [root@localhost local]# tsung start
    Starting Tsung
    "Log directory is: /root/.tsung/log/20150311-0536"

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

    [root@localhost 20150311-0536]# cd /root/.tsung/log/20150311-0536
    [root@localhost 20150311-0536]# ls -a
    .  ..  match.log  tsung_controller@localhost.log  tsung.log  tsung.xml

    4、进入需要生成图形报表的Log目录,如/root/.tsung/log/20150311-0536

    [root@localhost 20150311-0536]# /usr/local/tsung/lib/tsung/bin/tsung_stats.pl 
    creating subdirectory data 
    creating subdirectory gnuplot_scripts 
    creating subdirectory images 
    No data for Session
    No data for Perfs
    No data for Transactions
    No data for Match
    No data for Event
    No data for Async
    No data for Size
    size_rcv is equal to 0 !
    size_sent is equal to 0 !
    [root@localhost 20150311-0536]# ls
    data  gnuplot.log  gnuplot_scripts  graph.html  images  match.log  report.html  tsung_controller@localhost.log  tsung.log  tsung.xml

    5、将report.html拖到windows系统中,直接打开即可查看。

    五、更多命令:

    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 
  • 相关阅读:
    ssh无密码登录设置方法以及出现问题 ECDSA host key 和IP地址对应的key不同的解决
    asp.net core 3 Swagger 添加 Authorization [Bearer token]
    asp.net core3 发布到IIS
    asp.net core 3.1 使用log4net
    asp.net core 3 跨域
    解决'vue' 不是内部或外部命令,也不是可运行的程序 或批处理文件的方法
    ReSharper 安装没有提示功能
    Python3 安装MySQL驱动
    win10 安装 Python 和 pip 详解
    Win10下 80端口被system(pid=4)占用的解决方法
  • 原文地址:https://www.cnblogs.com/linkxu1989/p/6632890.html
Copyright © 2020-2023  润新知