Adding VuGen Functions Overview

This section contains useful VuGen functions that you may want to add to your script while debugging or preparing your script for load testing.

Obtain Vuser Information

You can add the following functions to your Vuser scripts to retrieve Vuser information:

Function
Description
lr_get_attrib_string
Returns a command line parameter string.
lr_get_host_name
Returns the name of the machine running the Vuser script.
lr_get_master_host_name
Returns the name of the machine running the Controller. Not applicable when working with HPE Application Performance Management.
lr_whoami
Returns the name of a Vuser executing the script. Not applicable when working with HPE Application Performance Management.

In the following example, the lr_get_host_name function retrieves the name of the computer on which the Vuser is running.

my_host = lr_get_host_name( );

For more information about the above functions, see the Function Reference.

Back to top

Send Messages to Output

Using the Message type functions in your Vuser script, you can send customized error and notification messages to the output and log files, and to the Test Report summary. For example, you could insert a message that displays the current state of the client application. LoadRunner Controller displays these messages in the Output window. You can also save these messages to a file.

When working with HPE Application Performance Management, you can use Message type functions to send error and notification messages to the Web site or Business Process Monitor log files. For example, you could insert a message that displays the current state of the Web-based application.

Note: Do not send messages from within a transaction as this may lengthen the transaction execution time and skew the transaction results.

You can use the following message functions in your Vuser scripts:

Function
Description
lr_debug_message
Sends a debug message to the Output window or the Business Process Monitor log file.
lr_error_message
Sends an error message to the Output window or the Business Process Monitor log files.
lr_get_debug_message
Retrieves the current message class.
lr_log_message
Sends an output message directly to the log file, output.txt, located in the Vuser script folder. This function is useful in preventing output messages from interfering with TCP/IP traffic.
lr_output_message
Sends a message to the Output window or the Business Process Monitor log files.
lr_set_debug_message
Sets a message class for output messages.
lr_vuser_status_message
Sends a message to the Vuser status area in the Controller. Not applicable when working with HPE Application Performance Management.
lr_message
Sends a message to the Vuser log and Output window or the Business Process Monitor log files.

The behavior of the lr_message, lr_output_message, and lr_log_message functions are not affected by the script's debugging level in the Log runtime settings—they will always send messages.

Back to top