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

来源:互联网 发布:mac无法打开文件夹 编辑:程序博客网 时间:2024/04/29 10:43

原文: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 STATUSCODEusing        extract_token(cs-uri-query,0,'|') as realQueryString  INTO %outfile%FROM %logfile%WHERE        cs-method = 'GET'        and STATUSCODE = 200GROUP BY URI, STATUSCODEORDER 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


原创粉丝点击