Highlighted
Super Contributor.. Super Contributor..
Super Contributor..
544 views

Vugen scripting

HI Team,

Please help for Vugen scripting logic as i am new to it. 

Please find attached screenshot. The requirement is if state and Health is not RUNNING and OK respectively , we need alert along with Server name.

Please let me know how to do this.

Regards,

Nilesh

0 Likes
4 Replies
Highlighted
Acclaimed Contributor.. Acclaimed Contributor..
Acclaimed Contributor..

Re: Vugen scripting

Just take a moment to play the role of a forum member that doesn't know any thing about your project and consider the image that you posted.

What kind of questions would you ask to be able to help (missing info). Please answer those here and you might make some progres.

You are at level 11, so you should be able to do a better job.

Signature:
Reward community members who take time to respond and help.
0 Likes
Highlighted
Honored Contributor.
Honored Contributor.

Re: Vugen scripting

Hi

1) It's depend on the protocol that you are using . 

 for example : on web h/h  the step web_url return int with the step status

 ( LR_PASS (0) on success, and LR_FAIL (1) on failure. )

 https://admhelp.microfocus.com/lr/en/12.60-12.61/help/function_reference/Content/FuncRef/web/lrFr_web_url.htm

 so you can check the status and decide what to do .

2) Other options is to wrap the steps with transaction and see if trnsaction pass / failed 

like here : http://allaboutloadrunner.blogspot.com/2012/11/transaction-in-loadrunner.html 

3) Don't forget to select this options at RunTime setting in order to continue the replay when error ocuured 

     [] Miscellaneous -> continue on error 

 

p.s

if it's still not clear please attach any screenshot from your script / zip any minial script and i will try to help you 

Regards

Oren

0 Likes
Highlighted
Super Contributor.. Super Contributor..
Super Contributor..

Re: Vugen scripting

HI,

 

I am able to get partial success to capture running and health OK status.

Action()
{
    int i;
    int a;
    int b;
    int c;
    int e;
    int x;
    int y;
    
    web_set_sockets_option("SSL_VERSION", "2&3");
lr_start_transaction("Login Page");

    web_set_user("tfsuser", 
        lr_decrypt("5c347e7c68f166e092a78b38"), 
        "ux311pas016.ux.icacorp.net:8102");

    web_reg_find("Search=Body",
        "SaveCount=RUNNING_COUNT",
        "Text=RUNNING",
        LAST);
    web_reg_find("Search=Body",
        "SaveCount=STARTING_COUNT",
        "Text=STARTING",
        LAST);

    web_reg_find("Search=Body",
        "SaveCount=HEALTH_OK_COUNT",
        "Text=HEALTH_OK",
        LAST);
    
    web_reg_find("Search=Body",
        "SaveCount=HEALTH_WARN_COUNT",
        "Text=HEALTH_WARN",
        LAST);

    
    web_reg_find("Fail=NotFound",
        "Search=All",
        "Text=HTTP/1.1 200 OK",
        LAST);

    web_url("servers", 
        "URL=https://ux311pas016.ux.icacorp.net:8102/management/tenant-monitoring/servers", 
        "Resource=0", 
        "RecContentType=text/html", 
        "Referer=", 
        "Snapshot=t1.inf", 
        "Mode=HTML", 
        EXTRARES, 
        "Url=/favicon.ico", "Referer=", ENDITEM, 
        LAST);
    lr_end_transaction("Login Page",LR_AUTO);

    
        
    a = atoi(lr_eval_string("{RUNNING_COUNT}"));
    lr_output_message("Machine Running count: %d", a);
    
    b = atoi(lr_eval_string("{STARTING_COUNT}"));
    lr_output_message("Machine STARTING count: %d", b);
    
    c = atoi(lr_eval_string("{HEALTH_OK_COUNT}"));
    lr_output_message("Machine HEALTH OK count: %d", c);
    
    e = atoi(lr_eval_string("{HEALTH_WARN_COUNT}"));
    lr_output_message("Machine HEALTH WARNING count: %d", e);
    
    x=a+b;
    lr_output_message("Machine Running and starting count: %d", x);
    y=c+e;
    lr_output_message("Machine Health OK and Warn count: %d", y);
        
    lr_start_transaction("Machine state Running");
    
    if ((x) == 11) {
        lr_output_message("All Machine states are running.");
        lr_end_transaction("Machine state Running", LR_PASS);        
        }
     else{
          lr_error_message("All Machine states are not running.Please logon to console to check further");
          lr_end_transaction("Machine state Running", LR_FAIL);
          return(0);
     }
    
    lr_start_transaction("Machine Health OK");
   if ((y) == 11) {
        lr_output_message("All Machine HEALTH is OK.");
        lr_end_transaction("Machine Health OK", LR_PASS);        
        }
     else{
          lr_error_message("All Machine HEALTH is not OK.Please logon to console to check further");
          lr_end_transaction("Machine Health OK", LR_FAIL);
          return(0);
     }

    
    return 0;
}

 

Please let me know how to get server name in output message itselt if State is not running or Health is not OK itselt.

0 Likes
Highlighted
Acclaimed Contributor.. Acclaimed Contributor..
Acclaimed Contributor..

Re: Vugen scripting

Thanks for letting us know that you are using Web HTML protocol and C-scripting. It look like you are querying a Oracle WebLogic API for server status. Reading the referred page I see that you can get your output of this API in XML, JSON or HTML (default).

Using XML/json might make your live more easy because LR has functions to examine the message content in detail. Just start reading the documentation. (lr_json_*() or lr_xml_*())

When you want to stick with HTML response type examine the HTML structure and use functions like lr_reg_save_param_ex() or lr_reg_save_param_regexp() with option "Ord=ALL" to store references to all values per type (you need three in this case; one for name, status and health) loop  over the responses with lr_paramarr*() functions.

Success,

Erik

 

P.S.

The referred page contains also python script examples. That might be more convenient for this kind of tasks. Esp when you can 'redirect' the output at intervals to (telegraf) InfluxDB with Grafana to build dashboards.

Signature:
Reward community members who take time to respond and help.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.