Facing error with JMeter in Non-GUI mode. Error: "Malformed option -" - jmeter

I am using Jmeter(5.1.1) in Non-GUI mode and unable to execute it. It still runs fine in GUI mode but fails in Non-GUI with "Error: Malformed option -". I removed the listeners from the JMX file but it still has some HTTP Request which are disabled will that be the problem here.?
I am currently using this command in my Windows 7 machine with Java 8.
Commands:
jmeter -n -t (location: C:\Users\File.jmx) -l (location: C:\Users\Results.csv)
Its not showing results neither updating the results.csv file, after each run its just showing "
Error: Malformed option -
" in command window. Can someone tell me what i am missing or what should i follow.?

Please use it like the below:-
jmeter -n -t D:\TestScripts\script.jmx -l D:\TestScripts\scriptresults.jtl
Hope this helps.

First you have to go to Jmeter/bin path where your Jmeter jar is located.
(For Example, C:\apache-jmeter-5.0\bin)
Now after going to that path using cmd, use below command given that your abc.jmx file is at the above mentioned location only and once execution starts it will automatically create def.jtl at that location, hope this have given you clarity:
jmeter -n -t abc.jmx -l def.jtl

Ok, so here what i was doing wrong. Dont know if this is stupid but might help others.
Since we use JMeter at work locations, my drive was linked with the cloud folder where none of the commands get execute i believe, so when i copy the installed JMeter folder and my JMX file to a Local location, say
before:
> C:\UsersABC\OneDrive-UserABC\JMETER\apache-jmeter-5.1.1\bin
Now:
> C:\JMET\apache-jmeter-5.1.1\bin
That OneDrive causing all the trouble. But thanks to all of you guys, you helped me figured this out. Thanks alot again :)

I got the same issue while trying with "jmeter -n -t D:\load test 01\test.jmx -l D:\TestScripts\scriptresults.jtl" command.
Then I changed it to "jmeter -n -t D:\load_test_01\test.jmx -l D:\TestScripts\scriptresults.jtl" and it worked fine, in my case the issue was whitespaces in the folder name.

Related

JMeter Distributed Runner not able to Generate the Consolidated Reports

When I am running a simple standalone JMeter script using command line as below
jmeter -n -t your_script.jmx
This generates a CSV file which contains all the data related to the execution.
However, when the same JMeter file executed for a distributed load testing with multiple JMeter Server IP addresses which will simulate the given number of users and runs on the target server, I am not able to get the jmeter.csvfile Generated(But the command runs successfully).
The command I have used for distributed execution is
jmeter -n -t script.jmx -R IP_address1, IP_address2,...
Now, I should get a consolidated jmeter.csv file from this execution. But, I am not getting one.
Same is the case with JMeter API DistributedRunner Class- We are not getting the consolidated jmeter.csv file and reports.
This command:
jmeter -n -t your_script.jmx
does not generate any CSV file, you need to add -l command-line argument and provide desired results file location like:
jmeter -n -t your_script.jmx -l jmeter.csv
The same applies for distributed testing:
jmeter -n -t script.jmx -R IP_address1, IP_address2 -l jmeter.csv
If you provide -l command-line argument but still not getting any results most probably your script execution fails on remote slaves somewhere somehow. Follow the below checklist in order to get to the bottom of the script failure:
Inspect jmeter.log file on master machine and jmeter-server.log on the remote slaves, if something goes wrong - most probably you will find the cause in log files
Make sure that JRE version is the same on master and the slaves
Make sure that JMeter version is the same on master and the slaves, it's recommended to use the latest JMeter version where possible
If the test relies on any of the JMeter Plugins - make to install them all onto all slave machines. The plugins can be installed using JMeter Plugins Manager
If your test is using CSV Data Set Config - you will need to copy the CSV file to all slaves manually
If your test needs any additional JMeter Properties you will need to supply the properties via -J or -D command-line arguments on all the machines or via -G command-line arugment on the master

How to save JMeter Report with Timestamp added in ReportName

I am generating JMeter HTML report through command prompt. I want to save the report with Timestamp, so that in future i can compare these reports. Without clearing the report folder if i am trying to execute i am getting below error message,
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
An error occurred: Cannot write to 'D:\AgileCockpit_IntegrationTest\HtmlReports' as folder is not empty
errorlevel=1
I am using below command to execute,
jmeter -n -t D:\AgileCockpit_IntegrationTest\AgileCockpitIntegrationTest.jmx -l D:\AgileCockpit_IntegrationTest\Result\Result1.csv -e -o D:\AgileCockpit_IntegrationTest\HtmlReports\
Same with CSV file.
Please help me on this...Thanks in advance.
You can add a timestamp to .jtl results file and HTML reporting dashboard folder using Windows date and time commands combination like:
jmeter -n -t D:\AgileCockpit_IntegrationTest\AgileCockpitIntegrationTest.jmx -l "D:\AgileCockpit_IntegrationTest\Result\%date:~-4%-%date:~3,2%-%date:~0,2%-%time:~0,2%-%time:~3,2%-%time:~6,2%.jtl" -e -o "D:\AgileCockpit_IntegrationTest\HtmlReports\%date:~-4%-%date:~3,2%-%date:~0,2%-%time:~0,2%-%time:~3,2%-%time:~6,2%"
Different results files can be compared using Merge Results tool, the tool can be installed using JMeter Plugins Manager

How to upload .jtl file to blazemeter sense

I created a Jenkins job where it run some JMeter scripts and return .jtl files. Now, I want to upload this files to Blazemeter Sense to see the performance test, downloads pdf reports, etc.
I've searched a lot of information, where I find that to upload some file, I can use this command thats running from Windows CMD:
curl -v https://sense.blazemeter.com/api/files -H "Authorization: Token 'cat ~/.loadosophia.token'" -F "projectKey=Project_name" -F "jtl_file=#jtl.gz"
REFERENCE: https://sense.blazemeter.com/wiki/help:uploads/
The only values that I change are
cat ~/.loadosophia.token, where I replaced for my Upload Token (finded in Blazemeter Sense -> Options -> Settings -> Your Upload Token)
projectKey where I replaced by my project name (test_taurus)
jtl_file where I replaced by the file directory generated by Jmeter test (.jtl)
The final command is:
curl -v https://sense.blazemeter.com/api/files -H "Authorization: Token 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXYLaa'" -F "projectKey=test_taurus" -F "jtl_file=/path/of/file/file.jtl"
I missed some? What is my wrong? Existe another posibility to make it?
Thanks everyone
U P D A T E:
I did what Dmitri T said. Thats works. But when I run the command, the output is the following:
What could be the issue?
You need to remove quotation marks around the token
You need to add an "at" symbol before the .jtl file path
Fixed command would be something like:
curl -v https://sense.blazemeter.com/api/files -H "Authorization: Token XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXYLaa" -F "projectKey=test_taurus" -F "jtl_file=#/path/of/file/file.jtl"
More information: Upload files with CURL
You might find BM.Sense Uploader plugin more convenient to use, the plugin can be installed using JMeter Plugins Manager:

Jmeter non-GUI -Jjmeter.save.saveservice.print_field_names=true not getting honoured

I need to have headers in the jmeter csv output, i tried jmeter in non GUI mode to with -Jjmeter.save.saveservice.print_field_names=true (command : jmeter -Jjmeter.save.saveservice.print_field_names=true -n -t ....).
The result file is getting generated without headers.
Can someone help me how to get csv output file with headers in jmeter command line mode ?
Note: I am using Jmeter3.1
By default, jmeter.save.saveservice.print_field_names=true in JMeter 3.1 version and ealier versions too.
The headers are saved when ran the following command (Non-GUI mode):
jmeter.bat -n -t Scrept.jmx -l results.jtl
-Gjmeter.save.saveservice.print_field_names=true is worked for me in master-slave mode.
Thank you.

JMeter Multiple Log Files from Command Line

I'm running JMeter through jenkins for performance testing using the command line options. I already write to one jtl file when I do the command, such as:
java -jar path to Jmeter -n -t jmx file -l log file
I would like to also put the results into another log file stored in another location, but I can't get it to work by putting another path after the -l command or putting in a second -l. Is there anyway to do this simply?
Thanks
Check these options. you should use the option '-j'. It works fine for me.
-n This specifies JMeter is to run in non-gui mode
-t [name of JMX file that contains the Test Plan].
-l [name of JTL file to log sample results to].
-j [name of JMeter run log file].
-r Run the test in the servers specified by the JMeter property "remote_hosts"
-R [list of remote servers] Run the test in the specified remote servers

Resources