$!****************************************************************************** $! $! TITLE: ATR_DAEMON.COM $! $! WRITTEN BY: Michael M. Frazier $! $! PURPOSE: This command file will run as a Detatched Process $! and wake up periodically to check the ACMS Audit $! Trail (ACMSATR). A mail message will be mailed $! to ATR_DAEMON_DISTRIB if errors are found. $! $!****************************************************************************** $! $! $ INITIALIZE: $ set on $! $ on error then goto fatal_error $ node_name = f$getsyi("nodename") $ set proc/name="''f$trnlnm("ATR_DAEMON_PROCNAM")'" $! $ on error then gosub catch_error $ old_priv = f$setprv("SYSPRV") $ if .not. f$privilege("SYSPRV") then goto no_privs $ sleep_time = f$trnlnm("ATR_DAEMON_SLEEP") $! $ lf[0,8] = 10 $ cr[0,8] = 13 $! $ START: $ set noon $ delete/nolog/noconf 'f$trnlnm("ATR_DAEMON_INPUT")';* $ set on $ on error then gosub catch_error $ mcr acmsatr list/since="-''sleep_time'"/out=atr_daemon_input !- $! acms$audit_log $ if f$search("atr_daemon_input",1) .eqs. "" then goto sleep $! $ if f$search("ATR_DAEMON_OUTPUT",1) .nes. "" then - delete/nolog/noconf 'f$trnlnm("ATR_DAEMON_OUTPUT")';* $ define tpu$work sys$sysdisk !Work disk with lots of freespace $ edit/tpu/nosect/nodispl/command=atr_daemon:find_atr_error - atr_daemon_input $ if f$search("atr_daemon_output",1) .eqs. "" then goto sleep $! $ mail/noself/subj="ACMSATR Errors found on ''node_name'..." - atr_daemon_output atr_daemon_distrib $! $ SLEEP: $ sleep_time = f$trnlnm("ATR_DAEMON_SLEEP") $ wait 'sleep_time' $ goto start $! $! $!****************************************************************************** $! $! Subroutines $! $!****************************************************************************** $! $ NO_PRIVS: $ username = f$getjpi("","USERNAME") $ err_msg = "''username' does not have SYSPRV. Daemon aborting." $ log_msg = f$fao( - "!%T !ASATR_Daemon recieved the following error:!AS!AS", - warn, node_name, err_msg) $ gosub open_log $ goto fatal_error $! $ CATCH_ERROR: $ err_stat = $status $ on error then goto fatal_error $ err_msg = f$message(err_stat) $ log_msg = f$fao( - "!%T !AS::ATR_Daemon recieved the following error:!AS", - 0, node_name, cr + lf + err_msg) $ OPEN_LOG: $ open/append/error=new_log error_log atr_daemon_errors $ goto write_log $! $ NEW_LOG: $ open/write error_log atr_daemon_errors $! $ WRITE_LOG: $ write error_log log_msg $ close error_log $! $ return $! $ FATAL_ERROR: $ mail/noself/subj="A Fatal Error occured in ATR Daemon on ''node_name'"- nl: atr_daemon_errdis $ exit !****************************************************************************** ! ! TITLE: FIND_ATR_ERROR.TPU ! ! WRITTEN BY: Michael M. Frazier ! ! PURPOSE: This TPU batch file will search for ATR Errors in ! the 'Text' line of the ATR report, and write the ! errors to the ATR_DAEMON_OUTPUT file. ! !****************************************************************************** ! set (message_flags,0); input_file := get_info (command_line, "file_name"); main_buffer := create_buffer ("MAIN", input_file); staging_buffer := create_buffer ("Staging Buffer"); error_buffer := create_buffer ("Error Buffer"); error_pattern := LINE_BEGIN & "Text : " & ("Task canceled" | "Signal by" | "Error" | MATCH ("failed") | "Unsuccessful Appl"); asterisk_pattern := LINE_BEGIN & "******"; jbc_pattern := LINE_BEGIN & "-JBC-S-NORMAL"; errors_found := 0; position (beginning_of (main_buffer)); loop found_range := search_quietly (error_pattern, forward); exitif found_range = 0; position (found_range); start_range := search_quietly (asterisk_pattern, reverse); position (start_range); start_pos := select (none); position (found_range); end_range := search_quietly (asterisk_pattern, forward); position (end_range); error_stuff := select_range; position (beginning_of (staging_buffer)); copy_text (error_stuff); jbc_position := search_quietly (jbc_pattern, reverse); if jbc_position = 0 then position (error_buffer); copy_text (error_stuff); errors_found := errors_found + 1; endif; erase(staging_buffer); start_pos := 0; position (main_buffer); endloop; if errors_found > 0 then write_file (error_buffer,"ATR_DAEMON_OUTPUT"); endif; delete (staging_buffer); quit; $!****************************************************************************** $! $! TITLE: START_ATR_DAEMON.COM $! $! WRITTEN BY: Michael M. Frazier $! $! PURPOSE: This command procedure will define the ATR_DAEMON $! system logicals, and then create the ATR_DAEMON $! detached process. $! $! This procedure should be placed in the SYS$STARTUP $! directory, and executed at System Startup. $! $! FORMAT: $ @SYS$STARTUP:START_ATR_DAEMON $! $!****************************************************************************** $! $ @SYS$STARTUP:ATR_DAEMON_LOGICALS $ username = f$trnlnm("ATR_DAEMON_USERNAME") $ if username .eqs. "" then username = "SYSTEM" $ RUN/DETACHED SYS$SYSTEM:LOGINOUT /UIC='username' - /INPUT=ATR_DAEMON:ATR_DAEMON.COM - /OUTPUT=NL: - /PRIORI=4 $ EXIT $!****************************************************************************** $! $! TITLE: ATR_DAEMON_LOGICALS.COM $! $! WRITTEN BY: Michael M. Frazier $! $! PURPOSE: This procedure defines the logicals used by the $! ATR_DAEMON and ATR_ERROR command files. $! $!****************************************************************************** $! Definitions of Logicals $! $! ATR_DAEMON - The directory the Daemon lives in $! ATR_DAEMON_SCRATCH - Work area for Daemon temporary files $! ATR_DAEMON_ERRORS - Filename where Daemon errors are to be logged $! ATR_DAEMON_INPUT - Temporary File created with ATR LIST/OUT= $! ATR_DAEMON_OUTPUT - File that contains only the ATR Errors $! ATR_DAEMON_PROCNAM - The process name for the ATR_DAEMON $! ATR_DAEMON_DISTRIB - Distribution List or Username(s) of who gets mailed $! the ATR_DAEMON_OUTPUT file $! ATR_DAEMON_ERRDIS - Distribution List or Username(s) of who gets mailed $! notification of Daemon's death by a Fatal error $! ATR_DAEMON_SLEEP - How long the Daemon sleeps between runs $! ATR_DAEMON_USERNAME - Username that the Daemon will run under $!****************************************************************************** $! $ define/system/nolog atr_daemon DISK:[ATR] $ define/system/nolog atr_daemon_scratch DISK:[ATR.SCRATCH] $ define/system/nolog atr_daemon_errors atr_daemon_scratch:atr_daemon_error.log $ define/system/nolog atr_daemon_input atr_daemon_scratch:atr.log $ define/system/nolog atr_daemon_output atr_daemon_scratch:atr_errors.txt $ define/system/nolog atr_daemon_procnam "ATR Daemon" $ define/system/nolog atr_daemon_distrib "@your_distrubution_list" $ define/system/nolog atr_daemon_errdis "@error_distrubution_list" $ define/system/nolog atr_daemon_sleep "00:30:00" $ define/system/nolog atr_daemon_username "SYSTEM" $!****************************************************************************** $! $! TITLE: ATR_ERROR.COM $! $! WRITTEN BY: Michael M. Frazier $! $! PURPOSE: This command file will list the Errors found in $! the ACMSATR. By Default this will show all errors $! for today since midnight. $! $! FORMAT: $ @ATR_ERROR [acmsatr_switches] $! $! NOTE: Do NOT use the /OUT switch as a parameter $! $!****************************************************************************** $! $! $ verify_sw = f$verify(0) $ INITIALIZE: $ edit = "$ edit" $ say := write sys$output $ p1 = "/since=today " + p1 $ set on $ on error then gosub catch_error $ old_priv = f$setprv("SYSPRV") $ if .not. f$privilege("SYSPRV") then goto no_privs $ in_file = f$trnlnm("ATR_DAEMON_INPUT") $ out_file = f$trnlnm("ATR_DAEMON_OUTPUT") $! $ START: $ set noon $ if f$search(in_file) .nes. "" then - delete/nolog/noconf 'in_file';* $ if f$search(out_file) .nes. "" then - delete/nolog/noconf 'out_file';* $ set on $ say "" $ say "Now getting Audit Trail (''p1')..." $ mcr acmsatr list/out='in_file' 'p1' $ if f$search(in_file,1) .eqs. "" then goto finish $! $ say "Editing Audit Trail..." $ say "" $ edit := edit $ edit/tpu/nosect/nodispl/command=atr_daemon:find_atr_error - atr_daemon_input $ if f$search(out_file,1) .eqs. "" then goto no_errors $! $ type/page 'out_file' $ goto finish $! $ NO_ERRORS: $ say "" $ say "No errors were found." $ say "" $ goto finish $! $ NO_PRIVS: $ say "" $ say "User must have SYSPRV to see ACMS$AUDIT_LOG" $ say "" $ goto finish $! $ FINISH: $ old_priv = f$setprv(old_priv) $ verify_sw = f$verify(verify_sw) $ exit 1 $! $ CATCH_ERROR: $ err_stat = $status $ verify_sw = f$verify(verify_sw) $ exit 'err_stat'