41

I am new to jmeter. I have the .jmx file containg all the required http samplers. I could run it throught the Jmeter UI using "Run-> Start" and view the result in the "Summary Report". I can then save the results to the .csv using "Save Table Data" button in "Summary Report".

Question is how can I achieve the same using command line.

user1788294
  • 1,823
  • 4
  • 24
  • 30
  • You can't get direct excel output from JMeter but if you are using CSV like output format (instead of XML) you can import it in excel. Just don't forget to include headers in your CSV to avoid confusion later. – Dominik Antal Jul 04 '14 at 08:15

9 Answers9

62

JMeter can be launched in non-GUI mode as follows:

jmeter -n -t /path/to/your/test.jmx -l /path/to/results/file.jtl

You can set what would you like to see in result jtl file via playing with JMeter Properties.

See jmeter.properties file under /bin folder of your JMeter installation and look for those starting with

jmeter.save.saveservice.

Defaults are listed below:

#jmeter.save.saveservice.output_format=csv
#jmeter.save.saveservice.assertion_results_failure_message=false
#jmeter.save.saveservice.assertion_results=none
#jmeter.save.saveservice.data_type=true
#jmeter.save.saveservice.label=true
#jmeter.save.saveservice.response_code=true
#jmeter.save.saveservice.response_data=false
#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
#jmeter.save.saveservice.sample_count=false
#jmeter.save.saveservice.idle_time=false
#jmeter.save.saveservice.timestamp_format=ms
#jmeter.save.saveservice.timestamp_format=yyyy/MM/dd HH:mm:ss.SSS
#jmeter.save.saveservice.default_delimiter=,
#jmeter.save.saveservice.default_delimiter=\t
#jmeter.save.saveservice.print_field_names=false
#jmeter.save.saveservice.xml_pi=<?xml-stylesheet type="text/xsl" href="../extras/jmeter-results-detail-report_21.xsl"?>
#jmeter.save.saveservice.base_prefix=~/
#jmeter.save.saveservice.autoflush=false

Uncomment the one you are interested in and set it's value to change the default. Another option is override property in user.properties file or provide it as a command-line argument using -J key as follows:

jmeter -Jjmeter.save.saveservice.print_field_names=true -n /path/to/your/test.jmx -l /path/to/results/file.jtl

See Apache JMeter Properties Customization Guide for more details on what can be done using JMeter Properties.

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • 3
    I tried this way but the report generated differs from than that generated via GUI/"Save Table Data" one. How to generate the same report as seen in "Summary Report" – user1788294 Jul 04 '14 at 17:54
  • 2
    Some of fields are **calculated** so you can either open .jtl file with "Summary Report" listener after the test or implement calculations using Excel or equivalent in .jtl result file. – Dmitri T Jul 05 '14 at 08:40
  • Hi @Dmitri, Is it possible to see the resultfile.jtl content on console while test is running ? which option is suitable for this? – usersam Jun 27 '18 at 08:33
  • 1
    Since [JMeter 3.0](https://www.blazemeter.com/blog/5-key-things-you-need-know-about-jmeter-30/) it's possible to generate [HTML Reporting Dashboard](https://jmeter.apache.org/usermanual/generating-dashboard.html) after the test execution like `jmeter -n -t test.jmx -l result.jtl -e -o /path/to/dashboard` or from existing [jtl results file](https://cwiki.apache.org/confluence/display/JMETER/JtlFiles) like `jmeter -j /path/to/result.jtl -o /path/to/dashboard` – Dmitri T Mar 30 '20 at 14:24
5

You can use this command,

jmeter -n -t /path to the script.jmx -l /path to save results with file name file.jtl

But if you really want to run a load test in a remote machine, you should be able to make it run eventhough you close the window. So we can use nohup to ignore the HUP (hangup) signal. So you can use this command as below.

nohup sh jmeter.sh -n -t /path to the script.jmx -l /path to save results with file name file.jtl &
Ushani
  • 1,199
  • 12
  • 28
2

You can run JMeter from the command line using the -n parameter for 'Non-GUI' and the -t parameter for the test plan file.

    jmeter -n -t "PATHTOJMXFILE"        

If you want to further customize the command line experience, I would direct you to the 'Getting Started' section of their documentation.

Quinnlv
  • 302
  • 1
  • 5
1

This worked for me on mac os High sierra 10.13.6, java 8 64-bit, jmeter 4.0

$  jmeter -n --testfile /path/to/Test_Plan.jmx

Sample output:

Creating summariser <summary>
Created the tree successfully using ./src/test/jmeter/Test_Plan.jmx
Starting the test @ Fri Aug 24 17:18:18 PDT 2018 (1535156298333)
Waiting for possible Shutdown/StopTestNow/Heapdump message on port 4445
summary =     10 in 00:00:09 =    1.1/s Avg:  6666 Min:  1000 Max:  8950 Err:     
0 (0.00%)
Tidying up ...    @ Fri Aug 24 17:18:28 PDT 2018 (1535156308049)
... end of run
user674669
  • 10,681
  • 15
  • 72
  • 105
1

To get the results in excel like file, you have one option to get it done with csv file. Use below commands with provided options.

jmeter -n -t /path-to-jmeter-test/file.jmx -l TestResults.csv
-n states Non GUI mode
-t states Test JMX File
-l state Log the results in provided file

Also you can pass any results related parameters dynamically in command line arguments using -Jprop.name=value which are already defined in jmeter.properties in bin folder.

  • Unfortunately, this does not output the tests "summary report" listener output, it just dumps raw list of every request. – John Little Jul 21 '20 at 12:16
0

This would be the command line statement.

"%JMETER_HOME%\bin\jmeter.bat" -n -t <jmx test file path> -l <csv result file path> -Djmeter.save.saveservice.output_format=csv
vins
  • 15,030
  • 3
  • 36
  • 47
  • It should be "%JMETER_HOME%\bin\jmeter.bat" -n -t -l -Jjmeter.save.saveservice.output_format=csv as `-D[prop_name]=[value] - defines a java system property value. -J[prop name]=[value] - defines a local JMeter property. ` refer link for more details [here](http://jmeter.apache.org/usermanual/get-started.html#override) – Ketu Dec 29 '15 at 13:36
0

In Command line mode: I have planned on Linux OS.

  1. download the latest jmeter version. Apache JMeter 3.2 (Requires Java 8 or later) as of now.

  2. Extract in your desired directory. For example, extract to /tmp/

  3. Now, default output file format will be csv. No need to change anything or specify in the CLI command. for example: ./jmeter -n -t examples/test.jmx -l examples/output.csv

For changing the default format, change the following parameter in jmeter.properties : jmeter.save.saveservice.output_format=xml

Now if you run the command : ./jmeter -n -t examples/test.jmx -l examples/output.jtl output get stored in xml format.

Now, make the request on multiple server(Additional info query): We can specify host and port as tags in

./jmeter -n -t examples/test.jmx -l examples/output.jtl -JHOST=<HOST> -JPORT=<PORT>

shashankS
  • 1,043
  • 1
  • 11
  • 21
0

Check my powershell command

$Date = Get-Date -Format ddMMyyyyhhmmss
jmeter -n -t jmetter\dev.jmx -l jmetter\TestResult-$Date.csv -o jmetter\Results-$Date\ -X

// For to know all parameter (like -n, -t, ...), use this command:

jmeter --?

Felipe Augusto
  • 1,341
  • 1
  • 16
  • 18
-2

Running JMeter in command line mode:

1.Navigate to JMeter’s bin directory

Now enter following command,

jmeter -n –t test.jmx

-n: specifies JMeter is to run in non-gui mode

-t: specifies name of JMX file that contains the Test Plan

Sneha
  • 2,200
  • 6
  • 22
  • 36
amit1881
  • 1
  • 1