C PROGRAM CHKFRE C C This program checks disks for free space, and executes a C command file when the disk space falls below a user specified C level. The disks to be checked and the minimum free space C desired are read from the file: LB:[1,2]CHKFRE.CMD (This file C also contains the commands that are to be executed when the C free space on a disk falls below the minimum). CHKFRE.CMD C contains one line of the following form for each disk to be C checked: C C .;* DDn: nnnnn C C DDn: is the disk to be checked and nnnnn is the minimum free C space for that disk. The list of disks is terminated by the C following line: C C .;- C C If the free space on any of the disks checked falls below the C given level then CHKFRE.CMD is executed (from terminal TT0:) C by a specially installed version (CHKFR2) of the indirect C command processor, once for each disk that is low on disk C space. (Note that the data lines in CHKFRE.CMD begin with C ".;", and are therefore comments to the indirect command C processor). CHKFRE.CMD is executed with the following C parameters: C C P1 = The name of the disk that is low on disk space (DDn:) C P2 = The actual amount of free space on that disk. C If the disk was not accessible, then P1 = "*". C C C Example CHKFRE.CMD file: C C .;* DR0: 05000 C .;* DR1: 10000 C .;- C .ENABLE SUBSTITUTION,QUIET C .DISABLE DISPLAY C .IF P2 = "*" .EXIT C BRO ALL:"Warning: 'P1' has only 'P2' blocks free." C C C To run CHKFRE, insert the following in LB:[1,2]STARTUP.CMD : C C INS CHKFRE C INS $ICP/TASK=CHKFR2 C RUN CHKFRE H/RSI=1H C C (This runs CHKFRE every hour, on the hour) BYTE DISK(10), COMMND(26), FLAGS(4), DOT, SEMI, STAR, DASH, BLANK INTEGER MINFRE, RESULT, STATUS(8), DSW, ERR REAL IND LOGICAL ATCOM, OK, DONE DATA DISK / 4*0, '[', '0', ',', '0', ']', 0 / DATA DOT, SEMI, STAR, DASH, BLANK + / 1H., 1H;, 1H*, 1H-, 1H / DATA COMMND / + 1H@, 1HL, 1HB, 1H:, 1H[, 1H1, 1H,, 1H2, 1H], + 1HC, 1HH, 1HK, 1HF, 1HR, 1HE, 11*1H / DATA IND /6RCHKFR2/ CALL ASSIGN(1, 'LB:[1,2]CHKFRE.CMD') CALL FDBSET(1, 'READONLY') CALL ERRSET(43, .TRUE., .FALSE., .FALSE., .FALSE.) REPEAT READ(1, 100, END=999) FLAGS, (DISK(I), I = 1, 4), MINFRE 100 FORMAT(4A1, 4A1, I6) ATCOM = (FLAGS(1) .EQ. DOT) .AND. (FLAGS(2) .EQ. SEMI) OK = ATCOM .AND. (FLAGS(3) .EQ. STAR) DONE = ATCOM .AND. (FLAGS(3) .EQ. DASH) IF (OK) THEN CALL ASSIGN(2, DISK) CALL ERRTST(43, ERR) IF (ERR .EQ. 1) THEN RESULT = -1 ELSE CALL FRESPC(2, MINFRE, RESULT) ENDIF IF (RESULT .NE. 0) THEN COMMND(17) = DISK(1) COMMND(18) = DISK(2) COMMND(19) = DISK(3) COMMND(20) = DISK(4) IF (RESULT .LT. 0) THEN COMMND(22) = STAR DOLOOP I = 23, 26 COMMND(I) = BLANK ENDLOOP ELSE CALL NCODEI(RESULT, COMMND(22), 5) ENDIF CALL SPAWN(IND, 1, 1, 15,, STATUS,, COMMND, 26, + 0, 'TT', DSW) IF (DSW .LE. 0) THEN CALL CLOSE(1) CALL ASSIGN(3, 'CO:') WRITE(3, 300) COMMND, DSW 300 FORMAT(' CHKFRE -- Spawn failure: "', 26A1, '"', + 5X, 'DSW =', I6) ELSE CALL WAITFR(15) ENDIF ENDIF ENDIF UNTIL (DONE) 999 CALL EXIT END SUBROUTINE NCODEI(NUMBER, STRING, LEN) C --- ENCODE A POSITIVE INTEGER NUMBER (*NUMBER*) LEFT JUSTIFIED, INTO A C - CHARACTER STRING (*STRING*) OF LENGTH (*LEN*). INTEGER NUMBER, LEN INTEGER NUM, DIGIT BYTE STR(5), STRING(LEN), DIGITS(10), BLANK DATA BLANK /1H / DATA DIGITS(1) /1H0/, DIGITS(2) /1H1/, DIGITS(3) /1H2/, + DIGITS(4) /1H3/, DIGITS(5) /1H4/, DIGITS(6) /1H5/, + DIGITS(7) /1H6/, DIGITS(8) /1H7/, DIGITS(9) /1H8/, + DIGITS(10) /1H9/ NUM = NUMBER I1 = LEN + 1 REPEAT I1 = I1 - 1 NEWNUM = NUM / 10 DIGIT = NUM - NEWNUM * 10 NUM = NEWNUM STR(I1) = DIGITS(DIGIT + 1) UNTIL ((NUM .EQ. 0) .OR. (I1 .EQ. 0)) I2 = 1 DOLOOP I = I1, LEN STRING(I2) = STR(I) I2 = I2 + 1 ENDLOOP RETURN END