How to generate .jtl file in jmeter with unique name? - jmeter

I have a doubt.
I want to create .jtl file with uniqe name in yy-mm-dd-time format.
How can i do this?

If you want to use JMeter listener to write JTL file, you can use time function (and put it into filename parameter of listener) like:
${__time(yy-MM-dd-HH-mm-ss)}.jtl
It also has shortcuts that you may want to use.
If you want to create JTL via -l command line option, you can use usual command line possibilities. For example in linux you can do:
sh jmeter.sh -n -t "TestPlan.jmx" -l $(date -d "today" +"%Y-%m-%d-%H-%M-%S").jtl

Related

How do I automatically save results of a table in a JMeter Listener at the end of the test

I have a Listener element that calculates some results from samples executed. I can manually save these results at the end of the test, but i would like to save them at the end of the test automatically to a file.
What do i need to do reacte to the End of test notification that seems to be sent by the JMeterEngine? Or is there a better solution do something at the end of the test?
In listeners there is a section named Filename just mention the path with the filename extension in which you want to save the result set, In this way J Meter will automatically saves the results that you want to store at the end of the test execution.
Consider using JMeterPluginsCMD Command Line Tool
Install JMeter Plugins Manager
Install JMeterPluginsCMD Command Line Tool
Install Synthesis Report
Run your JMeter test in command-line non-GUI mode like
jmeter -n -t test.jmx -l result.jtl
Generate textual representation of the Aggregate Report table like:
JMeterPluginsCMD.bat --generate-csv my-table.csv --input-jtl result.jtl --plugin-type AggregateReport
That's it, now you can open my-table.csv and enjoy your test results
You can generate other reports and charts similarly, check out How to Use the JMeterPluginsCMD Command Line article for more details.

Trim new line character at end of jtl file saved from JMeter command line

On Ubuntu, inside of a bash script, this ran ( along with some other commands ):
sudo jmeter -n -t test.jmx -l /home/ubuntu/apache-jmeter-2.13/bin/results.jtl
When I do a "ls", I see this file with a question mark in the filename for some reason results.jtl?. I believe this is because there is a new line at the end of the file after the last line of the .jtl:
"
"
That question mark character in the file name is causing me problems. If I open the file with nano, manually delete the newline out of the file and save the file as results.jtl, then I can use the .jtl file like normal.
How can I get JMeter to save the .jtl without adding that newline to the end of the .jtl?
If that is not possible, how can I fix this? I would like to avoid using code to read the file and make adjustments. I would think there should be a more straightforward answer to this.
I also tried to open some of my other scripts involved and remove any white-space or new lines at the end of those scripts. This has not helped either, though. I was thinking about why the "?" would be in the file name, to begin with, and trying any solutions.
Furthermore, if I deleted the "results.jtl?" file and ran the JMeter command on the command line, not inside a bash script file, then JMeter did not save it with the ? in the file name. So, it's only when the bash script is run that the ? is in the file name.

edit/save a file within shell script

I think this question fall under pipes, am bad at it.
Using one of my shell script, a file is generated with millions of rows.
Before I can use it with another command, I need to edit this file. I need to add a text e.g 'txt' in front of every line.
What i am currently doing now is,
-exit the shell script after file is generated
-open it in vim
-use command :g/^/s//txt/g to add txt at start of each line
-save file
-use it in remaining shell script
I am sure there would be a more efficient way, which i am not aware of. thanks for the help.
As some people said in the comments, you can use GNU sed to do that:
sed -i 's/^/txt/' yourfile.txt
The -i stands for --in-place and edit your file instead of printing to stdout.

What is the difference between -p and -q options

We have decided to split our jmeter properties into 2 files. One contains more "environment" related variables and the other contains more application centric (stuffs that changes with version).
Everything seems to work fine when using "jmeter.sh -q file1 -q file2 -t test.jmx". However we found there was also a -p option. In which context should it be use (vs the -q?)
According to the documentation:
-p, --propfile {argument}
the jmeter property file to use
-q, --addprop {argument}
additional property file(s)
this is, using -p you overwrite jmeter.properties, using -q adds a custom properties file.

How to write to a different file everyday day of the week using bash

I have a script that pulls information from a file and outputs it to a different file. What i need to do is run this script everyday but output to a different file. I will have this in the crontab to run everyday at the same time but i dont know how to output to a different file everyday. Is there a loop i can use?
Regards,
John
You don't need a loop. Rather, use a stdout/stderr redirection to a filename created using 'date'
e.g.
$ myprocess.sh > `date +"%m-%d-%Y"`.log
so date is executed in the backticks (this is known as command substitution) and the output substituted in the line. Here the formatted output of date is used as the log file name (in this case 04-24-2014.log)

Resources