Using LoadRunner for performance testing, the general intuition is that LR can only complete the script recording and writing the request behavior of the impersonated user, but in some cases, to monitor the performance of some middleware or Web servers, it is not possible to record scripts to complete, then you need to write the script manually, The Lr_user_data_point ("", "") dot function is customized to monitor its performance through LR.
Here is an example of monitoring the Tomcat Web server.
Implementation ideas:
1, configure the Tomcat login user, find the tomcat-6.0.37 directory/conf/tomcat-users.xml, add the following configuration:
< tomcat-users > < rolename= "Manager-gui"/><username= "Monitor" password= "123456" roles= "Manager-gui"/> </tomcat-users>
(After configuring the Tomcat login user, it is recommended to test the configured user login to log into the Tomcat Administration page)
2. In the action script, use Web_set_user ("username", "password", "The IP address where the Tomcat server resides: Port");
3. Write Web_url () in the script; Impersonate the URL to access Tomcat and log in
4, using the correlation function web_reg_save_parm () to dynamically capture the desired data
5, finally using the dot function lr_user_data_point ("Monitoring indicator name", "Monitoring indicator value"); Record user-defined data samples
The Vugen script code is as follows:
Action_tomcat () {DoubleAtofConst Char*string); Web_reg_save_param ("jvm_freememory", "Lb=free Memory:", "rb= MB", "ord=1", last); Web_reg_save_param ("jvm_totalmemory", "lb=total Memory:", "rb= MB", "ord=1", last); Web_reg_save_param ("jvm_maxmemory", "Lb=max Memory:", "rb= MB", "ord=1", last); Web_reg_save_param ("http_maxthreads", "Lb=max Threads:", "rb=", "ord=1", last); Web_reg_save_param ("Http_maxprocessingtime", "Lb=max processing Time:", "rb= S", "ord=1", last); Web_reg_save_param ("Http_requestcount", "lb=request Count:", "rb=", "ord=1", last); Web_reg_save_param ("http_bytesreceived", "Lb=bytes Received:", "rb= MB", "ord=1", last); Web_set_user ("Monitor","123456","localhost:8088"); Lr_think_time (5); Web_url ("Status", "Url=http://localhost:8088/manager/status", "resource=0", "referer=", "Snapshot=t1.inf", "mode=html", last); Lr_user_data_point ("tomcat_jvm_freememory", Atof (Lr_eval_string ("{jvm_freememory}"))); Lr_user_data_point ("tomcat_jvm_totalmemory", Atof (Lr_eval_string ("{jvm_totalmemory}"))); Lr_user_data_point ("tomcat_jvm_maxmemory", Atof (Lr_eval_string ("{jvm_maxmemory}"))); Lr_user_data_point ("tomcat_http_maxthreads", Atof (Lr_eval_string ("{http_maxthreads}"))); Lr_user_data_point ("Tomcat_http_maxprocessingtime", Atof (Lr_eval_string ("{Http_maxprocessingtime}"))); Lr_user_data_point ("Tomcat_http_processingtime", Atof (Lr_eval_string ("{Http_processingtime}"))); Lr_user_data_point ("Tomcat_http_requestcount", Atof (Lr_eval_string ("{Http_requestcount}"))); Lr_user_data_point ("tomcat_http_bytesreceived", Atof (Lr_eval_string ("{http_bytesreceived}"))); return 0;}
Run the script to view the replay log:
Scripting Good (note: It is recommended to put this script code that monitors tomcat into a new action and put it behind a previously recorded business script), then optimize the business script, create the controller and so on with the usual performance testing process.
Add "run-time graph-user-defined data point graph" in the controller monitoring scene diagram
Finally, in the analysis report, you can see that the "run-time graph-user-defined data point graph" is displayed with data,
Note: The values of tomcat_jvm_freememory and tomcat_http_requestcount here will be larger, while Tomcat_http_maxthreads, Tomcat_jvm_maxmemory, Tomcat _http_maxprocessingtime These values do not change very much the reason is basically the limitation of Tomcat itself.
Conclusion: It can be seen that Tomcat handles client request bottlenecks during 4~5min, and subsequent analysis of other graphs may be a CPU bottleneck.
How LR monitors tomcat performance