使用LogParser和WCAT进行iis压力测试

原文:http://theether.net/kb/100128

许多文章都在讲如何根据iis log 进行模拟测试,不幸的是这些文章要么不正确、不完整或者有表述错误,就是没有对应当前的产品版本,或者没有处理windows 验证,下面的流程已经成功应用于产生重复的负载测试

一下案例使用了log parser2.2和WCAT 6.3

方案:

1) 安装Log Parser 2.2 

http://theether.net/download/Microsoft/IIS/LogParser.msi 

将下面的的模板文件和sql命令copy到 %ProgramFiles%\Log Parser 2.2 目录下: 

http://theether.net/download/Microsoft/IIS/wcat.sql 
SELECT
        OUT_ROW_NUMBER() as ID,
        STRCAT(cs-uri-stem, REPLACE_IF_NOT_NULL(cs-uri-query,STRCAT('?', realQueryString))) AS URI,
        count(*) AS WEIGHT,
        case sc-status when 304 then 200 when 206 then 200 else sc-status end as STATUSCODE
using
        extract_token(cs-uri-query,0,'|') as realQueryString  
INTO %outfile%
FROM %logfile%
WHERE
        cs-method = 'GET'
        and STATUSCODE = 200
GROUP BY URI, STATUSCODE
ORDER BY WEIGHT DESC

http://theether.net/download/Microsoft/IIS/wcat.tpl 

<LPHEADER>
scenario
{
    name    = "Generated Using Log Parser";
 
    warmup      = 30;
    duration    = 120;
    cooldown    = 10;
    default
    {
        setheader
        {
            name    = "Host";
            value   = "intranet";
        }
        setheader
        {
            name    = "Connection";
            value   = "keep-alive";
        }
 
        setheader
        {
            name    = "User-Agent";
            value   = " Mozilla/4.0 (compatible; MSE 6.0; Windows NT 5.1; SV1)";
        }
        version     = HTTP11;
        close       = ka;
    }
</LPHEADER>
 <LPBody>
    transaction
    {
        id = "URL %ID%";
        weight = %WEIGHT%;
 
        request
        {
            url         = "%URI%";
            statuscode  = %STATUSCODE%;
        }
    }
</LPBODY>
<LPFOOTER>
}
</LPFOOTER>

http://theether.net/download/Microsoft/IIS/wcat.NTLM.tpl 

<LPHEADER>
scenario
{
    name    = "Generated Using Log Parser";
 
    warmup      = 30;
    duration    = 120;
    cooldown    = 10;
    default
    {
        setheader
        {
            name    = "Host";
            value   = "intranet";
        }
        setheader
        {
            name    = "Connection";
            value   = "keep-alive";
        }
 
        setheader
        {
            name    = "User-Agent";
            value   = " Mozilla/4.0 (compatible; MSE 6.0; Windows NT 5.1; SV1)";
        }
        version     = HTTP11;
        close       = ka;
    }
</LPHEADER>
 <LPBody>
    transaction
    {
        id = "URL %ID%";
        weight = %WEIGHT%;
 
        request
        {
            url         = "%URI%";
            statuscode  = 401;
        }

        request
        {
            url         = "%URI%";
            authentication = NTLM;
            username = "DOMAIN\\user";
            password = "password";
            statuscode  = %STATUSCODE%;
        }
    }
</LPBODY>
<LPFOOTER>
}
</LPFOOTER>


copy iis log文件到 %ProgramFiles%\Log Parser 2.2 目录下. 

2) 生成 WCAT 脚本
2a) IIS中使用了匿名验证 Using Anonymous Authentication on IIS 

在命令行中执行如下命令: 

CD "\Program Files\Log Parser 2.2"
Logparser file:WCat.sql?logfile=*.log+outfile=CurrentLog.ubr -i:IISW3C -o:tpl -tpl:WCat.tpl

(missing -i:IISW3C parameter courtesy Scott Stafford) 

2b) IIS中使用windows 验证的

编辑wcat.NTLM.tpl并更新domain,user和password
Edit wcat.NTLM.tpl and update DOMAIN, user and password. 

命令行中执行:

CD "\Program Files\Log Parser 2.2"
Logparser file:WCat.sql?logfile=*.log+outfile=CurrentLog.ubr -i:IISW3C -o:tpl -tpl:WCat.NTLM.tpl


3) 在测试机上安装 WCAT 
 

在控制机上安装WCAT

http://theether.net/download/Microsoft/IIS/wcat.x86.msi 
http://theether.net/download/Microsoft/IIS/wcat.amd64.msi 

拷贝 "%ProgramFiles%\Log Parser 2.2\CurrentLog.ubr" 脚本文件到 %ProgramFiles%\wcat 目录下. 

在客户机上安装WCAT: 

命令上执行 

CD "\Program Files\wcat"
cscript wcat.wsf -update -clients localhost Test1

注意:这个命令会把wcclient安装在控制机和Test1这台客户机上,并会立即重启所有的客户端
Note: This will install the WCAT client (wcclient.exe) on the controller and the Test1 host.  This will reboot all clients immediately

4) 启动WCAT控制器 

  命令行中执行:

CD "\Program Files\wcat"
start wcctl.exe -t currentlog.ubr -s webserver.domain.com -c 2 -v 500

注释:-c 参数定义了控制器要等待几个客户机连接
Note: The -c parameter specifies the number of clients to wait for. 

5) 启动客户端 

 在控制机上启动客户端: 

CD "\Program Files\wcat"
start wcclient.exe localhost


在客户机上启动客户端: 

CD "%windir%\wcat"
start wcclient.exe controller.domain.com


6) 查看测试结果 

控制机上执行如下cmd命令: 

iexplore %ProgramFiles%\wcat\log.xml


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值