jmeter命令行模式运行,实时获取压测结果
jmeter很小,很快,使用方便,可以在界面运行,可以命令行运行。简单介绍下命令行运行的方式:
sh jmeter.sh -n -t my-script.jmx -R 10.6.5.31,10.6.5.35,10.6.5.36,10.6.5.37,10.6.5.72 -l 8.jtl
上面一条命令应该可以满足大部分需求。
-n:使用命令行模式运行 -t:指定要运行的jmx脚本 -R:指定使用那些slave节点压测 -l:压测记录保存在哪里
使用-R
指定节点时,当然要首先在这些节点上启动jmeter-server的服务,-l
指定日志,jmeter运行过程中的所有请求记录,都会保存在这个jtl文件中。
调试压测请求
命令行下,如果想查看每个请求返回的结果,需要修改jmeter.properties配置文件,
#jmeter.save.saveservice.assertion_results=none #jmeter.save.saveservice.data_type=true #jmeter.save.saveservice.label=true #jmeter.save.saveservice.response_code=true # response_data is not currently supported for CSV output #jmeter.save.saveservice.response_data=false # Save ResponseData for failed samples #jmeter.save.saveservice.response_data.on_error=false #jmeter.save.saveservice.response_message=true #jmeter.save.saveservice.successful=true #jmeter.save.saveservice.thread_name=true #jmeter.save.saveservice.time=true #jmeter.save.saveservice.subresults=true #jmeter.save.saveservice.assertions=true #jmeter.save.saveservice.latency=true #jmeter.save.saveservice.samplerData=false #jmeter.save.saveservice.responseHeaders=false #jmeter.save.saveservice.requestHeaders=false #jmeter.save.saveservice.encoding=false #jmeter.save.saveservice.bytes=true #jmeter.save.saveservice.url=false #jmeter.save.saveservice.filename=false #jmeter.save.saveservice.hostname=false #jmeter.save.saveservice.thread_counts=false
将上面的注释打开,并且值修改成true,就会打开该条记录,jmeter就会将该条信息输出到我们指定的jtl文件中,不要要注意压测过程中,会产生大量的这样的记录,真正压测时,最好不要开太多的日志记录。
实时查看压测结果
jmeter命令行下,也可以实时查看压测结果,同样是修改配置文件jmeter.properties。
# Summariser - Generate Summary Results - configuration (mainly applies to non-GUI mode) #--------------------------------------------------------------------------- # # Define the following property to automatically start a summariser with that name # (applies to non-GUI mode only) #summariser.name=summary # # interval between summaries (in seconds) default 30 seconds #summariser.interval=30 //这个表示统计频率 # # Write messages to log file #summariser.log=true # # Write messages to System.out #summariser.out=true //是否将统计结果输出到控制台
打开上面的summariser.name、summariser.interval、summariser.out这三个配置项,保存,重新运行jmeter,应该就可以在shell里看到统计信息了。
Remote engines have been started Waiting for possible shutdown message on port 4445 summary + 3036 in 3s = 1001.6/s Avg: 25 Min: 14 Max: 58 Err: 3036 (100.00%) Active: 61 Started: 58 Finished: 0 summary + 25670 in 10.3s = 2494.7/s Avg: 61 Min: 11 Max: 190 Err: 25670 (100.00%) Active: 261 Started: 258 Finished: 0 summary = 28706 in 13.1s = 2192.0/s Avg: 57 Min: 11 Max: 190 Err: 28706 (100.00%) summary + 27300 in 10.3s = 2654.9/s Avg: 129 Min: 10 Max: 407 Err: 27300 (100.00%) Active: 461 Started: 458 Finished: 0 summary = 56006 in 23.1s = 2426.7/s Avg: 92 Min: 10 Max: 407 Err: 56006 (100.00%) summary + 27200 in 10.4s = 2606.1/s Avg: 202 Min: 10 Max: 528 Err: 27200 (100.00%) Active: 660 Started: 657 Finished: 0 summary = 83206 in 33.1s = 2512.8/s Avg: 128 Min: 10 Max: 528 Err: 83206 (100.00%) summary + 26300 in 11s = 2478.3/s Avg: 284 Min: 11 Max: 702 Err: 26300 (100.00%) Active: 861 Started: 858 Finished: 0 summary = 109506 in 43.1s = 2541.1/s Avg: 166 Min: 10 Max: 702 Err: 109506 (100.00%) summary + 26200 in 11s = 2439.0/s Avg: 355 Min: 10 Max: 866 Err: 26200 (100.00%) Active: 1000 Started: 997 Finished: 0 summary = 135706 in 53.1s = 2556.0/s Avg: 202 Min: 10 Max: 866 Err: 135706 (100.00%)
这里的错误率是100%,正常情况下应该是0%。
http://www.yeetrack.com/?p=1051