📄 genwl.rxp
字号:
"more processes running on this machine than were" say " defined in" workloadScript end else if handle.0 < machine.i.!Process.0 then do say "Warning: There were" (machine.i.!Process.0 - handle.0), "less processes running on this machine than were" say " defined in" workloadScript end do j = 1 to handle.0 call STAFSubmit machine.i.!Name, "PROCESS", "QUERY HANDLE", handle.j if RESULT \= 0 then do say "Error querying process handle," handle.j", on machine,", machine.i.!Name", RC:" RESULT if STAFResult \= "" then say "Additional Info:" STAFResult ITERATE end parse var STAFResult . ': ' . (LF), . ': ' handle.j.!Name (LF), . ': ' handle.j.!Title (LF), . ': ' . (LF), . ': ' handle.j.!Command (LF), . ': ' handle.j.!Parms (LF), . ': ' handle.j.!WorkDir (LF), . ': ' . (LF), . ': ' handle.j.!StartDate (LF), . ': ' handle.j.!StartTime (LF), . ': ' handle.j.!EndDate (LF), . ': ' handle.j.!EndTime (LF), . ': ' handle.j.!RC (LF) call StripCR("handle.j.!Name") call StripCR("handle.j.!Title") call StripCR("handle.j.!Command") call StripCR("handle.j.!Parms") call StripCR("handle.j.!WorkDir") call StripCR("handle.j.!StartDate") call StripCR("handle.j.!StartTime") call StripCR("handle.j.!EndDate") call StripCR("handle.j.!EndTime") call StripCR("handle.j.!RC") /* Debug: Terse info about handle say handle.j'|'handle.j.!Name'|'handle.j.!Title'|' ||, handle.j.!Command'|'handle.j.!Parms'|'handle.j.!WorkDir'|' ||, handle.j.!StartDate'-'handle.j.!StartTime'|' ||, handle.j.!EndDate'-'handle.j.!EndTime'|'handle.j.!RC */ handle.j.!Monitor = "GenWL internal error" call STAFSubmit machine.i.!Name, "MONITOR",, "QUERY MACHINE" STAFWrapData(machine.i.!Name), "HANDLE" handle.j if RESULT = 2 then do handle.j.!Monitor = "Monitor not available on this machine" end else if RESULT = 17 then do handle.j.!Monitor = "No monitor information available for this", "process" end else if RESULT \= 0 then do handle.j.!Monitor = "Monitor Query error, RC:" RESULT if STAFResult \= "" then handle.j.!Monitor = handle.j.!Monitor"," STAFResult end else handle.j.!Monitor = STAFResult if handle.j.!EndDate = "" then do say handle.j"("handle.j.!Name") -" handle.j.!Monitor end else do say handle.j"("handle.j.!Name") - Completed at", handle.j.!EndDate"-"handle.j.!EndTime", RC:" handle.j.!RC end end /* for each handle */ end /* for each machine */ RETURN 0/* End of HandleQuery *//*******************************************************//* HandleFree - Handles freeing all the processes data *//*******************************************************/HandleFree: do i = 1 to machine.0 if UseItem("MACHINE", machine.i.!Name) = 0 then do if verboseMode then say "Bypassing machine:" machine.i.!Name ITERATE end if \quietMode then say "Processing machine:" machine.i.!Name call STAFSubmit machine.i.!Name, "PROCESS",, "QUERY WORKLOAD" STAFWrapData(workload) if RESULT \= 0 then do say "Error querying processes on machine," machine.i.!Name",", "RC:" RESULT if STAFResult \= "" then say "Additional Info:" STAFResult ITERATE end parse var STAFResult . (LF) . (LF) data handle.0 = 0 do while data \= "" handle.0 = handle.0 + 1 handleIndex = handle.0 parse var data handle.handleIndex . (LF) data end if handle.0 > machine.i.!Process.0 then do say "Warning: There were" (handle.0 - machine.i.!Process.0), "more processes running on this machine than were" say " defined in" workloadScript end else if handle.0 < machine.i.!Process.0 then do say "Warning: There were" (machine.i.!Process.0 - handle.0), "less processes running on this machine than were" say " defined in" workloadScript end call STAFSubmit machine.i.!Name, "PROCESS",, "FREE WORKLOAD" STAFWrapData(workload) if RESULT \= 0 then do say "Error freeing processes on machine," machine.i.!Name",", "RC:" RESULT if STAFResult \= "" then say "Additional Info:" STAFResult ITERATE end end /* for each machine */ RETURN 0/* End of HandleFree *//*****************************************************************************//* UseItem - Determines if a certain machine or process should be used based *//* on the machine and process include/exclude lists *//* *//* Accepts: The type of item (Machine or Process) *//* The item to check *//* *//* Returns: 0, if the item should NOT be used *//* >1, if the item should be used *//*****************************************************************************/UseItem: PROCEDURE EXPOSE processInclude. processExclude. machineInclude., machineExclude. parse arg type, item if WORDPOS(TRANSLATE(type), "MACHINE PROCESS") = 0 then RETURN 0 item = TRANSLATE(item) if VALUE(type"Include.0") > 0 then doInclude = 0 else doInclude = 1 do i = 1 to VALUE(type"Include.0") while doInclude = 0 testItem = TRANSLATE(VALUE(type"Include.i")) if testItem = item then doInclude = 1 if RIGHT(testItem, 1) = '*' then do if ABBREV(item, LeftBut(testItem, 1)) then doInclude = 1 end end do i = 1 to VALUE(type"Exclude.0") while doInclude = 1 testItem = TRANSLATE(VALUE(type"Exclude.i")) if testItem = item then doInclude = 0 if RIGHT(testItem, 1) = '*' then do if ABBREV(item, LeftBut(testItem, 1)) then doInclude = 0 end end RETURN doInclude/* End of UseItem *//*************************************************************//* StripCR - Strips a CR off the end of the variable's value *//* *//* Accepts: The name of the variable to fix *//* *//* Returns: 0 *//*************************************************************/StripCR: parse arg StripCR_VarName StripCR_VarValue = VALUE(StripCR_VarName) if RIGHT(StripCR_VarValue, 1) = CR then do call VALUE StripCR_VarName,, SUBSTR(StripCR_VarValue, 1, LENGTH(StripCR_VarValue) - 1) end RETURN 0/* End of StripCR *//**************************************************//* PrintUsage - prints usage info for the program *//**************************************************/PrintUsage: PROCEDURE parse arg full say say "GenWL - Generic WorkLoad processor" say "Version 1.21" say say "Usage: GenWL <WorkLoad filename> -<Start[:<Actions>] | Stop | Query |", "Free>" say " [-<Include | Exclude>:<MACHINE | PROCESS>:<List>]" say " [-Quiet | -Verbose]" if full = '' then do say say "For more help, enter 'GenWL -?'" RETURN 0 end say say "where," say say "<WorkLoad filename> is the name of a Generic WorkLoad configuration" say "file. The default extension is .gwl." say say "-Start will start the workload defined in <WorkLoad filename>. This can" say "be modified by only specifying that only certain actions be taken. The" say "The valid actions are the following:" say say " GlobalVar - Causes global variables to be set" say " MachineVar - Causes machine variables to be set" say " Var - Causes GlobalVar and MachineVar actions to occur" say " Process - Causes processes to be executed" say " All - Causes GlobalVar, MachineVar, and Process actions to", "occur" say say " The default action is All" say say "-Stop will stop the workload defined in <WorkLoad filename>" say say "-Query will display the status of the the workload defined in" say "<WorkLoad filename>." say say "-Free will free the completion data for the workload defined in" say "<WorkLoad filename>." say say "-Quiet suppresses the display off all informational messages" say say "-Include and -Exclude cause the specified machines or processes to be" say "used or ignored. If a machine is process is specified in both an" say "-Include and -Exclude list, then the machine or process is excluded." say "The default is for all machines and processes to be used." say say "<List> is a command seperated list of machines or processes. Note," say "the * wildcard is allowed at the end of a machine or process. For" say 'example, "ev4a,ev3d,ev2*" or "Startup,Config,FileSys*"' say say say "Examples:" say say "In the following examples the workload definition is specified in the" say "file MyWork.gwl." say say "To start the workload, use the command" say say " GenWL MyWork -start" say say "To stop the workload on machines client1 and client2 only, use the", "command" say say " GenWL MyWork -stop -include:machine:client1,client2" say say "To set the global and machine variables only on machines client3 and" say "client5, use the command" say say " GenWL MyWork -start:var -include:machine:client3,client5" say say "To only start the Ogre1 processes in the workload without setting the" say "machine and global variables, use the command" say say " GenWL MyWork -start:process -include:process:Ogre1" RETURN 0/* End of PrintUsage *//*****************************************************************//* ParseCommandLine - Parses and verifies the command line parms *//*****************************************************************/DoParseCommandLine: call InitCommandLineParser 1 call AddCommandLineOption "Start", 1, "ALLOWED" call AddCommandLineOption "Stop", 1, "NO" call AddCommandLineOption "Query", 1, "NO" call AddCommandLineOption "Free", 1, "NO" call AddCommandLineOption "Debug" call AddCommandLineOption "UseHandle" call AddCommandLineOption "Quiet", 1, "NO" call AddCommandLineOption "Verbose", 1, "NO" call AddCommandLineOption "Include", 0, "YES" call AddCommandLineOption "Exclude", 0, "YES" call AddCommandLineGroup "Start Stop Query Free", 1, 1 call AddCommandLineGroup "Quiet Verbose", 0, 1 call ParseCommandLine commandline if RESULT \= 0 then RETURN RESULT if CommandLineNumArgs() = 0 then do say say "You must specify the <WorkLoad filename>" RETURN 1 end workloadScript = CommandLineArgValue(1) if POS('.', workloadScript) = 0 then workloadScript = workloadScript || ".gwl" quietMode = CommandLineOptionTimes("Quiet") verboseMode = CommandLineOptionTimes("Verbose") processInclude.0 = 0 processExclude.0 = 0 machineInclude.0 = 0 machineExclude.0 = 0 do i = 1 to CommandLineOptionTimes("Include") thisSpec = CommandLineOptionValue("Include", i) parse var thisSpec thisType ':' thisList thisType = TRANSLATE(thisType) if (WORDPOS(thisType, "MACHINE PROCESS") = 0) | thisList = "" then do say "Invalid include list:" thisSpec RETURN 1 end call BuildStemFromList "include.", thisList, "," do j = 1 to include.0 include.j = STRIP(include.j) if StemPos(include.j, thisType"Include.") = 0 then call AddToStem thisType"Include.", include.j end end do i = 1 to CommandLineOptionTimes("Exclude") thisSpec = CommandLineOptionValue("Exclude", i) parse var thisSpec thisType ':' thisList thisType = TRANSLATE(thisType) if (WORDPOS(thisType, "MACHINE PROCESS") = 0) | thisList = "" then do say "Invalid exclude list:" thisSpec RETURN 1 end call BuildStemFromList "exclude.", thisList, "," do j = 1 to exclude.0 exclude.j = STRIP(exclude.j) if StemPos(exclude.j, thisType"Exclude.") = 0 then call AddToStem thisType"Exclude.", exclude.j end end startGlobalVars = 0 startMachineVars = 0 startProcesses = 0 startList = TRANSLATE(CommandLineOptionValue("Start")) if startList = "" then startList = "ALL" call BuildStemFromList "list.", startList, "," do i = 1 to list.0 thisItem = STRIP(list.i) if WORDPOS(thisItem, "GLOBALVAR MACHINEVAR VAR PROCESS ALL") = 0 then do say "Invalid start option," thisItem", specified" RETURN 1 end if WORDPOS(thisItem, "GLOVALVAR VAR ALL") \= 0 then startGlobalVars = 1 if WORDPOS(thisItem, "MACHINEVAR VAR ALL") \= 0 then startMachineVars = 1 if WORDPOS(thisItem, "PROCESS ALL") \= 0 then startProcesses = 1 end debugParse = 0 debugLex = 0 debugSym = 0 debugExec = 0 debugNoRun = 0 if CommandLineOptionTimes("Debug") \= 0 then do debugparm = TRANSLATE(CommandLineOptionValue("Debug")) do i = 1 to LENGTH(debugparm) option = SUBSTR(debugparm,i,1) select when option = 'L' then debugLex = 1 when option = 'P' then debugParse = 1 when option = 'S' then debugSym = 1 when option = 'E' then debugExec = 1 when option = 'N' then debugNoRun = 1 otherwise say "Skipping unknown debug option '"option"'" end end end /* end if debugging */ RETURN 0/* End of ParseCommandLine *//*********************//* Catch errors here *//*********************/TrapHandler: say "REXX error" rc 'in line' sigl':' ERRORTEXT(rc) say SOURCELINE(sigl) say "Unregistering with STAF" call STAFUnRegister EXIT 1/* End of TrapHandler *//********************************************//* Now we imbed the other functions we need *//********************************************/#From CLParser Import All#From Misc Import BuildStemFromList AddToStem StemPos LeftBut#From STAFUtil Import STAFWrapData#From Lex Import All#From Parse Import All#From GenWLParse Import All
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -