home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: OtherApp / OtherApp.zip / rm2app2.zip / rm2app2.cmd < prev    next >
OS/2 REXX Batch file  |  1995-04-08  |  6KB  |  205 lines

  1. /***************************************/
  2. /* Osrm2 Lite Rexx Extension           */
  3. /* Version 3.0                         */
  4. /* (c) 1993,1995 C.O.L. Systems Inc.   */
  5. /* All Rights Reserved                 */
  6. /* Application Process Sample Proc 2   */
  7. /***************************************/
  8.  
  9. Data1. = "";         /* This is our data stem. Assumes one file input*/
  10.  
  11. Parse Arg   MyFile   /* Parse the file name on input to the proc     */
  12.  
  13. /************************/
  14. /* Load the extension   */
  15. /************************/
  16.  
  17. if RxFuncQuery('Rm2LoadFunctions') <> 0 then do
  18.    rcy = RxFuncAdd('Rm2LoadFunctions','RM2REXXL','Rm2LoadFunctions')
  19.    if rcy = 0 then do
  20.       rcy = Rm2LoadFunctions()
  21.       if rcy > 0 then
  22.          signal BadLoad;
  23.       end;
  24.    else do
  25.       signal BadAdd;
  26.       end;
  27.    end;
  28.  
  29.    say;
  30.    do count = 1 to 7
  31.       say   sourceline(count);
  32.       end;
  33.    say;
  34.    say "Reading records, please wait...";
  35.  
  36.    signal on HALT name ExceptionCalled;      /* SETUP EXCEPTION HANDLERS */
  37.    signal on ERROR name ExceptionCalled;     /* SETUP EXCEPTION HANDLERS */
  38.    signal on FAILURE name ExceptionCalled;   /* SETUP EXCEPTION HANDLERS */
  39.  
  40.  
  41. /**************************/
  42. /* Load the file and stem */
  43. /**************************/
  44.  
  45. reference = Rm2OpenFile(MyFile,"Data1.");
  46.  
  47. if reference == 0 then
  48.    signal BadOpen;
  49.  
  50. /* If the load is ok, and data originated with the AppMon tool   */
  51.  
  52. if Data1.Creator == 1 then do
  53.  
  54.    /* Supplied by originator  */
  55.  
  56.    say;
  57.    say "Data was created by "Data1.Title" from file "MyFile;
  58.  
  59.    /* While there are records to be read  */
  60.  
  61.    do while Rm2GetRecord( "Data1." , reference )
  62.  
  63.       /* For each application in the application list */
  64.  
  65.       do appslook = 1 to Data1.Records.Applications
  66.  
  67.          say   ;
  68.          say   ;
  69.          say   'Process Name = 'Data1.Records.Applications.appslook.Name,
  70.                'Date :' Rm2Date('U',Data1.Records.0.TDS),
  71.                '  Time :' Rm2Time('N',Data1.Records.0.TDS) ;
  72.          say   'Tid   Dispatch       Busy%     TimeRun  PageFaults    PageWait     FileWait';
  73.          say   '---------------------------------------------------------------------------';
  74.  
  75.          stotal = 0;
  76.          ttotal = 0;
  77.          cpgflt = 0;
  78.          tpgtm  = 0;
  79.          tfltm  = 0;
  80.          ttbsy  = 0;
  81.          tttic  = 0;
  82.  
  83.          /* For each record in the stem*/
  84.  
  85.          do count = 0 to Data1.Records
  86.  
  87.             /* For each non 0 thd group   */
  88.  
  89.             if Data1.Records.count.THD > 0 then do
  90.  
  91.                do tcount = 1 to Data1.Records.count.THD
  92.  
  93.                   dataRef = 'Data1.Records.'||count||'.THD.'||tcount||'.Pid';
  94.  
  95.                   /* For each thread that has a matching process ID  */
  96.                   /* display measurements and calculations           */
  97.  
  98.                   if Data1.Records.Applications.appslook.PID == value(dataRef) then do
  99.                      dataRef = 'Data1.Records.'||count||'.THD.'||tcount;
  100.                      tbsy    = value(dataRef||'.tmRun');
  101.                      ttbsy   = ttbsy + tbsy;
  102.  
  103.                      if Data1.Records.count.MT > 0 then
  104.                         tbsy    = (tbsy / Data1.Records.count.MT) * 100.0;
  105.                      else
  106.                         tbsy    = 0.0;
  107.  
  108.                      tttic   = tttic + Data1.Records.count.MT;
  109.  
  110.                      stotal  = stotal + value(dataRef||'.ctSched');
  111.                      ttotal  = ttotal + value(dataRef||'.tmRun');
  112.                      cpgflt  = cpgflt + value(dataRef||'.ctFaults');
  113.                      tpgtm   = tpgtm  + value(dataRef||'.tmFaults');
  114.                      tfltm   = tfltm  + value(dataRef||'.tmFileWait');
  115.  
  116.                      say   format( value(dataRef||'.Tid') , 3)||' ',
  117.                            format( value(dataRef||'.ctSched') , 9),
  118.                            format( tbsy , 8,2),
  119.                            format( value(dataRef||'.tmRun') , 8,2)||' ',
  120.                            format( value(dataRef||'.ctFaults'),10),
  121.                            format( value(dataRef||'.tmFaults'),8,2)||' ',
  122.                            format( value(dataRef||'.tmFileWait'),8,2);
  123.                      end;
  124.                   end;
  125.                end;
  126.             end;
  127.  
  128.          if tttic > 0.0 then
  129.             ttbsy = (ttbsy / tttic) * 100.0;
  130.          else
  131.             ttbsy = 0.0;
  132.  
  133.          say   '---------------------------------------------------------------------------';
  134.          say   'Tot.',
  135.                format( stotal , 9),
  136.                format( ttbsy , 8,2),
  137.                format( ttotal , 8,2)||' ',
  138.                format( cpgflt , 10),
  139.                format( tpgtm,8,2)||' ',
  140.                format( tfltm,8,2);
  141.          end;
  142.  
  143.       end;
  144.  
  145.       rcx = Rm2CloseFile( 'Data1.', reference );
  146.  
  147.    end;
  148.  
  149.    
  150.  
  151. /* Report a file access error  */
  152.  
  153. else do
  154.    say "Error in file set = "rcx;
  155.    if Data1.Creator <> 1 then
  156.     say 'Not a AppMon log!';
  157.    end;
  158.  
  159. /* Release the extension   */
  160.  
  161. rcx = Rm2DropFunctions();
  162. call RXFUNCDROP 'RM2LOADFUNCTIONS';
  163.  
  164. exit;
  165.  
  166. /****************************************************/
  167. /* Error opening the file caused a problem with proc*/
  168. /****************************************************/
  169.  
  170. BadOpen:
  171.  
  172.    say   "Error opening file";
  173.  
  174. exit;
  175.  
  176. /****************************************************/
  177. /*  Error in syntax occured somewhere here          */
  178. /****************************************************/
  179.  
  180. BadAdd:
  181.  
  182.    say   'Error Adding Osrm2 Rexx Function Loader';
  183.  
  184. exit;
  185.  
  186. BadLoad:
  187.  
  188.    say   'Error Loading Osrm2 Rexx Functions';
  189.  
  190. exit;
  191.  
  192. /***************************************************/
  193. /* Exception handler for insuring process cleanup  */
  194. /***************************************************/
  195.  
  196. ExceptionCalled :
  197.  
  198.    say "Exception Reached";
  199.         r = Rm2Exception();
  200.  
  201.    rcx = Rm2DropFunctions();
  202.    call RXFUNCDROP 'RM2LOADFUNCTIONS';
  203.  
  204. exit;
  205.