How Do I Run JMeter in Non-GUI Mode?
Do you think the JMeter GUI is a good GUI?
After all, the GUI is always considerate, shows up on time, is willing to carry it's share of the load....
On one hand, the GUI makes the program more intuitive; on the other hand, it consumes more resources.
Isn’t better to redirect these resources to the generation of useful load tests?
Yes, it is very good idea. Let's review a few typical cases of running JMeter in non-GUI mode.
Step 1. Prepare the JMeter test
Open your *.jmx file
Remove all graphic data writers
They will not work in the non-gui mode and there no need to keep them in testing scenario.
Step 2. Run the JMeter test
Go to bin folder of your JMeter installation from command prompt
Type the following command:
jmeter -n -t D:\TestScripts\script.jmx -l D:\TestScripts\scriptresults.jtl
-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].
Besides these options, JMeter has several other parameters that can be used for running in non-GUI mode.
-R [list of remote servers] Run the test in the specified remote servers
-H [proxy server hostname or ip address]
-P [proxy server port]
These options are used for remote execution of JMeter tests and for using JMeter through a proxy server.
Step 3. Stop running the test
When running JMeter in non-GUI mode, there is no Menu, and JMeter does not react to keystrokes such as Control + '.'. So in versions post 2.3.2, JMeter non-GUI mode will listen for commands on a specific port (default 4445, see the JMeter property jmeterengine.nongui.port ). In versions post 2.4, JMeter supports the automatic choice of an alternate port if the default port is being used (i.e. by another JMeter instance). In this case, JMeter will try the next highest port, continuing until it reaches the JMeter property jmeterengine.nongui.maxport, which defaults to 4455. If maxportis less than or equal to port , port scanning will not take place.
Note that JMeter 2.4 and earlier did not set up the listener for non-GUI clients, only non-GUI standalone tests; this has been fixed.
The chosen port is displayed in the console window.
The commands currently supported are:
Shutdown - graceful shutdown
StopTestNow - immediate shutdown
These commands can be sent by using the shutdown[.cmd|.sh] or stoptest[.cmd|.sh] script respectively. The scripts are to be found in the JMeter /bin directory. The commands will only be accepted if the script is run from the same host.
Note-before using shutdown.cmd or shutdown.sh CLASSPATH variable should be set to path with ApacheJmeter.jar, because inside these files we have string like
“java -cp %~dp0ApacheJMeter.jar org.apache.jmeter.util.ShutdownClient StopTestNow %*”. It means that JVM calls class file from ApacheJMeter.jar.
Look out for the next episode when we discuss interpreting how the *.jtl files feels about communication and if that is created as a result of non-GUI test.
For more information, check out our free Webinar "How to Make Performance Testing with JMeter Simple"
You might also find these useful:
Interested in writing for our Blog? Send us a pitch!