性能测试工具LoadRunner30-LR之监控Tomcat

步骤:

  1.通过LR去访问tomcat监控页(安装tomcat的过程可以百度一下)

  2.然后通过关联取监控数据

  3.通过lr_user_data_point()添加数据到图表中去

 1 double atof(const char*string);    //把字符串转换成浮点数
 2 
 3 Action()
 4 {
 5     float freememory,totalmemory,maxmemory;    //定义指标变量
 6     
 7     web_set_user("tomcat",
 8         lr_decrypt("5bc7f31441549b071635"),
 9         "127.0.0.1:8080");    //设置登录tomcat的用户名和密码
10     
11     web_reg_save_param("Free memory",
12         "LB=Free memory:",
13         "RB=Total memory:",
14         LAST);    //设定监控参数  空闲内存 这里使用的关联函数
15     
16     
17     web_reg_save_param("Total memory",
18         "LB=Total memory:",
19         "RB=Max memory:",
20         LAST);    //总共内存
21 
22     
23     web_reg_save_param("Max memory",
24         "LB=Max memory:",
25         "RB=",
26         LAST);    //最大内存
27 
28     
29     web_url("web_url",
30         "URL=http://127.0.0.1:8080/manager/status",
31         "TargetFrame=",
32         "Resource=0",
33         "Referer=",
34         LAST);    //访问tomcat的status页面
35 
36     sleep(5);
37 
38     //把获取的字符类型转化为浮点数
39     freememory=atof(lr_eval_string("{Free memory}"));
40     totalmemory=atof(lr_eval_string("{Total memory}"));
41     maxmemory=atof(lr_eval_string("{Max memory}"));
42 
43     //自定义数据点,输出各个监控参数
44     lr_user_data_point("Tomcat JVM Free memory",freememory);
45     lr_user_data_point("Tomcat JVM Total memory",totalmemory);
46     lr_user_data_point("Tomcat JVM Max memory",maxmemory);
47 
48     sleep(5);
49 
50 
51     return 0;
52 }

 

posted on 2018-10-18 14:24  深海溺心  阅读(252)  评论(0编辑  收藏  举报

导航