$! CHECK_DISKS.COM V1.50 $! 24-Jun-91 L Baldwin $! $! Procedure to monitor diskspace and errors $! $! Setup: $! EDIT TASM$COM:CHECK_DISKS.DAT to indicate the disks to monitor. $! $ set noverify $! $! If we are not already executing as a detached process $! then do it $! $ if f$mode() .eqs. "OTHER" then goto SKIP $ run/detach sys$system:loginout.exe - /input=tasm$com:check_disks.com - /output=tasm$scratch:check_disks.log - /process_name="" - /UIC=[1,4] $ EXIT $! $SKIP: $ @TASM$COM:TASM_MENUSYM $! Constants $! $ freeblock_warning = 50000 ! 50000 Blocks $ freeblock_critical = 10000 ! Blocks $ disk_err_warning = 1 ! 1 error $ disk_err_critical = 10 ! 10 errors $ interval = "00:15:00" ! polling interval $ warning_class = "(central)" !Opcom class to reply to for warnings $ critical_list = "(system)" !Who to notify if critical $ SAY:=write sys$output $! $! Initialization $! $INITIALIZATION: $! Read disk database $! $ show time $ on error then goto LAST_DISK $ index = 0 $ open/read inp TASM$COM:CHECK_DISKS.DAT ! open disk db $LOOP: $ read/end=last_disk inp disk ! get a disk $ index = index + 1 ! incr. index $ disk'index' = disk ! store disk in "array" $ errcnt'index' = f$getdvi(disk,"ERRCNT") ! store error count $ goto LOOP ! get next disk $LAST_DISK: $ close inp $ disk_count = index ! we know how many disks there are $ if disk_count .eq. 0 ! Abort if no disks defined $ then $ SAY - "There are no disks entered in the disk database: TASM$COM:CHECK_DISKS.DAT" + "CHECK_DISKS aborting." $ goto DONE $ endif $! $NEXT_INTERVAL: $! $! Check all disks $! $ index = 0 ! reset index $! Check each disk $NEXT_DISK: $ if index .gt. disk_count then goto DO_WAIT $ index = index + 1 ! next disk $ disk = disk'index' ! retrieve from "array" $ prev_errcnt = errcnt'index' ! get previous error count $ cur_errcnt = f$getdvi(disk,"ERRCNT") ! get current error count $ cur_freeblocks = f$getdvi(disk,"FREEBLOCKS") ! current free space $! $! Check space thresholds, send msgs if thresholds reached $! $ if cur_freeblocks .lt. freeblock_critical $ then $ msg = "Diskspace CRITICAL: only ''cur_freeblocks' blocks on ''disk'." $ reply/bell/user='critical_list' "''msg'" $ endif $! $ if cur_freeblocks .lt. freeblock_warning $ then $ msg = "Diskspace WARNING: less than ''freeblock_warning' blocks on ''disk'." $ request/to='warning_class' "''msg'" $ endif $! $! Check for disk errors, send msgs if thresholds reached $! $ if prev_errcnt - cur_errcnt .ge. disk_err_critical $ then $ msg = "Disk errors CRITICAL: ''disk' has logged ''cur_errcnt' errors." $ reply/bell/user='critical_list' "''msg'" $ endif $! $ if prev_errcnt - cur_errcnt .ge. disk_err_warning $ then $ msg = "Disk error WARNING: ''disk' has logged ''cur_errcnt' errors." $ request/to='warning_class' "''msg'" $ endif $ errcnt'index' = cur_errcnt $GOTO NEXT_DISK ! do next disk $DO_WAIT: $ wait 'interval' ! wait a while $ GOTO NEXT_INTERVAL $ exit