LoadRunner监控Tomcat

来源:互联网 发布:ni软件什么用 编辑:程序博客网 时间:2024/06/07 09:28

脚本如下:

<span style="font-size:18px;">double atof (const char *string); //把字符串转换成浮点数Action(){    float freememory,totalmemory,maxmemory;//定义指标变量web_set_user("admin","" ,"localhost:8080"); //设置登录tomcat的账户,端口号web_reg_save_param("Free memory",//设定监控参数—空闲内存"LB=Free memory: ","RB=Total memory:",LAST);web_reg_save_param("Total memory",//总共内存"LB=Total memory:","RB=Max memory:",LAST);web_reg_save_param("Max memory", //最大内存"LB=Max memory:","RB=",LAST);web_url("status", //访问tomcat的status页面"URL=http://localhost:8080/manager/status", "TargetFrame=", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t1.inf", "Mode=HTML", LAST);sleep(5);//把获取到的字符类型数据转化为浮点数    freememory=atof(lr_eval_string("{Free memory}"));totalmemory=atof(lr_eval_string("{Total memory}"));maxmemory=atof(lr_eval_string("{Max memory}"));    //自定义数据点 输出各个监控参数  lr_user_data_point("Tomcat JVM Free memory", freememory);  lr_user_data_point("Tomcat JVM Total memory", totalmemory);  lr_user_data_point("Tomcat JVM Max memory", maxmemory);sleep(5);return 0;}</span>


0 0