Conversion between LoadRunner parameters and variables

Source: Internet
Author: User

This is a script based on the script for custom monitoring Tomcat using LoadRunner. this article describes how parameters interact and how parameters and variables are copied and transferred. the following code comments are written according to your own understanding, and the correctness is not guaranteed.

 

[CPP]View plaincopy
  1. Action ()
  2. {
  3. // Define a three-character array for condition judgment
  4. Char JFM [100];
  5. Char JTM [100];
  6. Char jmm [100];
  7. // You must declare the data conversion function in advance. Otherwise, the monitoring result is incorrect.
  8. Double atof (const char * string );
  9. // The following three web_reg_save_param documents capture monitoring data from Tomcat:
  10. Web_reg_save_param ("jvm_free_memory ",
  11. "LB = free memory :",
  12. "RB = Mb ",
  13. "Ord = 1 ",
  14. Last );
  15. Web_reg_save_param ("jvm_total_memory ",
  16. "LB = total memory :",
  17. "RB = Mb ",
  18. "Ord = 1 ",
  19. Last );
  20. Web_reg_save_param ("jvm_max_memory ",
  21. "LB = max memory :",
  22. "RB = Mb ",
  23. "Ord = 1 ",
  24. Last );
  25. // Set monitoring transactions
  26. Lr_start_transaction ("status ");
  27. // Log on to Tomcat
  28. Web_set_user ("admin", "admin", "localhost: 8080 ");
  29. // Tomcat monitoring URL
  30. Web_url ("status ",
  31. "Url = http: // localhost: 8080/manager/status ",
  32. "Resource = 0 ",
  33. "Reccontenttype = text/html ",
  34. "Snapshot = t1.inf ",
  35. "Mode = html ",
  36. Last );
  37. Lr_end_transaction ("status", lr_pass );
  38. // User-defined monitoring of atat_jvm usage
  39. // Lr_user_data_point ("JVM free memory", atof (lr_eval_string ("{jvm_free_memory }")));
  40. // Lr_user_data_point ("JVM total memory", atof (lr_eval_string ("{jvm_total_memory }")));
  41. // Lr_user_data_point ("JVM Max memory", atof (lr_eval_string ("{jvm_max_memory }")));
  42. Lr_output_message ("**********************************");
  43. // Print Monitoring Value
  44. Lr_output_message (lr_eval_string ("{jvm_free_memory }"));
  45. Lr_output_message (lr_eval_string ("{jvm_total_memory }"));
  46. Lr_output_message (lr_eval_string ("{jvm_max_memory }"));
  47. Lr_output_message ("**********************************");
  48. // Save the parameter value in another parameter (in principle, it is similar to the reference in C ++)
  49. Lr_save_string (lr_eval_string ("{jvm_free_memory}"), "jfreemem ");
  50. Lr_save_string (lr_eval_string ("{jvm_total_memory}"), "jtotalmem ");
  51. Lr_save_string (lr_eval_string ("{jvm_max_memory}"), "jmaxmem ");
  52. Lr_output_message ("**********************************");
  53. // Print the value in "Reference"
  54. Lr_output_message (lr_eval_string ("{jfreemem }"));
  55. Lr_output_message (lr_eval_string ("{jtotalmem }"));
  56. Lr_output_message (lr_eval_string ("{jmaxmem }"));
  57. Lr_output_message ("**********************************");
  58. // Assign the parameter value to the variable (String Array)
  59. Strcpy (JFM, lr_eval_string ("{jvm_free_memory }"));
  60. Strcpy (JTM, lr_eval_string ("{jvm_total_memory }"));
  61. Strcpy (jmm, lr_eval_string ("{jvm_max_memory }"));
  62. // Perform logical judgment
  63. If (strcmp (JFM, "") = 0 & strcmp (JTM, "") = 0 & strcmp (jmm, "") = 0 ){
  64. Lr_output_message ("% s", "No parameter ");
  65. } Else {
  66. Lr_output_message ("% s", "parameter ");
  67. }
  68. // Output the actual value
  69. Lr_output_message ("**********************************");
  70. Lr_output_message ("% s", JFM );
  71. Lr_output_message ("% s", JTM );
  72. Lr_output_message ("% s", jmm );
  73. Lr_output_message ("**********************************");
  74. // Save the variable value in another parameter (in principle, it is similar to the reference in C ++)
  75. Lr_save_string (JFM, "jfreemem ");
  76. Lr_save_string (JTM, "jtotalmem ");
  77. Lr_save_string (jmm, "jmaxmem ");
  78. Lr_output_message ("**********************************");
  79. Return 0;
  80. }

Conversion between LoadRunner parameters and variables

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.