OpenVMS Source Code Demos
check_raid
$!==============================================================================
$! title : check_raid.com
$! author : Neil Rieck
$! created: 2018-11-12
$! notes : this script is used to check the RAID controllers:
$! scs node=kawc09 P400 on rx2660
$! scs node=kawc90 P410 on rx2800-i2
$!==============================================================================
$ on error then goto error_exit !
$ say := write sys$output !
$ ask := inquire/nopunct !
$ dq[0,8] = 34 ! double quote
$ bel[0,8] = 7 ! ring that bell
$ say "-i-script:",f$environment("PROCEDURE") !
$ bad_word_list = "FAILED,REMOVED,ERROR,BAD," ! comma-delimited list (upper case)
$ requeue = 1 !
$ display_counters = 0 !
$ reason$ = "" !
$ count_line = 0 !
$ count_volume = 0 !
$ count_volume_ok = 0 !
$ count_error = 0 !
$ my_node = f$getsyi("SCSNODE") !
$ my_stamp = f$cvtime() !
$ my_stamp = my_stamp - ":" - ":" - "-" - "-" - " " - "." !
$ my_scratch1 = "csmis$tmp:check_raid-"+ my_stamp +".scratch" !
$ define/user sys$output 'my_scratch1' ! divert output to here
$ run sys$system:msa$util.exe
$deck
set cont *
show units
exit
$eod
$!----------------------------------------------------------------------
$! okay, let's read/analyze the report
$!----------------------------------------------------------------------
$!~ type 'my_scratch1' ! debug
$ open/read/error=my_error1 my_channel1 'my_scratch1' !
$loop1: !
$ read/error=my_error1/end_of_file=my_eof1 my_channel1 my_buffer1
$!~ say "yada>",my_buffer1 ! debug
$ uc1 = f$edit(my_buffer1,"UPCASE") !
$ count_line = count_line + 1 !
$ if f$length(uc1) .lt. 5 then goto loop1 ! data line is too small
$ if (f$locate("VOLUME STATUS",uc1) .lt. f$length(uc1)) !
$ then !
$ count_volume = count_volume + 1 !
$ if (f$locate("VOLUME OK",uc1) .lt. f$length(uc1)) !
$ then !
$ count_volume_ok = count_volume_ok + 1 !
$ endif !
$ endif !
$!
$! <<< isolate words from the bad words list then look for them on this data line >>>
$!
$ wkng = bad_word_list ! make a working copy of bad_word_list
$loop_bw:
$ c1 = f$locate(",", wkng) ! locate the coma (if any)
$ if (c1 .eq. f$length(wkng)) then goto loop1 ! jump cuz no coma here
$ word = f$extract(0,c1,wkng) ! isolate a word
$!~ say "word:",word ! debug
$ wkng = f$extract(c1+1,f$length(wkng)-c1,wkng) !
$ if (f$locate(word,uc1) .lt. f$length(uc1)) !
$ then !
$ count_error = count_error + 1 !
$ endif !
$ goto loop_bw !
$loop2: !
$ goto loop1 !
$my_eof1: !
$my_error1: !
$ close my_channel1 !
$ say "-i-exit stats :" !
$ say "-i-count_line : ",count_line !
$ say "-i-count_volume : ",count_volume !
$ say "-i-count_volume_ok: ",count_volume_ok !
$ say "-i-count_error : ",count_error !
$ if (count_volume .ne. count_volume_ok) .or. -
(count_error .gt. 0) .or. -
(count_line .lt. 15) !
$ then !
$ reason$ = "-e-RAID problems were found" !
$ say reason
$ display_counters = 1 !
$ else
$ endif !
$ goto requeue_exit !
$error_exit: !
$ set noon !
$ requeue = 0 ! something wrong so do not REQUEUE
$ reason$ = "-e-this script encountered DCL errors" !
$mail_fini:
$ set noon !
$ my_stamp = f$cvtime() !
$ my_stamp = my_stamp - ":" - ":" - "-" - "-" - " " - "." !
$ my_scratch2 = "csmis$tmp:check_raid-"+ my_stamp +".txt" !
$ open/write/error=my_error2 my_channel2 'my_scratch2' !
$ write/error=my_error2 my_channel2 "node:",my_node !
$ write/error=my_error2 my_channel2 "reason: ", reason$
$ if (display_counters .eq. 1)
$ then
$ write/error=my_error2 my_channel2 "-i-exit stats :"
$ write/error=my_error2 my_channel2 "-i-count_line : ",count_line
$ write/error=my_error2 my_channel2 "-i-count_volume : ",count_volume
$ write/error=my_error2 my_channel2 "-i-count_volume_ok: ",count_volume_ok
$ write/error=my_error2 my_channel2 "-i-count_error : ",count_error
$ endif
$my_error2:
$ close my_channel2 !
$ mail/subj="icsis-raid-error" 'my_scratch2' "[email protected]"
$requeue_exit: !
$ set noon !
$ if (f$mode() .eqs. "INTERACTIVE") .and. (requeue .eq. 1)
$ then
$ ask junk$ "-?-queue this job for 8:00 tomorrow? (y/N) "
$ if junk$ .nes. "Y" then requeue = 0
$ endif
$ if (requeue .eq. 0)
$ then
$ say "-i-job NOT requeued"
$ else
$ next_time = dq + f$cvtim("TOMORROW","ABSOLUTE","DATE") +" 08:00:00" + dq
$ submit csmis$com:check_raid.com -
/queue=csmis$batch -
/after='next_time' -
/user="CUSTODIAN" -
/log=csmis$tmp:check_raid.log -
/noprint
$ endif
$ exit !
Back to
Home
Neil Rieck
Waterloo, Ontario, Canada.