Citrix Monitoring Scripts

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Citrix Monitoring Scripts as PDF for free.

More details

  • Words: 638
  • Pages: 6
Citrix Monitoring Scripts The sample script used in document is “StarsIIPlus”. Group, Monitor and Transaction Name -Following is the code in the script strcat(sql, ", 'StarsIIPlus', 'StarsIIPlus_1', 'StarsIIPlus_01_AppLogin', "); In this StarsIIPlus is Group, StarsIIPlus_1 is monitor name, StarsIIPlus_01_AppLogin is transaction name Code to connect with Production, Staging and QA Database in Vuser Init Section – //lrd_open_connection(&Con1, LRD_DBTYPE_ODBC, "", "", "", "DSN=D060;UID=insbat;PWD=password;SERVER=D060;", Ctx1, 1, 0); //Dev DB //lrd_open_connection(&Con1, LRD_DBTYPE_ODBC, "", "", "", "DSN=P053;UID=insbat;PWD=password;SERVER=P053;", Ctx1, 1, 0); //Production DB //lrd_open_connection(&Con1, LRD_DBTYPE_ODBC, "", "", "", "DSN=P063;UID=insbat;PWD=bat_ins_p1;SERVER=P063;", Ctx1, 1, 0); //Prod Oracle 10g //lrd_open_connection(&Con1, LRD_DBTYPE_ODBC, "", "", "", "DSN=Q063;UID=insapp;PWD=app_ins_q1;SERVER=Q063;", Ctx1, 1, 0); //QA D Code in the beginning of Script before Vuser_init -typedef long time_t; long file_stream; time_t t; int intStatus; char *strStatus; double doubleDuration; char *SQLStatement; Continue the code in Vuser_init -vuser_init() { lrd_init(&InitInfo, DBTypeVersion); lrd_open_context(&Ctx1, LRD_DBTYPE_ODBC, 0, 0, 0); lrd_alloc_connection(&Con1, LRD_DBTYPE_ODBC, Ctx1, 0 /*Unused*/, 0); lrd_db_option(Con1, OT_ODBC_LOGIN_TIMEOUT, (void FAR const *)20, 0);

lrd_open_connection(&Con1, LRD_DBTYPE_ODBC, "", "", "", "DSN=P063;UID=insbat;PWD=bat_ins_p1;SERVER=P063;", Ctx1, 1, 0); //Prod Oracle 10g //lrd_open_connection(&Con1, LRD_DBTYPE_ODBC, "", "", "", "DSN=Q063;UID=insbat;PWD=bat_ins_q1;SERVER=Q063;", Ctx1, 1, 0); //QA Oracle 10g //lrd_open_connection(&Con1, LRD_DBTYPE_ODBC, "", "", "", "DSN=S063;UID=insbat;PWD=bat_ins_s1;SERVER=S063;", Ctx1, 1, 0); //Staging Oracle 10g return 0; } Code in the beginning of Script before Action – struct tm *today; char errorMsg[51]; char* getErrorMessage(int httpCode) { strcpy(errorMsg, ""); lr_output_message("Error Code here is %i", httpCode); if(httpCode >= 400 && httpCode < 500) { switch (httpCode) { case 400: strcpy(errorMsg, "400 - Bad Request"); break; case 401: strcpy(errorMsg, "401 - Unauthorized"); break; case 402: strcpy(errorMsg, "402 - Payment Required"); break; case 403: strcpy(errorMsg, "403 - Forbidden"); break; case 404: strcpy(errorMsg, "404 - Not Found"); break;

case 405: strcpy(errorMsg, "405 - Method Not Allowed"); break; case 406: strcpy(errorMsg, "406 - Not Acceptable"); break; case 407: strcpy(errorMsg, "407 - Proxy Authentication Required"); break; case 408: strcpy(errorMsg, "408 - Requet Time-Out"); break; case 409: strcpy(errorMsg, "409 - Conflict"); break; case 410: strcpy(errorMsg, "410 - Gone"); break; case 411: strcpy(errorMsg, "411 - Length Required"); break; case 412: strcpy(errorMsg, "412 - Precondition Failed"); break; case 413: strcpy(errorMsg, "413 - Request Entity Too Large"); break; case 414: strcpy(errorMsg, "414 - Request-URL Too Large"); break; case 415: strcpy(errorMsg, "415 - Unsupported Media Type"); break; case 500: strcpy(errorMsg, "500 - Internal Server Error");

break; case 501: strcpy(errorMsg, "501 - Not Implemented"); break; case 502: strcpy(errorMsg, "502 - Bad Gateway"); break; case 503: strcpy(errorMsg, "503 - Out of Resources"); break; case 504: strcpy(errorMsg, "504 - Gateway Time-out"); break; case 505: strcpy(errorMsg, "505 - HTTP Version not supported"); break; } } lr_output_message("Error Message = %s", errorMsg); return errorMsg; } Continue the code in Action -char sql[2048] = "begin INSAPP.P1112_INSIGHT_RATIONAL(SYSDATE, "; char a[20]; char b[20]; int httpReturnCode = 200; int Count; char *robot; robot = (char *) strupr(lr_get_host_name()); lr_think_time(5);

The Transaction will be like this – lr_start_transaction("StarsIIPlus_03_ViewSystemCalendar"); ctrx_key("c", MODIF_CONTROL); ctrx_sync_on_window("II+ System Calendar", ACTIVATE, 96, 257, 787, 294, "snapshot8", CTRX_LAST); doubleDuration = lr_get_transaction_duration("StarsIIPlus_03_ViewSystemCalendar"); intStatus = lr_get_transaction_status("StarsIIPlus_03_ViewSystemCalendar") == LR_FAIL ? -1 : 0; lr_end_transaction("StarsIIPlus_03_ViewSystemCalendar", LR_AUTO); After the Transaction ends Insert the following Code – strcpy(sql, "begin INSAPP.P1112_INSIGHT_RATIONAL(SYSDATE, "); strcpy(a, ""); strcpy(b, ""); sprintf(a, "%f", doubleDuration * 1000); sprintf(b, "%i", intStatus); lr_output_message("doubleDuration = %s", a); lr_output_message("Status output = %s", b); time(&t); today = (struct tm *) localtime(&t); strcat(sql, "'"); strcat(sql, robot); strcat(sql, "', "); if(intStatus < 0) { strcat(sql, "'Failed'"); strcat(sql, ", 'StarsIIPlus', 'StarsIIPlus_2', 'StarsIIPlus_02_SelectSchedule', "); strcat(sql, "'n/a' ,'"); strcat(sql, "Unable to see II+ Schedule * window."); strcat(sql, "'); end;"); } else { strcat(sql, "'Success'");

strcat(sql, ", 'StarsIIPlus', 'StarsIIPlus_2', 'StarsIIPlus_02_SelectSchedule', "); strcat(sql, a); strcat(sql, ", 'Success'); end;"); } lr_output_message("SQL = %s", sql); lrd_open_cursor(&Csr2, Con1, 0); lrd_stmt(Csr2, sql, -1, 1, 0, 0); lrd_db_option(Csr2, OT_ODBC_CURSOR_CLOSE, 0, 0); lrd_close_cursor(&Csr2, 0); // Lr_Exit will Stop current iteration, and go to the next iteration. if(intStatus != 0) { ctrx_key("F4_KEY", MODIF_ALT); ctrx_key("F4_KEY", MODIF_ALT); ctrx_disconnect_server(""); lr_exit (LR_EXIT_ITERATION_AND_CONTINUE, LR_AUTO); } lr_think_time(5); Code for Vuser_end – vuser_end() { lrd_close_connection(&Con1, 0, 0); lrd_free_connection(&Con1, 0 /*Unused*/, 0); lrd_close_context(&Ctx1, 0, 0); return 0; }

Related Documents

Citrix Monitoring Scripts
November 2019 7
Scripts
November 2019 27
Scripts
June 2020 14
Scripts
October 2019 32
Scripts
November 2019 27