Monitoring Tomcat with LoadRunner
LoadRunner does not come with a monitor for Tomcat. Fortunately, you can easily create one in about 5 minutes…
Tomcat exposes metrics related to JVM memory and Servlet container threads (and some other useful information) on a Status page at <Server Name>/manager (ask your Tomcat admin to enable it).
Create a standard web vuser script which loads the Tomcat Status page, and capture all the metrics you want using web_reg_save_param. Then log these values using lr_user_data_point. The metrics will be visible in the LoadRunner Controller and also in LoadRunner Analysis on the User-Defined Data Points Graph.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | lr_start_transaction("monitor tomcat"); /* <h1>JVM</h1><p> Free memory: 130.99 MB Total memory: 254.18 MB Max memory: 1016.12 MB</p> */ web_reg_save_param("JVMFreeMemory", "LB=Free memory: ", "RB= MB", "Ord=1", LAST); web_reg_save_param("JVMTotalMemory", "LB=Total memory: ", "RB= MB", "Ord=1", LAST); web_reg_save_param("JVMMaxMemory", "LB=Max memory: ", "RB= MB", "Ord=1", LAST); web_reg_find("Text=/manager", LAST); web_url("status", "URL=http://{ServerName}/manager/status", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t1.inf", "Mode=HTTP", LAST); lr_end_transaction("monitor tomcat", LR_AUTO); // Tomcat JVM metrics lr_user_data_point("Tomcat JVM Free memory", atof(lr_eval_string("{JVMFreeMemory}"))); lr_user_data_point("Tomcat JVM Total memory", atof(lr_eval_string("{JVMTotalMemory}"))); lr_user_data_point("Tomcat JVM Max memory", atof(lr_eval_string("{JVMMaxMemory}"))); |
An example script is available for download here [7 KB].
Related posts:
- Testing Web Services With a Standard Web Vuser It is possible to test web services using the standard...
- Load balancing vusers without a load balancer Recently I ran a test at a company which had...
- What’s New in LoadRunner 9.50? LoadRunner 9.5 was released today and, as mentioned by the...
- DNS-based load balancing for virtual users In DNS-based load balancing, a website visitor will request a...
- Changing LoadRunner/VuGen log options at runtime LoadRunner has a whole bunch of logging options. These can...
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

January 15th, 2009 at 1:06 am
Very interesting article. I plan on using this to test a tomcat application now. I am assuming you just configure this script to run with a pacing of 15-30 seconds (or how ever often you want to collect metrics) and then have it run for the length of the scenario?
Thanks for the excellent tip :)
[Stuart's Reply:
Yes, that's the idea. I like to use a pacing interval of 5 seconds, so that I get a fairly high level of granularity.
Note that you will probably have to modify the script a little depending on the number of JVMs, web servers and servlet containers you have configured.
Good luck with your testing!]
April 17th, 2009 at 1:46 am
For information, you could receive informations from Tomcat in XML format with :
/manager/status?XML=true
response extract :
….
September 1st, 2009 at 11:43 pm
Hello,
I write a jmx client tool in java, and i use it to monitor tomcat, jboss, jonas … and i create also user_data_point.
Unfortunately, you must have the Templates Bundle license to use it (java template).
[Stuart's Reply:
Thanks for your comment. I agree that JMX is a much nicer way to monitor a Java app server. Unfortunately, as you noted, it requires an additional license.
It would be great if HP would include 1 Java Template vuser (and maybe 1 Microsoft .Net vuser) with each LoadRunner license so that they could be used for monitoring.
I have already requested that they enhance the lr_user_data_point function so that people can more easily create monitors for unsupported applications, but perhaps this would be another good feature request.]