这是用LoadRunner自定义监控Tomcat的脚本为基础而写的脚本.阐述了参数相互之间以及参数与变量之间复制传递原理.下面的代码注释是按照本身的理解写的,正确性不必定保证.html
- Action()
- {
-
- char jFM[100];
- char jTM[100];
- char jMM[100];
-
-
- double atof(const char *string);
-
-
- web_reg_save_param("JVM_Free_Memory",
- "LB=Free memory:",
- "RB=MB",
- "ORD=1",
- LAST);
- web_reg_save_param("JVM_Total_Memory",
- "LB=Total memory:",
- "RB=MB",
- "ORD=1",
- LAST);
- web_reg_save_param("JVM_Max_Memory",
- "LB=Max memory:",
- "RB=MB",
- "ORD=1",
- LAST);
-
-
- lr_start_transaction("Status");
-
- web_set_user("admin", "admin", "localhost:8080");
-
- web_url("status",
- "URL=http://localhost:8080/manager/status",
- "Resource=0",
- "RecContentType=text/html",
- "Snapshot=t1.inf",
- "Mode=HTML",
- LAST);
-
- lr_end_transaction("Status", LR_PASS);
-
-
-
-
-
- lr_output_message("**********************************");
-
-
- lr_output_message(lr_eval_string("{JVM_Free_Memory}"));
- lr_output_message(lr_eval_string("{JVM_Total_Memory}"));
- lr_output_message(lr_eval_string("{JVM_Max_Memory}"));
-
- lr_output_message("**********************************");
-
-
- lr_save_string(lr_eval_string("{JVM_Free_Memory}"), "JFreeMem");
- lr_save_string(lr_eval_string("{JVM_Total_Memory}"), "JTotalMem");
- lr_save_string(lr_eval_string("{JVM_Max_Memory}"), "JMaxMem");
-
- lr_output_message("**********************************");
-
-
- lr_output_message(lr_eval_string("{JFreeMem}"));
- lr_output_message(lr_eval_string("{JTotalMem}"));
- lr_output_message(lr_eval_string("{JMaxMem}"));
-
- lr_output_message("**********************************");
-
-
- strcpy(jFM, lr_eval_string("{JVM_Free_Memory}"));
- strcpy(jTM, lr_eval_string("{JVM_Total_Memory}"));
- strcpy(jMM, lr_eval_string("{JVM_Max_Memory}"));
-
-
- if (strcmp(jFM, "") == 0 && strcmp(jTM, "") == 0 && strcmp(jMM, "") == 0) {
- lr_output_message("%s", "无参数");
- } else {
- lr_output_message("%s", "有参数");
- }
-
-
- lr_output_message("**********************************");
- lr_output_message("%s", jFM);
- lr_output_message("%s", jTM);
- lr_output_message("%s", jMM);
- lr_output_message("**********************************");
-
-
- lr_save_string(jFM, "JFreeMem");
- lr_save_string(jTM, "JTotalMem");
- lr_save_string(jMM, "JMaxMem");
- lr_output_message("**********************************");
-
- return 0;
- }