#!/usr/bin/perl ############################################################################### ## ## Written By: Jarred Nicholls ## E-mail: jarred.nicholls@umbc.edu ## Website: http://userpages.umbc.edu/~jarred1/ ## Maintained By: Jon Roenick ## ## This script goes through the error.log file and first picks out all of ## the errors in the log. Then, it removes errors that are to be ignored, ## and prints the remaining potentially important errors into a file named ## "errors.txt" where they may be printed out cleanly and reviewed more ## efficiently and effectively. ## ############################################################################### print "\nEnter the path of the log file to be searched: "; $filename = ; chomp($filename); open(FILE, $filename) || die("\nThe file $filename could not be opened\n"); open(ERRORS, ">/u/carelink/live/log/errors.txt") || die("\nThe errors.txt file could not be created\n"); @file_contents = ; for ($i = 0, $j = 0; $i < @file_contents; $i++) { $errors[$j++] = $file_contents[$i] if ($file_contents[$i] =~ /ERROR/); } ### BEGINNING OF ERROR LIST (ERRORS TO IGNORE) ### # You may add errors by simply adding a comma to the last # error in the list, pressing enter, indenting to the first # quote ("), and type "" (quotes included, no brackets). # If the quote contains either a double-quote (") or a # single-quote ('), then you MUST put a backslash (\) in front # of it. See where I did that below...Good luck and enjoy! @error_list = ( "A file or directory in the path name does not exist", "Error while trying to retrieve text for error", "", "No patient type group identified using facility", "Default patient type group used", "No PARENT", "Unable to open message file", "Unable to get prompt", "can\'t read from O_PROMPT_LOU", "IS ALREADY ADMITTED", "Unable to open message file", "No CHILD ANC_STAT_XL", "_ADD_REC", "ALREADY DISCHARGED", "source systems don\'t match", "lock", "setting debug logging level to \'AUDIT\'", "TRANSACTION PROCESSOR", "STATUS_CHANGE", "(DTY)", "(NSH)" ); ### END OF ERROR LIST ### $num_errors_to_ignore = @error_list; for ($i = 0, $flag = 0, $num_errors = 0; $i < $j; $flag = 0, $i++) { for ($k = 0; $k < @error_list; $k++) { if ($errors[$i] !~ /$error_list[$k]/i) { $flag++; } } if ($flag == $num_errors_to_ignore) { print ERRORS "$errors[$i]\n"; $num_errors++; } } close(FILE); close(ERRORS); print "\nNumber of probable errors found: $num_errors\n"; print "\nView errors.txt for details.\n";