参考文档:http://jmeter.apache.org/usermanual/get-started.html#non_gui

真正开始跑压力测试时,我们就不能使用GUI模式了。这时候需要采用命令行模式。

执行测试命令

参数说明:

-n, --nongui
run JMeter in nongui mode //以命令行模式执行JMeter
-t, --testfile <argument>
the jmeter test(.jmx) file to run. "-t LAST" will load last used file //指定要执行的JMX脚本
-l, --logfile <argument>
the file to log samples to //指定取样结果的保存文件
-j, --jmeterlogfile <argument>
jmeter run log file (jmeter.log) //指定jmeter.log的路径

示例:

1. 命令行方式跑 my_test.jmx

jmeter -n -t my_test.jmx

2. 保存取样结果

这里取样结果可以保存为csv格式,也可以保存为jtl格式。

jmeter -n -t my_test.jmx -l a.csv

保存好的a.csv或者a.jtl文件可以在后期使用JMeter直接打开。

新建一个Test Plan,任意建立一个监听器,比如查看结果树。点击浏览,打开我们保存的文件,这里就是a.csv,就可以看到详细取样结果信息。

3. 保存JMeter的log文件

JMeter的log信息默认情况下都保存到 jmeter.log文件里面。但是这个文件每次跑测试之前都会清空,所以如果我们想要保存每次测试的log信息,我们就需要用到 –j 这条命令。

jmeter -n -t my_test.jmx -j a.log

以JMeter的GUI模式执行时,可以通过点击下面的黄色感叹号来打开 Log View 面板,也可以通过 选项 –> Log Viewer来打开。Log Viewer面板显示的log和上面命令行执行产生的a.log的内容是一致的。

log内容类似如下:

-- ::, INFO o.a.j.JMeter: Version 3.2.
-- ::, INFO o.a.j.g.a.Load: Loading file: c:\mytestfiles\BSH.jmx
-- ::, INFO o.a.j.e.StandardJMeterEngine: Running the test!
-- ::, INFO o.a.j.e.StandardJMeterEngine: Starting threads for group BSH. Ramp up = .
-- ::, INFO o.a.j.e.StandardJMeterEngine: Continue on error
-- ::, INFO o.a.j.t.JMeterThread: Thread BSH1- started
-- ::, INFO o.a.j.t.JMeterThread: Thread BSH1- is done
-- ::, INFO o.a.j.e.StandardJMeterEngine: Test has ended

远程执行

参数说明:

-r, --runremote
Start remote servers (as defined in remote_hosts) //在 remote_hosts定义的机器上跑测试
-R, --remotestart <argument>
Start these remote servers (overrides remote_hosts) //在后边定义的机器上跑测试
-X, --remoteexit
Exit the remote servers at end of test (non-GUI) //测试结束退出远程机器

示例:

1. 在远程机器上跑测试

jmeter -n -t testplan.jmx –r

前提是设置好远程连接:JMeter 七:远程测试

设置好远程服务器之后,这里就会启动 jmeter.properties文件里面 remote_hosts配置的远程机器。

2. 在特定的远程机器上跑测试

jmeter -n -t script.jmx -R server1,server2,…

这里先定义远程机器,然后在远程机器上启动测试。

代理

如果需要在防火墙或者代理服务器后测试,我们需要向JMeter提供 防火墙或者代理服务器的机器名以及端口号。

-H, --proxyHost <argument>
Set a proxy server for JMeter to use //设置JMeter使用的代理服务器
-P, --proxyPort <argument>
Set proxy server port for JMeter to use //设置JMeter使用的代理服务器端口号
-N, --nonProxyHosts <argument>
Set nonproxy host list (e.g. *.apache.org|localhost) //设置非代理服务器列表
-u, --username <argument>
Set username for proxy server that JMeter is to use //设置JMeter使用的代理服务器用户名
-a, --password <argument>
Set password for proxy server that JMeter is to use //设置JMeter使用的代理服务器密码

示例:

jmeter -H xxx.xxx.xxx -P  -u username -a password -N localhost

帮助命令

参数说明:

--?
print command line options and exit //打印命令行选项
-h, --help
print usage information and exit //打印帮助信息
-v, --version
print the version information and exit //打印版本信息

其他命令

还有一些不常用的其他命令,主要都是对一些属性的设置。拷贝下来留作备用。

-p, --propfile <argument>
the jmeter property file to use
-q, --addprop <argument>
additional JMeter property file(s)
-i, --jmeterlogconf <argument>
jmeter logging configuration file (log4j2.xml)
-s, --server
run the JMeter server
-J, --jmeterproperty <argument>=<value>
Define additional JMeter properties
-G, --globalproperty <argument>=<value>
Define Global properties (sent to servers)
e.g. -Gport=
or -Gglobal.properties
-D, --systemproperty <argument>=<value>
Define additional system properties
-S, --systemPropertyFile <argument>
additional system property file(s)
-f, --forceDeleteResultFile
force delete existing results files before start the test
-L, --loglevel <argument>=<value>
[category=]level e.g. jorphan=INFO, jmeter.util=DEBUG or com
.example.foo=WARN
-d, --homedir <argument>
the jmeter home directory to use

JMeter 十二:命令行执行的更多相关文章

  1. Jmeter 5.1命令行执行bat文件

    一.编写run_jmeter,bat @echo off::设置参数::参考命令:jmeter -n -t d:\123.jmx -l result.jtl -e -o d:\report\repor ...

  2. jmeter summariser(命令行执行时的输出) 、查看结果树等结果中文乱码

    在使用jmeter测试时,如果你的sampler名字为中文.或者输出的结果信息有中文,你会发现它们都是乱码,非常蛋碎!原因是:  jmeter的默认编码为:ISO-8859-1, 解决方案就是要修改它 ...

  3. Jmeter 非 GUI 命令行执行脚本文件

    https://www.cnblogs.com/yebaofang/p/9803273.html

  4. 使用命令行执行jmeter的方法

    1. 简介 使用非 GUI 模式,即命令行模式运行 JMeter 测试脚本能够大大缩减所需要的系统资 本文介绍windows下以命令行模式运行的方法. 1.1. 命令介绍 jmeter -n -t & ...

  5. Jmeter命令行执行并生成HTML报告

    前提:准备好jmeter脚本,找到jmeter配置文件查看生成的日志格式是否为csv,如果不是请改为csv 注意:使用命令执行jmeter脚本必须使用jmeter 3.0及以上版本1.使用命令行执行脚 ...

  6. Jmeter(6)命令行执行

    Jmeter执行方式有2种:GUI和非GUI模式 GUI:在Windows电脑上运行,图形化界面,可直接查看测试结果,但是消耗压力机资源较高 非GUI:通过命令行执行,无图形化界面,不方便查看测试结果 ...

  7. php 运行linux命令 与 linux下命令行执行php

    1.php运行linux命令 exec函数:string exec(string command, string [array], int [return_var]);  执行函数后不输出结果,返回最 ...

  8. 【转】Caffe初试(十)命令行解析

    caffe的运行提供三种接口:C++接口(命令行).Python接口和matlab接口.本文先对命令行进行解析,后续会依次介绍其它两种接口. caffe的C++主程序(caffe.cpp)放在根目录下 ...

  9. linux命令行执行db2存储过程

    存储过程代码如下: CREATE PROCEDURE proc_sum2(IN n INT,OUT sum INT,OUT j INT) BEGIN DECLARE i INT; ; ; ; WHIL ...

随机推荐

  1. caffe-安装anaconda后重新编译caffe报错

    ks@ks-go:~/caffe-master$ make -j16 CXX/LD -o .build_release/tools/convert_imageset.bin CXX/LD -o .bu ...

  2. 最正确的React事件绑定方式

    参考这篇文章:Choosing the Best Approach for React Event Handlers 1.function.bind()方式 2.inline arrow functi ...

  3. CNN-感受野

    CNN中感受野的计算:http://blog.csdn.net/kuaitoukid/article/details/46829355(好像有错误)http://blog.csdn.net/green ...

  4. Linux命令之firewall-cmd

    firewall-cmd [选项] firewall-cmd是firewalld守护程序的命令行客户端.它提供了管理运行时和永久配置的接口.firewalld中的运行时配置与永久配置分开.这意味着可以 ...

  5. python 写文件write(string), writelines(list) ,读文件

    read()方法用于直接读取字节到字符串中,可以接参数给定最多读取的字节数,如果没有给定,则文件读取到末尾. readline()方法读取打开文件的一行(读取下个行结束符之前的所有字节),然后整行,包 ...

  6. noip2012开车旅行 题解

    题目大意: 给出n个排成一行的城市,每个城市有一个不同的海拔.定义两个城市间的距离等于他们的高度差的绝对值,且绝对值相等的时候海拔低的距离近.有两个人轮流开车,从左往右走.A每次都选最近的,B每次都选 ...

  7. [BZOJ 3553][SHOI2014]三叉神经树

    传送门(下面也有题面) 题目大意: 一颗有根树,每个非叶子节点都有三个子节点,每个节点的权为0/1. 每个节点的权 取决于其所有子节点中 哪种权出现的次数更多. 有若干次询问,每次询问修改一个叶子节点 ...

  8. vue组件续和前端工程化

    1.3 插槽 slot template: ` <button> <slot></slot> </button> ` <my-button> ...

  9. JDK源码学习笔记——Integer

    一.类定义 public final class Integer extends Number implements Comparable<Integer> 二.属性 private fi ...

  10. [转]Spring MVC 4常用的那些注解

    Spring从2.5版本开始在编程中引入注解,用户可以使用@RequestMapping, @RequestParam, @ModelAttribute等等这样类似的注解.到目前为止,Spring的版 ...