$! CHECK_PROCESSES V1.50 $! Desc: $! Procedure to make sure that all processes that should be $! running are. Also make sure they were started by the correct username. $! $! Load the database from text file $! which will set the "number of passes" field to zero. $! $! Setup: $! Edit TASM$COM:CHECK_PROCESSES.DAT to contain the processes you want $! to check for. $! $! $! If we are not already executing as a detached process $! then do it $! $ if f$mode() .eqs. "OTHER" then goto SKIP $ run/detach sys$system:loginout.exe - /input=tasm$com:check_processes.com - /output=tasm$scratch:check_processes.log - /process_name="" - /UIC=[1,4] $ EXIT $! $SKIP: $ @TASM$COM:TASM_MENUSYM $ interval = "00:30:00.00" !30 minutes $ set noverify $ set noon $ define sys$scratch tasm$scratch $INITIALIZE: $! Convert the process data base text file into an indexed file $ convert/fdl=TASM$COM:CHECK_PROCESSES TASM$COM:CHECK_PROCESSES.dat - TASM$COM:CHECK_PROCESSES.idx $ pass = 1 $! $NEXT_PASS: $ show time $ open/read/write db TASM$COM:CHECK_PROCESSES.idx $ context = "" $! $LOOP1: $ pid=f$pid(context) ! get process id of 1st proc. $ if pid .eqs. "" then goto DO_CHECK ! if last one $ prcname = f$edit(f$getjpi(pid,"PRCNAM"),"TRIM") $ username = f$edit(f$getjpi(pid,"USERNAME"),"TRIM") $ set message/nofac/nosev/noiden/notext ! disable error msgs $ read/key="''prcname'" db line ! read from database $ if $severity .gt. 1 then goto LOOP1 ! if not in db, get next $ set message/fac/sev/iden/text ! enable error msgs $ db_prcname = f$edit(f$element(0,"/",line),"TRIM") ! extract process name $ db_username =f$edit(f$element(1,"/",line),"TRIM") ! extract username $ if (username .eqs. db_username .AND. prcname .eqs. db_prcname) $ then $! Change to found, indicate by incrementing pass # $! Modify the db, so the last three characters indicate the $! number of passes through this command procedure. $! $! Any record in the db which is not marked with the current pass $! number did not meet the match criteria above, and thus either $! does not exist, or it running under the wrong username. $! $! Later in DO_CHECK we scan the entire db and report on any processes $! which do not have the correct pass number. $! $ pass_str=f$fao("!2UL",pass) !convert to 2 digit string $ line = f$extract(0,f$length(line)-3,line)+pass_str+"/" $ write/update db line $ endif $GOTO LOOP1 $DO_CHECK: $ close db $ open/read inp TASM$COM:CHECK_PROCESSES.idx $LOOP2: $ read/end=DONE inp line $ db_prcname = f$edit(f$element(0,"/",line),"TRIM") ! get process name $ db_username =f$edit(f$element(1,"/",line),"TRIM") ! get user name $! ! get last recorded pass number $ db_seen =f$integer(f$edit(f$element(2,"/",line),"TRIM")) $ if db_seen .ne. pass ! if .ne. current pass, signal it! $ then $ request/to=central- "''db_prcname' is not running under user ''db_username', please investigate." $ show time $ write sys$output - "''db_prcname' is not running under user ''db_username', please investigate." $ endif $goto LOOP2 ! check next process in db $DONE: $ close inp $ pass = pass + 1 ! next pass $ if pass .ge. 96 then goto INITIALIZE ! initialize before we reach 100 $ wait 'interval' ! hang out $ goto NEXT_PASS ! next one