loadrunner监控tomcat 代码及遇到的问题

监控tomcat 首先要在tomcat的conf下的 tomcat-users.xml中增加user

代码:

Action_Tomcat()
{
    double atof(const char * string);

    web_set_user("tomcat","tomcat","localhost:8080");

    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);

    lr_think_time(5);

    web_url("status",
            "URL=http://localhost:8080/manager/status",
            "TargetFrame=",
            "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;
}
脚本完成,单击运行,然后···

检查了一下发现

这俩Action不一致,修改后运行脚本,ok了。

监控Tomcat的这段脚本代码放在新插入一个Action里面,并且放在之前录制来的业务脚本后面

然后就可以从Controller中观察到tomcat的运行状态了。

值得一提的是只有应用lr_user_data_point()函数,“User Defined Data Points”才处于可用状态。

 

转载于:https://www.cnblogs.com/adolf/p/5779764.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值