home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: SysTools / SysTools.zip / thes3000.exe / getobj.cmd next >
OS/2 REXX Batch file  |  1999-06-04  |  6KB  |  152 lines

  1. /* */
  2. /*==================================================================+
  3. |   This EXEC calls the theseus2 REXX DLLs Theseus0 and Theseus1.   |
  4. | Theseus0 is called for the RT2FindProcesses function.             |
  5. | Theseus1 is called for the RT2GetObjSummary function.             |
  6. +==================================================================*/
  7. trace o
  8.  
  9. /*==================================================================+
  10. |   Constats for type to obtain system,shared, or private objects.  |
  11. +==================================================================*/
  12. p_system    = 0;
  13. p_shared    = 1;
  14. p_private   = 2;
  15. Pid         = 1;
  16. Object_type = 2;
  17. secs        = 5;
  18. iterations  = 1;
  19. found       = false;
  20. pid_num     = false;
  21.  
  22. /*==================================================================+
  23. |   Parse the input arguements to upper case.                       |
  24. +==================================================================*/
  25. PARSE UPPER ARG p_pid p_type p_iterations p_secs
  26.  
  27. /*==================================================================+
  28. |   Check to see if any operand have been passed. If Not exit.      |
  29. +==================================================================*/
  30. IF p_pid = '' | p_pid = '?' THEN
  31. DO
  32.    SAY 'CMD file GETOBJ needs at least one input operand.'
  33.    SAY ''
  34.    SAY '  GETOBJ pid [object_type] [num_iterations] [num_secs]'
  35.    SAY ''
  36.    SAY 'Optional operands require the previous operand in order to work.'
  37.    SAY '   Where:'
  38.    SAY '     pid  - is the aplhanumeric name of the process to get data for.'
  39.    SAY '            If it is all decimal it will be treated as the pid.'
  40.    SAY '     object_type - is one of the following three:'
  41.    SAY '          private - indicates private object summary request for given pid name'
  42.    SAY '                    which is the DEFAULT. (Minimum letter is p)'
  43.    SAY '          shared  - indicates shared object summary request for given pid name.'
  44.    SAY '                    (Minimum is sh)'
  45.    SAY '          system  - indicates system object summary requested.'
  46.    SAY '                    (Minimum is sy)'
  47.    SAY '     num_iterations - is the number of data collections for this run.'
  48.    SAY '                      DEFAULT is 1 iteration.'
  49.    SAY '     num_secs       - is the number of seconds between interations.'
  50.    SAY '                      DEFAULT is 5 seconds.'
  51.    EXIT 999
  52. END
  53.  
  54. /*==================================================================+
  55. |   Check operand to see if any have been defaulted.                |
  56. +==================================================================*/
  57. IF p_secs \= '' THEN secs = STRIP(p_secs);
  58. IF p_iterations \= '' THEN iterations = p_iterations
  59. IF p_type = '' | ABBREV('PRIVATE',STRIP(p_type),1) = 1 THEN Object_type = p_private
  60. ELSE IF ABBREV('SHARED',STRIP(p_type),2) = 1 THEN Object_type = p_shared
  61. ELSE IF ABBREV('SYSTEM',STRIP(p_type),2) = 1 THEN Object_type = p_system
  62.  
  63. /*==================================================================+
  64. |   If p_pid data type is numeric then set flag so that we do not   |
  65. | scan process list.                                                |
  66. +==================================================================*/
  67. IF DATATYPE(p_pid) = 'NUM' THEN pid_num = true;
  68.  
  69. /*==================================================================+
  70. |   The following loads the necessary REXX functions and Theseus2   |
  71. | functions.                                                        |
  72. +==================================================================*/
  73. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  74. call SysLoadFuncs
  75.  
  76. call RxFuncAdd 'RT2LoadFuncs', 'THESEUS0', 'RT2LoadFuncs'
  77. rc = RT2LoadFuncs()
  78. IF rc \= 0 THEN Say 'RT2loadfuncs rc is = 'rc
  79.  
  80. call RxFuncAdd 'RT2LoadFuncs1', 'THESEUS1', 'RT2LoadFuncs1'
  81. rc = RT2LoadFuncs1()
  82. IF rc \= 0 THEN Say 'RT2loadfuncs1 rc is = 'rc
  83.  
  84. /*==================================================================+
  85. |   Get the current processes running in the system.                |
  86. | Loop through each process and find the one that we want.          |
  87. +==================================================================*/
  88. IF p_pid \= 'SYSTEM' THEN
  89. DO
  90.    IF pid_num = true THEN
  91.    DO
  92.       call RT2FindProcesses "pTable"
  93.  
  94.       DO i =1 TO pTable.0
  95.          PARSE UPPER VALUE pTable.i With Pid Parent NumThrd TaskName
  96.          IF p_pid = Pid THEN
  97.          DO
  98.             found = true;
  99.             LEAVE;
  100.          END
  101.       END
  102.    END
  103.    ELSE
  104.    DO
  105.       DO forever
  106.          call RT2FindProcesses "pTable"
  107.  
  108.          DO i =1 TO pTable.0
  109.             PARSE UPPER VALUE pTable.i With Pid Parent NumThrd TaskName
  110.             IF p_pid = TaskName THEN
  111.             DO
  112.                found = true;
  113.                LEAVE;
  114.             END
  115.          END
  116.          IF found = true THEN LEAVE
  117.          Call SysSleep 1
  118.       END
  119.    END
  120. END
  121. ELSE
  122. DO
  123.    found = true;
  124.    Object_type  = p_system;
  125. END
  126.  
  127. /*==================================================================+
  128. |   After all parms have been checked and a pid found then loop     |
  129. | for the number of iterations for the duration of seconds between  |
  130. | iterations.                                                       |
  131. +==================================================================*/
  132. if found = true THEN
  133. DO
  134.    DO i = 1 TO iterations BY 1
  135.       rc = RT2GetObjSummary( Pid , Object_type )
  136.       if rc = 0 THEN
  137.       DO
  138.          SAY 'Data collected for pid 'Pid' at 'time()', on 'date(Language)'.'
  139.          SAY ''
  140.          SAY ''
  141.          call SysSleep secs
  142.       END
  143.       ELSE
  144.       DO
  145.          SAY 'Return code 'rc 'from RT2GetObjectSummary.'
  146.          EXIT
  147.       END
  148.    END
  149. END
  150. SAY 'GETOBJ has terminated.  The time is 'time()', the date is 'date(Language)'.'
  151. EXIT
  152.