Google
 

Trailing-Edge - PDP-10 Archives - SRI_NIC_PERM_SRC_3_19910112 - utilities/idly.mac
There are no other files named idly.mac in the archive.
	TITLE IDLY
	SUBTTL MRC
	SEARCH MACSYM,MONSYM

A=1				; JSYS ACs
B=2
C=3
D=4
I=5				; index into line table
PC=13

LINTAB:	0			; currently snarl at no lines
LINSIZ==.-LINTAB		; length of table

DETCHK:	BLOCK 1			; when to zap detached jobs
NVTCHK:	BLOCK 1			; when to zap NVT's
TIMCHK:	BLOCK 1			; when to do a time check
JOBBLK:	BLOCK .JIUNO+1		; where to store GETJI% data
JOBCTR:	BLOCK 1			; job counter

IDLY:	RESET%			; flush all I/O
	SETZM TIMCHK		; do checks now
	SETZM NVTCHK
	SETZM DETCHK
	MOVEI A,.FHSLF		; enable all privileges
	SETOB B,C
	EPCAP%
	HRROI A,.JOBNA		; get how many jobs on this system
	GETAB%
	 MOVNI A,^D80		; assume 80 jobs just in case
	HRLZS A			; put count in LH, 0 in RH
	ADJSP A,1		; skip over SYSJOB
	MOVEM A,JOBCTR		; save for later
IDLY0:	SOSLE TIMCHK		; time for a time check?
	IFSKP.
	  MOVEI ^D30		; next check is 30 minutes from now
	  MOVEM TIMCHK
	  MOVEI A,.PRIOU	; time stamp output
	  SETO B,
	  SETZ C,
	  ODTIM%
	   ERJMP .+1
	  TMSG < IDLY: 30 minute time check and all is well...
>
	ENDIF.
	MOVSI I,-LINSIZ		; set up loop pointer
	DO.
	  MOVE A,LINTAB(I)	; get line number we're interested in
	  IORI A,.TTDES		; make a terminal designator
	  MOVE B,[-<.JIUNO+1>,,JOBBLK]	; # of words,,where data goes
	  MOVEI C,.JIJNO	; starting at job number
	  GETJI%
	  IFNJE.
	    SKIPG A,JOBBLK+.JIJNO ; get job number this user
	    IFSKP.
	      IDLE%		; see how long she's been idle
	      IFNJE.
	        CAMGE A,[^D20*^D60*^D1000] ; job idle for more than 20 minutes?
	        IFSKP.
		  IDIV A,[^D10*^D60*^D1000] ; get mins from 10 minute interval
		  CAIL B,^D60*^D1000 ; at a 10 minute interval?
		  IFSKP.
		    MOVE A,LINTAB(I) ; get line # again
		    IORI A,.TTDES
		    HRROI B,[ASCIZ/
[From SYSTEM: You have been idle for over 20 minutes.  Please log off.]
/]
		    TTMSG%	; barf at her
		     ERJMP .+1
		  ENDIF.
		ENDIF.
	      ENDIF.
	    ENDIF.
	  ENDIF.
	  AOBJN I,TOP.		; continue looking
	ENDDO.
	SOSLE NVTCHK		; time for an NVT check?
	IFSKP.
	  MOVEI ^D15		; next check is 15 minutes from now
	  MOVEM NVTCHK
	  MOVX A,TCP%NT		; get TVT function
	  STAT%
	  IFNJE.
	    MOVE C,B		; get pointer in C
	    JSP PC,NVTFRE	; free Internet NVT's
	  ENDIF.
	  MOVEI A,.GTNSZ	; get AOBJN pointer to NVT's in C
	  GTNCP%
	  IFNJE.
	    JSP PC,NVTFRE	; free ARPANET NVT's
	  ENDIF.
	  MOVE A,[SIXBIT/PUPPAR/]
	  SYSGT%		; get -nbr,,1st Pup NVT
	  CAIN B,0
	  IFSKP.
	    MOVE C,A		; get pointer in C
	    JSP PC,NVTFRE	; free Pup NVT's
	  ENDIF.
	ENDIF.
	SOSLE DETCHK		; time for a detached jobs check?
	IFSKP.
	  MOVEI ^D5		; next check is 5 minutes from now
	  MOVEM DETCHK
	  MOVE I,JOBCTR		; get pointer to jobs
	  DO.
	    MOVEI A,(I)		; get TTY number for this job
	    MOVE B,[-<.JIUNO+1>,,JOBBLK]; # of words,,where data goes
	    MOVEI C,.JIJNO
	    GETJI%
	    IFNJE.
	      SKIPL JOBBLK+.JITNO ; is user detached?
	      IFSKP.
		IDLE%		; yes, look at job's idle time
		IFNJE.
		  CAMGE A,[3*^D60*^D60*^D1000] ; idle more than 3 hours?
		  IFSKP.
		    MOVEI A,(I)	; yes, time to kill this luser
		    LGOUT%
		    IFNJE.
		      MOVEI A,.PRIOU ; time stamp output
		      SETO B,
		      SETZ C,
		      ODTIM%
		       ERJMP .+1
		      TMSG < IDLY: Killed three-hour old detached job >
	 	      MOVEI A,.PRIOU ; log job number
		      MOVEI B,(I)
		      MOVEI C,^D10
		      NOUT%
		       ERJMP .+1
		      TMSG <, user >
		      MOVEI A,.PRIOU
		      MOVE B,JOBBLK+.JIUNO
		      DIRST%
		       ERJMP .+1
		      TMSG <
>
		    ENDIF.
		  ENDIF.
		ENDIF.
	      ENDIF.
	    ENDIF.
	    AOBJN I,TOP.	; try next job
	  ENDDO.
	ENDIF.
	MOVE A,[^D60*^D1000]	; go to sleep for a minute
	DISMS%
	JRST IDLY0		; start all over

NVTFRE:	DO.
	  MOVEI A,.TTDES(C)	; get designator for this NVT
	  ASND%			; try to assign it
	  IFNJE.
	    RELD%		; now deassign it
	     ERJMP .+1		; shouldn't happen, but...
	  ENDIF.
	  AOBJN C,TOP.		; try next NVT
	ENDDO.
	JRST (PC)		; return

	END IDLY