4 Replies Latest reply on Oct 17, 2013 10:53 AM by Flavio Bonacordi

    Add the LOCATION into a RaiseError custom message.

    Flavio Bonacordi

      Hi Community,

       

      I'm working with TMART for a while and developing a lot of scripts... Since the beggining I notice a need that I'm solving but I believe it's not the best way to solve it!

       

      I have four locations configured in TMART

       

      Dallas, Houston, Leatherhead and Singapore and I have one Execution server on each.

       

      When I create a monitor with a CUSTOM MEASURE, like a

       

      Measurestart("CNN");
       WebPageUrl("http://www.cnn.com");
      Measurestop("CNN");
      

       

      And I Raise and error when the total time is greater than 5 seconds.

       

      But when I'm visiting the MONITORING page in TMART, to have an overview about my monitors, if I don't "disable" the locations and refresh the report I can't compare the values. I mean.. If I visit the page with all four locations checked, the values will be combined.

       

      And I was looking for a way to have the values in a glance... so in my monitor, I had created an Project Attribute where I type the name of the location that will be running the monitor (but note that, in my opinion, is the worst way to do it).

       

      So, when I visit the MONITORING page to see the CUSTOM TIMERS I have the CCN - HOUSTON, CNN - DALLAS, CNN - LEATHERHEAD, CNN - SINGAPORE segregated in the same view.

       

      But, as I said, I don't belive this is the best way to do it. I was wondering if there is a way, into BDL code, to "read" the location name and add this location name into my Measure name and also into my RaiseError custom message.

       

      See the script below as example: This is how I'm doing today.

       

      Project Parameters Values: Location = Houston, Threshold = 5

       

      I would like to have a way to read the Location where the script is running and use this information into my code and remove the Project Attribute attLocation.

       

       

      // ----------------------------------------------------------------------
      // Recorded 8/14/2013 by BMC TM ART Recorder v4.2.0.5498
      // ----------------------------------------------------------------------
      // Rule set "ASP.NET ViewState"
      //  * Rule "Parse and Replace __VIEWSTATE"
      //  * Rule "Parse and Replace __EVENTVALIDATION"
      // ----------------------------------------------------------------------
      @codepage(1252)
      benchmark BMCTMARTRecorder
      use "WebAPI.bdh"
      
      dcluser
        user
          VUser
        transactions
          TInit           : begin;
          TMain           : 1;
      var
      dclrand
      dcltrans
        transaction TInit
        begin
          
          WebSetBrowser(WEB_BROWSER_MSIE7);
          WebModifyHttpHeader("Accept-Language", "en-US");
          //WebSetUserBehavior(WEB_USERBEHAVIOR_FIRST_TIME);
          //WebSetDocumentCache(true, WEB_CACHE_CHECK_SESSION);
        end TInit;
        transaction TMain
        var
          aURL       : array [60] of string(70);
          aTitle     : array [60] of string(40);
          sLocation  : string;
          nId        : number;
          sThreshold : string;
          fValue     : float;
          sMeasure   : string;
          sMessage   : string;
          
        begin   
          aURL[1]:="http://www.google.com";
           .
           .
           .
          aURL[60]:="http://www.cnn.com";
      
       
          aTitle[1]:="http://www.google.com";
           .
           .
           .
          aTitle[60]:="http://www.cnn.com";
       
         
          AttributeGetString("attLocation", sLocation, sizeof(sLocation));
          AttributeGetString("attThreshold", sThreshold, sizeof(sThreshold));
          SetEncoding("UTF-8");
          for nId:=1 to 60 do 
            MeasureStart(aTitle[nId]+"-"+sLocation);
            WebPageUrl(aURL[nId], aTitle[nId]);
            MeasureStop(aTitle[nId]+"-"+sLocation);
            
            MeasureSet(aTitle[nId]+"-"+sLocation,MEASURE_COUNTER_CUSTOMCOUNTER,number(sMeasure));
            MeasureGet(aTitle[nId]+"-"+sLocation,MEASURE_COUNTER_CUSTOMCOUNTER,MEASURE_KIND_LAST,fValue);
            
            if number(sMeasure) > number(sThreshold) then
              sMessage:="Website "+aTitle[nId]+ " URL="+aURL[nId]+" took "+sMeasure+" seconds to load completly at "+sLocation+". That is above the defined threshold of "+sThreshold+" seconds."
              RaiseError(CUSTOM_MESSAGE,sMessage,SEVERITY_ERROR);
            end;
            
          end;
          
        end TMain;