About
Download
Documentation
JMeter Resources
Community
|
11. Building a Monitor Test Plan
|
In this section, you will learn how to create a
Test Plan
to monitor webservers. Monitors
are useful for a stress testing and system management. Used with stress
testing, the monitor provides addtion information about server performance.
It also makes it easier to see the relationship between server performance
and response time on the client side. As a system administration tool, the
monitor provides an easy way to monitor multiple servers from one console.
The monitor was designed to work with the status servlet in Tomcat 5. In
theory, any servlet container that supports JMX (Java Management Extension)
can port the status servlet to provide the same information.
|
|
11.1 Adding A Server
|
The first step is to add a
Thread Group
element. The Thread Group tells JMeter the number of threads you want. Always use
1, since we are using JMeter as a monitor. This is very important for those not
familiar with server monitors. As a general rule, using multiple threads for a
single server is bad and can create significant stress.
Go ahead and add the ThreadGroup element by first selecting the Test Plan,
clicking your right mouse button to get the Add menu, and then select
Add --> ThreadGroup.
You should now see the Thread Group element under Test Plan. If you do not
see the element, "expand" the Test Plan tree by clicking on the Test Plan element.

Figure 10.1. Thread Group with Default Values
|
Enter the name of the server.
|
|
11.2 Adding HTTP Request
|
Add the
HTTP Request
to the Thread Group element
(Add --> Sampler --> HTTP Request). Then, select the HTTP Request element
in the tree and edit the following properties):
-
Change the Name field to "Server Status".
-
Enter the IP address or Hostname
-
Enter the port number
-
Set the Path field to "/manager/status" if you're using Tomcat.
-
Add a request parameter named "XML" in uppercase. Give it a value of
"true" in lowercase.
-
Check "Use as Monitor" at the bottom of the sampler
|
|
11.3 Adding Constant Timer
|
Add a timer to this thread group (Add --> Timer --> Constant Timer).
Enter 5000 milliseconds in the "Thread Delay" box. In general, using intervals shorter
than 5 seconds will add stress to your server. Find out what is an acceptable interval
before you deploy the monitor in your production environment.
|
|
11.4 Adding a Listener to Store the Results
|
If you want to keep a record of the server's performance, add a
Listener
. This element is
responsible for storing all of the results of your HTTP requests in a file.
Select the thread group element and add a
Simple Data Writer
listener
(Add --> Listener --> Simple Data Writer). Next, you need to specify a directory
and filename of the output file. You can either type it into the filename field, or
select the Browse button and browse to a directory and then enter a filename.
|
|
11.5 Adding Monitor Results
|
Add the
Listener
by selecting the
test plan element (Add --> Listener -- > Monitor Results). There are two tabs in
the monitor results listener. The first is the "Health", which displays the status of
the last sample the monitor received. The second tab is "Performance", which shows a
historical view of the server's performance.
|
|
11.6 Saving the Test Plan
|
Although it is not required, we recommend that you save the Test Plan to a
file before running it. To save the Test Plan, select Save Test Plan from the
File menu (with the latest release, it is no longer necessary to select the
Test Plan element first).
JMeter allows you to save the entire Test Plan tree or
only a portion of it. To save only the elements located in a particular "branch"
of the Test Plan tree, select the Test Plan element in the tree from which to start
the "branch", and then click your right mouse button to access the Save As menu item.
Alternatively, select the appropriate Test Plan element and then select Save As from
the Edit menu.
|
|
|
11.7 Running the Test Plan
|
From the Run menu, select Run.
JMeter lights up a green square in the upper-right-hand corner to indicate if a test is
currently running. The square is turned gray when all tests stop. Even after you select "stop",
the green light will stay on until all test threads have exited.
|
Once JMeter has finished running your Test Plan, select Stop from the
Run menu.
If you selected a file to save the results to in your listener, then you will have a file that can be
opened in any visualizer. Each visualizer will display the results in it's own fashion.
It is possible to have the same file open in more than one visualizer. This is not a problem. JMeter
will ensure during the test run that no sample is recorded to the same file more than once.
|
|
|
|