.TITLE SYSTEM_SNAPSHOT ; ; Take a snapshot of processes active on system ; and output to a file SNAPSHOT.DAT pseudo process delete ; accounting records for those processes found to be active ; $ACRDEF $JBCMSGDEF $JPIDEF $PRVDEF $SSDEF .ENABLE DEBUG .PAGE .SUBTITLE STORAGE,PURGE_DATA .PSECT PURE_DATA,RD,NOWRT,SHR,NOEXE,LONG A=0 B=0 .MACRO SB V .IF GE, B=B!<1@> .IFF A=A!<1@V> .ENDC .ENDM SB PRV$V_WORLD SB PRV$V_SYSPRV PRIV_MASK: .LONG A,B ENABLE_FLAG: .LONG 1 .MACRO ENT ITEM,BUF,LEN,RTN .IF NB,LEN .WORD LEN .IFF .IF NB,ITEM .WORD 4 .IFF .WORD 0 .ENDC .ENDC .IF NB,ITEM .WORD ITEM .IFF .WORD 0 .ENDC .IF NB,BUF .LONG BUF .IFF .LONG 0 .ENDC .IF NB,RTN .LONG RTN .IFF .LONG 0 .ENDC .ENDM .ALIGN LONG ITEMLIST: ENT JPI$_ACCOUNT,ACCOUNT,8,ACCOUNT_STRING ENT JPI$_BUFIO,BUFIO ENT JPI$_CPUTIM,CPUTIM ENT JPI$_DIRIO,DIRIO ENT JPI$_IMAGECOUNT,IMAGECOUNT ENT JPI$_JOBTYPE,JOBTYPE ENT JPI$_LOGINTIM,LOGINTIM,8 ENT JPI$_OWNER,OWNER ENT JPI$_PAGEFLTS,PAGEFLTS ENT JPI$_PID,PID ENT JPI$_PRI,PRI ENT JPI$_PROCPRIV,PROCPRIV,8 ENT JPI$_TERMINAL,TERMINAL,7,TERMINAL_STRING ENT JPI$_UIC,UIC ENT JPI$_USERNAME,USERNAME,12,USERNAME_STRING ENT JPI$_VOLUMES,VOLUMES ENT JPI$_WSPEAK,WSPEAK .LONG 0,0,0 ; ; This string sets the wait interval between snapshots ; WAIT_TIME_ASCII: .ASCID /0 00:15:00.00/ .PAGE .SUBTITLE IMPURE DATA .PSECT IMPURE_DATA,RD,WRT,NOSHR,NOEXE,LONG .ALIGN LONG ACCOUNT: .BLKB 8 ACCOUNT_STRING: .LONG 8 .ADDRESS ACCOUNT BUFIO: .LONG 0 CPUTIM: .LONG 0 DIRIO: .LONG 0 IMAGECOUNT: .LONG 0 JOBTYPE: .LONG 0 LOGINTIM: .LONG 0,0 OWNER: .LONG 0 PAGEFLTS: .LONG 0 PID: .LONG 0 PRI: .LONG 0 PROCPRIV: .LONG 0,0 TERMINAL: .BLKB 7 TERMINAL_STRING:.LONG 7 .ADDRESS TERMINAL UIC: .LONG 0 USERNAME: .BLKB 12 USERNAME_STRING:.LONG 12 .ADDRESS USERNAME VOLUMES: .LONG 0 WSPEAK: .LONG 0 SYS_TIME: .QUAD 0 JPI_PID: .LONG -1 WAIT_TIME_BINARY: .LONG 0,0 .PAGE .SUBTITLE ACCOUNTING DATA BLOCK BUILD AREA .PSECT ACCOUNTING_DATA,RD,WRT,NOEXE,LONG,NOSHR ACC_SIZE=1024 ACCOUNT_BLOCK: .BLKB ACC_SIZE .PAGE .SUBTITLE RMS BLOCKS FOR FILE OUTPUT .PSECT RMS_DATA,RD,WRT,NOEXE,QUAD,NOSHR .ALIGN LONG TEMP_FAB: $FAB DNM=,- FAC=,- FOP=,- MRS=ACC_SIZE,- ORG=SEQ,- SHR=NIL .ALIGN LONG TEMP_RAB: $RAB FAB=DAT_FAB,- RAC=SEQ,- RBF=ACCOUNT_BLOCK,- ROP=TPT .ALIGN LONG DAT_FAB: $FAB DAT_FAB_LENGTH=.-DAT_FAB .ALIGN LONG DAT_RAB: $RAB DAT_RAB_LENGTH=.-DAT_RAB .PAGE .SUBTITLE INIT CODE .PSECT CODE,RD,NOWRT,EXE,SHR .ENTRY SNAPSHOT,0 $SETPRV_S ENBFLG=ENABLE_FLAG,PRVADR=PRIV_MASK BLBS R0,1$ $EXIT_S R0 1$: $BINTIM_S TIMBUF=WAIT_TIME_ASCII,TIMADR=WAIT_TIME_BINARY BLBS R0,6$ $EXIT_S R0 6$: INTERVAL_LOOP: $GETTIM_S TIMADR=SYS_TIME BLBS R0,2$ $EXIT_S R0 2$: MOVC3 #DAT_FAB_LENGTH,TEMP_FAB,DAT_FAB MOVC3 #DAT_RAB_LENGTH,TEMP_RAB,DAT_RAB $CREATE FAB=DAT_FAB BLBS R0,3$ $EXIT_S R0 3$: $CONNECT RAB=DAT_RAB BLBS R0,4$ $EXIT_S R0 4$: $REWIND RAB=DAT_RAB BLBS R0,5$ $EXIT_S R0 5$: MOVL #-1,JPI_PID ;INIT PID POINTER TO WILD CARD VALUE $GETJPIW_S PIDADR=JPI_PID,ITMLST=ITEMLIST ;Skip null process .PAGE .SUBTITLE INNER LOOP-GATHER DATA INNER_LOOP: $GETJPIW_S PIDADR=JPI_PID,ITMLST=ITEMLIST ;GET JOB INFO CMPL #SS$_NOMOREPROC,R0 BNEQ 1$ BRW END_INNER_LOOP 1$: CMPL #SS$_SUSPENDED,R0 BEQL INNER_LOOP BLBS R0,2$ $EXIT_S R0 2$: .MACRO DE_NULL NAME,?D,?B,?C PUSHR #^M MOVZBL 'NAME'_STRING,R11 BEQL B MOVL 'NAME'_STRING+4,R10 D: TSTB (R10) BNEQ C MOVB #^A/ /,(R10) C: INCL R10 DECL R11 BGTR D B: POPR #^M .ENDM DE_NULL ACCOUNT DE_NULL TERMINAL DE_NULL USERNAME .PAGE .SUBTITLE INNER LOOP-BUILD PSEUDO ACCOUTNING BLOCK MOVC5 #0,ACCOUNT_BLOCK,#0,#ACC_SIZE,ACCOUNT_BLOCK ; BUILD PSEDO TERMINATION ACCOUNTING BLOCK MOVAL ACCOUNT_BLOCK,R11 ; BLOCK HEADER LESS LENGTH (DONE LATER) MOVW #ACR$S_ACRDEF1,ACR$W_LENGTH(R11) MOVQ SYS_TIME,ACR$Q_SYSTIME(R11) MOVW #<!>,- ACR$W_TYPE(R11) .MACRO TYPE BIT,SET,?A CMPL #JPI$K_'BIT',JOBTYPE BNEQ A .IF NB,SET BISW2 #,ACR$W_TYPE(R11) .IFF BISW2 #,ACR$W_TYPE(R11) .ENDC BRB 20$ A: .ENDM TYPE DETACHED TYPE NETWORK TYPE BATCH TYPE LOCAL,INTERACTIVE TYPE DIALUP,INTERACTIVE TYPE REMOTE,INTERACTIVE ; SET UP FOR ID PACKET 20$: ADDL3 #,R11,R10 MOVW #<<1@ACR$V_PACKET>!!- >,ACR$W_TYPE(R10) MOVW #ACR$S_ACRDEF2,ACR$W_LENGTH(R10) ADDL3 #ACR$S_ACRDEF2,R10,R9 ;CALC OFFSET TO OFFSET DATA AREA MOVL PID,ACR$L_PID(R10) MOVL OWNER,ACR$L_OWNER(R10) MOVL UIC,ACR$L_UIC(R10) MOVQ PROCPRIV,ACR$Q_PRIV(R10) MOVB PRI,ACR$B_PRI(R10) .MACRO OFFSET NAME,?A,?B TSTL 'NAME'_STRING BNEQ A CLRW ACR$W_'NAME'(R10) BRW B A: SUBL3 R10,R9,R0 MOVW R0,ACR$W_'NAME'(R10) MOVB 'NAME'_STRING,(R9)+ MOVC3 'NAME'_STRING,'NAME',(R9) ADDL2 'NAME'_STRING,R9 ADDW2 'NAME'_STRING,ACR$W_LENGTH(R10) INCW ACR$W_LENGTH(R10) B: .ENDM OFFSET USERNAME OFFSET ACCOUNT CLRW ACR$W_NODENAME(R10) OFFSET TERMINAL CLRW ACR$W_JOBNAME(R10) CLRL ACR$L_JOBID(R10) CLRW ACR$W_QUEUE(R10) CLRW ACR$W_NODEADDR(R10) CLRW ACR$W_REMOTEID(R10) ADDW2 ACR$W_LENGTH(R10),ACR$W_LENGTH(R11) ; SET UP OFFSET FOR RESOURCE PACKET MOVL R9,R10 ADDL3 R10,#ACR$S_ACRDEF3,R9 MOVW #<<1@ACR$V_PACKET>!!- >,ACR$W_TYPE(R10) MOVW #ACR$S_ACRDEF3,ACR$W_LENGTH(R10) TSTL LOGINTIM BNEQ 30$ TSTL LOGINTIM+4 BNEQ 30$ MOVQ SYS_TIME,ACR$Q_LOGIN(R10) BRB 31$ 30$: MOVQ LOGINTIM,ACR$Q_LOGIN(R10) 31$: MOVL #JBC$_JOBABORT,ACR$L_STATUS(R10) MOVL IMAGECOUNT,ACR$L_IMGCNT(R10) MOVL CPUTIM,ACR$L_CPUTIME(R10) MOVL PAGEFLTS,ACR$L_FAULTS(R10) CLRL ACR$L_FAULTIO(R10) MOVL WSPEAK,ACR$L_WSPEAK(R10) CLRL ACR$L_PAGEFL(R10) MOVL DIRIO,ACR$L_DIOCNT(R10) MOVL BUFIO,ACR$L_BIOCNT(R10) MOVL VOLUMES,ACR$L_VOLUMES(R10) ; CLEAN UP LENGTH ADDW2 ACR$W_LENGTH(R10),ACR$W_LENGTH(R11) MOVW ACR$W_LENGTH(R11),DAT_RAB+RAB$W_RSZ $PUT RAB=DAT_RAB BRW INNER_LOOP .PAGE .SUBTITLE DONE THIS PASS-WAIT BEFORE REPEATING END_INNER_LOOP: $DISCONNECT RAB=DAT_RAB BLBS R0,3$ $EXIT_S R0 3$: $CLOSE FAB=DAT_FAB BLBS R0,1$ $EXIT_S R0 1$: $SETIMR_S EFN=#2,DAYTIM=WAIT_TIME_BINARY BLBS R0,2$ $EXIT_S R0 2$: $WAITFR_S EFN=#2 BLBS R0,4$ $EXIT_S R0 4$: BRW INTERVAL_LOOP .END SNAPSHOT