PROGRAM DSKUSG C C Routine to determine the current disk usage by account user. C Would normally be run on a periodic basis, such as ever night C to get an account of the current state of the system disk. C C Output is messages to CO: informing the LOGFILE of the user, C and the number of blocks allocated on all of his accounts. C C An analyzer program can then be run on the logfile and get C a Datatrieve compatible file for report generation. C C Compile and taskbuild commands C FORTRAN/F77 DISKUSAGE/TRACEBACK:NONE C DISKUSAGE,DISKUSAGE/-SP=DISKUSAGE C LB:[1,1]SYSLIB/LB:$SHORT C / C UNITS=2 C ACTFIL=2 C ASG=CO:2 C MAXBUF=512 C TASK=DSKUSG C UIC=[1,1] C // C IMPLICIT INTEGER (A-Z) DIMENSION STATUS(8) REAL PIP BYTE BUFFER(512),CMDLIN(31),NULL CHARACTER*255 TOTLIN,NBLCKS*6 CHARACTER*14 NAMES(100) CHARACTER*3 GROUP(100),MEMBER(100) C DATA PIP/6R...PIP/,NULL/0/ PARAMETER (FILES=1,CO=2) C OPEN (UNIT=FILES,FILE='LB:[0,0]RSX11.SYS',READONLY,STATUS='OLD', $ RECORDTYPE='FIXED',RECL=512,ERR=99) C NACTS = 0 5 READ (FILES,6,END=30) BUFFER 6 FORMAT (4(128A1)) DO 15 I=1,512,128 IF (BUFFER(I).EQ.NULL) GO TO 30 NACTS = NACTS+1 DECODE (26,7,BUFFER(I)) GROUP(NACTS),MEMBER(NACTS),NAMES(NACTS) 7 FORMAT (2A3,6X,A14) 15 CONTINUE GO TO 5 C C Filled the user accounts C 30 CLOSE (UNIT=FILES) C C Clean up TEMP files ( delete any existing ones) C ENCODE(25,31,CMDLIN) 31 FORMAT ('PIP LB:[1,4]TEMP.TMP;*/DE/NM') CALL SPAWN(PIP,1,4,5,,STATUS,,CMDLIN,28,,,IDSW) CALL STOPFR(5) DO 55 I=1,NACTS C C Get the block count for this user by spawning a command line C to PIP to generate a file with the total number of blocks there C ENCODE(31,41,CMDLIN) GROUP(I) 41 FORMAT ('PIP LB:[1,4]TEMP.TMP=DU:[',A3,',*]/TB/NM') CALL SPAWN(PIP,1,4,5,,STATUS,,CMDLIN,37,,,IDSW) CALL STOPFR(5) C C Now read that file, looking for the last line C NBLCKS = ' 0' OPEN(UNIT=FILES,FILE='LB:[1,4]TEMP.TMP',STATUS='OLD',ERR=50) 45 READ (FILES,46,END=50) N,TOTLIN 46 FORMAT (Q,A255) TOTLIN = TOTLIN(:N) IF (INDEX(TOTLIN,'otal').EQ.0) GO TO 45 L = INDEX(TOTLIN,'Grand') IF (N.NE.0) TOTLIN = TOTLIN(L:N) C C Got the last line, decode the block count C STRIDX = INDEX(TOTLIN,'/')+1 ENDIDX = INDEX(TOTLIN,'. blo')-1 NCHRS = ENDIDX-STRIDX+1 NBLCKS = ' ' NBLCKS(7-NCHRS:6) = TOTLIN(STRIDX:ENDIDX) GO TO 45 C C Write the goodies to CO: (the log file) C 50 CLOSE(UNIT=FILES,DISPOSE='DELETE') WRITE (CO,51) GROUP(I),MEMBER(I),NAMES(I),NBLCKS 51 FORMAT (' Disk usage user [',A3,',',A3,'] ',A14,' Blocks: ',A6) 55 CONTINUE C C That's it! C 99 CALL EXIT END