From: CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 11-OCT-1990 19:08:15.12 To: MRGATE::"ARISIA::EVERHART" CC: Subj: Cheap WDOG for people who forget to logout Received: by crdgw1.ge.com (5.57/GE 1.73) id AA08421; Thu, 11 Oct 90 18:55:05 EDT Received: From UCBVAX.BERKELEY.EDU by CRVAX.SRI.COM with TCP; Thu, 11 OCT 90 13:57:24 PDT Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA02245; Thu, 11 Oct 90 13:26:25 -0700 Received: from USENET by ucbvax.Berkeley.EDU with netnews for info-vax@kl.sri.com (info-vax@kl.sri.com) (contact usenet@ucbvax.Berkeley.EDU if you have questions) Date: 11 Oct 90 19:10:09 GMT From: motcsd!dms!shepperd@apple.com (Dave Shepperd) Organization: Atari Games Inc., Milpitas, CA Subject: Cheap WDOG for people who forget to logout Message-Id: <1168@dms.UUCP> Sender: info-vax-request@kl.sri.com To: info-vax@kl.sri.com Someone asked about a cheap watchdog that will logout your terminal if you forget to logout yourself. This'll do the trick. It ain't bullet proof (just delete the process), but it might be all you need. $! ------------------ CUT HERE ----------------------- $ v='f$verify(f$trnlnm("SHARE_VERIFY"))' $! $! This archive created by VMS_SHARE Version 7.2-007 22-FEB-1990 $! On 11-OCT-1990 11:54:46.45 By user SHEPPERD $! $! This VMS_SHARE Written by: $! Andy Harper, Kings College London UK $! $! Acknowledgements to: $! James Gray - Original VMS_SHARE $! Michael Bednarek - Original Concept and implementation $! $! TO UNPACK THIS SHARE FILE, CONCATENATE ALL PARTS IN ORDER $! AND EXECUTE AS A COMMAND PROCEDURE ( @name ) $! $! THE FOLLOWING FILE(S) WILL BE CREATED AFTER UNPACKING: $! 1. WDOG.COM;22 $! $set="set" $set symbol/scope=(nolocal,noglobal) $f=f$parse("SHARE_TEMP","SYS$SCRATCH:.TMP_"+f$getjpi("","PID")) $e="write sys$error ""%UNPACK"", " $w="write sys$output ""%UNPACK"", " $ if f$trnlnm("SHARE_LOG") then $ w = "!" $ ve=f$getsyi("version") $ if ve-f$extract(0,1,ve) .ges. "4.4" then $ goto START $ e "-E-OLDVER, Must run at least VMS 4.4" $ v=f$verify(v) $ exit 44 $UNPACK: SUBROUTINE ! P1=filename, P2=checksum $ if f$search(P1) .eqs. "" then $ goto file_absent $ e "-W-EXISTS, File ''P1' exists. Skipped." $ delete 'f'* $ exit $file_absent: $ if f$parse(P1) .nes. "" then $ goto dirok $ dn=f$parse(P1,,,"DIRECTORY") $ w "-I-CREDIR, Creating directory ''dn'." $ create/dir 'dn' $ if $status then $ goto dirok $ e "-E-CREDIRFAIL, Unable to create ''dn'. File skipped." $ delete 'f'* $ exit $dirok: $ w "-I-PROCESS, Processing file ''P1'." $ if .not. f$verify() then $ define/user sys$output nl: $ EDIT/TPU/NOSEC/NODIS/COM=SYS$INPUT 'f'/OUT='P1' PROCEDURE Unpacker ON_ERROR ENDON_ERROR;SET(FACILITY_NAME,"UNPACK");SET( SUCCESS,OFF);SET(INFORMATIONAL,OFF);f:=GET_INFO(COMMAND_LINE,"file_name");b:= CREATE_BUFFER(f,f);p:=SPAN(" ")@r&LINE_END;POSITION(BEGINNING_OF(b)); LOOP EXITIF SEARCH(p,FORWARD)=0;POSITION(r);ERASE(r);ENDLOOP;POSITION( BEGINNING_OF(b));g:=0;LOOP EXITIF MARK(NONE)=END_OF(b);x:=ERASE_CHARACTER(1); IF g=0 THEN IF x="X" THEN MOVE_VERTICAL(1);ENDIF;IF x="V" THEN APPEND_LINE; MOVE_HORIZONTAL(-CURRENT_OFFSET);MOVE_VERTICAL(1);ENDIF;IF x="+" THEN g:=1; ERASE_LINE;ENDIF;ELSE IF x="-" THEN IF INDEX(CURRENT_LINE,"+-+-+-+-+-+-+-+")= 1 THEN g:=0;ENDIF;ENDIF;ERASE_LINE;ENDIF;ENDLOOP;t:="0123456789ABCDEF"; POSITION(BEGINNING_OF(b));LOOP r:=SEARCH("`",FORWARD);EXITIF r=0;POSITION(r); ERASE(r);x1:=INDEX(t,ERASE_CHARACTER(1))-1;x2:=INDEX(t,ERASE_CHARACTER(1))-1; COPY_TEXT(ASCII(16*x1+x2));ENDLOOP;WRITE_FILE(b,GET_INFO(COMMAND_LINE, "output_file"));ENDPROCEDURE;Unpacker;QUIT; $ delete/nolog 'f'* $ CHECKSUM 'P1' $ IF CHECKSUM$CHECKSUM .eqs. P2 THEN $ EXIT $ e "-E-CHKSMFAIL, Checksum of ''P1' failed." $ ENDSUBROUTINE $START: $ create 'f' X$ old_verify = f$verify(0) X$! This command file is intended to be SPAWNED as a watchdog. X$! If it is not spawned, it will just exit with a message. X$! It watches the CPU time, the buffered and unbuffered I/O count, X$! and all subprocesses. If there are less than 3 CPU ticks X$! in each scan period and no I/O (for all processes in the tree but us), X$! the master process is deleted, logging us off the system. X$! The scans occur once each minute. The number of scans with no apparent X$! activity (including the creation or deletion of subprocesses that X$! straddle a snapshot) is user selectable, defaulting to 45. X$! X$! It is intended to be fired up with this line in anyone's LOGIN.COM: X$! $ SPAWN/NOWAIT/NOLOG/NONOTIFY/IN=_NL: @WDOG `5B`5D X$! Notice: The /OUTPUT goes to CRT for the final warning messa Vge. X$! X$! It can now be started with @WDOG `5B`5D, interactively or from X$! a command file. X$! X$! Written on a V5.0 system, upgraded on a V5.2 (spawn environment different V!) X$ X$ X$ on warning then $exit $status X$ X$ bleep = " " X$ bleep`5B0,7`5D = 7 X$ bleep`5B8,7`5D = 13 X$ bleep`5B16,7`5D = 10 X$ debug := if 0 then $ X$ prodn := if 1 then $ X$ X$ god = f$getjpi("","master_pid") X$ us = f$getjpi("","PID") X$ mom = f$getjpi("","OWNER") X$`09tty = f$getjpi("","TERMINAL") X$`09godtty = f$getjpi(god,"TERMINAL") X$`09if us .eqs. god then $ goto fakeit X$`09if mom .eqs. god then $ goto doit X$ Copy sys$input sys$error X%WATCHDOG-?-TOOFARAWAY, This must be done from the root process to be effect Vive. X$ exit %x10000001 + 0*(f$verify(old_verify)) X$ X$ X$fakeit:`09! We are our own man; we are the master PID; we must spawn. X$`09if f$mode() .nes. "INTERACTIVE" .or. godtty .eqs. "" - X`09`09then $ exit %x10000001 + 0*(f$verify(old_verify)) X$!`09`09'cuz we don't monitor batch or detached jobs X$ X$`09SPAWN/NOWAIT/NOLOG/NONOTIFY/IN=_NL: @'f$env("procedure")' X$ exit %x10000001 + 0*(f$verify(old_verify)) X$ X$ X$doit:`09`09! We are properly spawned, so do the actual watchdog. X$ pass_interval := 0:1:0 X$ all_of_them = 45 X$`09if f$type(p1) .eqs. "INTEGER" X$`09then X$`09`09if 'p1' .ge. 5 .and. 'p1' .le. 120 X$`09`09then X$`09`09`09all_of_them = 'p1' X$`09`09else X$ `09`09Copy sys$input sys$error X%WATCHDOG-?-BADPARAM, You may specify a number of minutes between 5 and 120. X%WATCHDOG-S-DEFAULTING, Using the normal default of 45 minutes of idle time. X$`09`09endif X$`09else X$`09`09if f$len(p1) .gt. 0`09! if he typed something... X$`09`09then X$ `09`09Copy sys$input sys$error X%WATCHDOG-?-BADPARAM, You may specify a number of minutes between 5 and 120. X-WATCHDOG-?-BADNUMBER, You may only specify the number of minutes as an inte Vger. X%WATCHDOG-S-DEFAULTING, Using the normal default of 45 minutes of idle time. X$`09`09endif X$`09endif X$ scans_to_go = all_of_them X$ X$! MAKE SURE WE ARE THE ONLY ONE (UNIQUE PROCESS NAME) X$ set noon X$ set message/notext/noseverity/nofacility/noident X$ set process/name='godtty'wdog X$ if .not. $status then $ stop/id=0 X$ set message/text/severity/facility/ident X$ set on X$ X$next_pass: X$ context = 0 X$next_pid: X$ current = f$pid(context) X$ if current .eqs. "" then $ goto end_of_pass X$ if f$getjpi(current, "MASTER_PID") .nes. god then $ goto next_pid X$ if current .eqs. us then $ goto next_pid X$ X$ if f$type(PID_'current') .eqs. "" then $ scans_to_go = all_of_them X$ if f$type(PID_'current') .eqs. "" then $ PID_'current' := 0,0,0,0 X$ prccnt = f$getjpi(current, "PRCCNT") X$ if current .eqs. mom then $ if prccnt .gt. 0 then $ prccnt = prccnt V - 1 X$ cputim = f$getjpi(current, "CPUTIM") X$ bufio = f$getjpi(current, "BUFIO") X$ dirio = f$getjpi(current, "DIRIO") X$ if prccnt .ne. f$element(0,",",PID_'current') then - X $ scans_to_go = all_of_them X$ if cputim .ge. (f$element(1,",",PID_'current') + 3) then - X $ scans_to_go = all_of_them X$ if bufio .ne. f$element(2,",",PID_'current') then - X $ scans_to_go = all_of_them X$ if dirio .ne. f$element(3,",",PID_'current') then - X $ scans_to_go = all_of_them X$ PID_'current' := 'prccnt','cputim','bufio','dirio' X$ X$ goto next_pid X$ X$ X$end_of_pass: X$ scans_to_go = scans_to_go - 1 X$ if scans_to_go .lt. 0 then $ goto jelly_blaster X$rewait: X$debug write sys$output "at REWAIT:" X$debug sho sym pid_* X$debug sho sym scans_to_go X$debug write sys$output "" X$ wait 'pass_interval' X$ goto next_pass X$ X$ X$jelly_blaster: X$ if scans_to_go .lt. -1 then $ goto drop_dead X$ write sys$output bleep, "Automatic logoff will occur in ", - X ( f$cvtime(pass_interval,"DELTA") - "0 " ), - X " unless you DO SOMETHING!!", bleep X$ goto rewait X$drop_dead: X$debug write sys$output "at DROP_DEAD:" X$debug sho sym pid_* X$debug sho sym scans_to_go X$ write sys$output bleep, "Automatic logoff enforced at ", - X f$edit(f$cvtime("+0", "ABSOLUTE"), "TRIM"), bleep X$prodn stop/id='god' X$ stop/id=0 ! if we live this long $ CALL UNPACK WDOG.COM;22 1914907277 $ v=f$verify(v) $ EXIT -- Dave Shepperd. shepperd@dms.UUCP or weitek!dms!shepperd Atari Games Corporation, 675 Sycamore Drive, Milpitas CA 95035. Nobody knows what I'm saying. I don't even know what I'm saying.