sub LastDalLoad { my $ContentsLoadMsg = shift; my $logFile = "$ENV{ MIS_ROOT }/log/loadmsg_1.log"; my @Result; my $Command; my $indLines; my $finishedLine; my $beginningLine; my $found; my @beginningTime; my @finishedTime; my $maxSecondsAnHour; my @datePart; my @checkDate; my @checkTime; my $beginningInSeconds; my $finishedInSeconds; my $actualInSeconds; my $timeDiff; my $startDiff; my $status = $TRUE; # # Check the status of MIS as stated in mistrap.log # if( ( $statusLoadmsg = &FileExists( $logFile ) ) == $FALSE ) { &ResCode("WARNING"); &BrowseCode("File \"$logFile\" not found"); &SummaryCode("WARNING"); return $WARNING; } # # read whole log file # if( &readFileContents( $logFile, $ContentsLoadMsg ) == $FALSE ) { &ResCode("E_LOADMSG_ERROR"); : &BrowseCode("Could not open \"$logFile\""); &SummaryCode("E_MISLOAD_ERROR"); return $FALSE; } # # find out last load # $finishedLine = ""; $beginningLine = ""; $indLines = $#{ $ContentsLoadMsg }; while ( $indLines > -1 and ( length( $finishedLine ) == 0 or length( $beginningLine ) == 0 ) ) { if( ${ $ContentsLoadMsg }[ $indLines ] =~ /The utility has finished/ ) { $finishedLine = ${ $ContentsLoadMsg }[ $indLines ] . " " . ${ $ContentsLoadMsg }[ $indLines + 1 ]; } elsif( ${ $ContentsLoadMsg }[ $indLines ] =~ /The utility is beginning/ ) { $beginningLine = ${ $ContentsLoadMsg }[ $indLines ] . " " . ${ $ContentsLoadMsg } [ $indLines + 1 ]; } $indLines --; } # # last load # @beginningTime = &getLineParts( $beginningLine, 4, 4, "\"" ); @finishedTime = &getLineParts( $finishedLine, 4, 4, "\"" ); # # get actual day and time # ( $day, $month, $year ) = &getActualDate; ( $hour, $minute, $second ) = &getActualTime; # get max seconds of a day $maxSecondsAnHour = &getTimeInSeconds( 23, 59, 59 ) + 1; # # get values of DAL load start : # # get pure date part @datePart = &getLineParts( $beginningTime[0], 1, 2 ); @checkDate = &getLineParts( $datePart[0], 1, 3, "-" ); # get pure time part @checkTime = &getLineParts( $datePart[1], 1, 1, "." ); @checkTime = &getLineParts( $checkTime[0], 1, 3, ":" ); # get time of DAL load start in seconds $beginningInSeconds = &getTimeInSeconds( $checkTime[0], $checkTime[1], $checkTime[2] ); # get actual time in seconds $actualInSeconds = &getTimeInSeconds( $hour, $minute, $second ); # get difference in days of actual day and last DAL file load start $Command = "db2 \"values (julian_day('$year-$month-$day') - "; $Command .= " julian_day('$checkDate[2]-$checkDate[0]-$checkDate[1]'))\" "; if( &executeSQL( $Command, \@Result ) == $FALSE ) { &ResCode("E_DB2_ERROR"); &BrowseCode("It was not possible to execute an SQL command"); &SummaryCode("E_MISLOAD_ERROR"); return $FALSE; } # get the value of the previous SQL call for days difference $startDiff = &getFirstNonBlank( $Result[3] ); # is DAL file from same day if( $startDiff == 0 ) { $timeDiff = $actualInSeconds - $beginningInSeconds; # have more than MIS_MAX_DALLOADTIMEPASS_H hours gone after the last DAL files was l oaded if( $timeDiff > &getTimeInSeconds( $Configuration{ MIS_MAX_DALLOADTIMEPASS_H }, 0, 0 ) ) { &ResCode("WARNING"); &BrowseCode("Last DAL load operation was started more than $Configuration{ MIS_MA X_DALLOADTIMEPASS_H } hours ago"); $status = $WARNING; } else { &ResCode("OK"); &BrowseCode("Last DAL load operation started at @beginningTime"); } } # is DAL file from yesterday ( check if time difference over midnight is within range ) elsif( $startDiff == 1 ) { $timeDiff = $maxSecondsAnHour - $beginningInSeconds; $timeDiff += $actualInSeconds; # have more than MIS_MAX_DALLOADTIMEPASS_H hours gone after the last DAL files was l oaded if( $timeDiff > &getTimeInSeconds( $Configuration{ MIS_MAX_DALLOADTIMEPASS_H }, 0, 0 ) ) { &ResCode("WARNING"); &BrowseCode("Last DAL load operation was started more than $Configuration{ MIS_MAX_DALLOADTIMEPASS_H } hours ago"); $status = $WARNING; } else { &ResCode("OK"); &BrowseCode("Last DAL load operation started at @beginningTime"); } } # DAL file is more than one day old else { &ResCode("WARNING"); &BrowseCode("Last DAL load operation started at @beginningTime"); $status = $WARNING; } # # get values of DAL load end # # get pure date part @datePart = &getLineParts( $finishedTime[0], 1, 2 ); @checkDate = &getLineParts( $datePart[0], 1, 3, "-" ); # get pur time part @checkTime = &getLineParts( $datePart[1], 1, 1, "." ); @checkTime = &getLineParts( $checkTime[0], 1, 3, ":" ); # get time of DAL load start in seconds $finishedInSeconds = &getTimeInSeconds( $checkTime[0], $checkTime[1], $checkTime[2] ); # get difference in days of actual day and last DAL file load start $Command = "db2 \"values (julian_day('$year-$month-$day') - "; $Command .= " julian_day('$checkDate[2]-$checkDate[0]-$checkDate[1]'))\" "; if( &executeSQL( $Command, \@Result ) == $FALSE ) { &ResCode("E_DB2_ERROR"); &BrowseCode("It was not possible to execute an SQL command"); &SummaryCode("E_MISLOAD_ERROR"); return $FALSE; } # get the value of the previous SQL call for days difference $startDiff = &getFirstNonBlank( $Result[3] ); # is DAL file from same day if( $startDiff == 0 ) { $timeDiff = $actualInSeconds - $finishedInSeconds; # have more than MIS_MAX_DALLOADTIMEPASS_H hours gone after the last DAL files was l oaded if( $timeDiff > &getTimeInSeconds( $Configuration{ MIS_MAX_DALLOADTIMEPASS_H }, 0, 0 ) ) { &ResCode("WARNING"); &BrowseCode("Last DAL load operation ended more than $Configuration{ MIS_MAX_DALLOADTIMEPASS_H } hours ago"); $status = $WARNING; } else { &ResCode("OK"); &BrowseCode("Last DAL load operation ended at @finishedTime"); } } # is DAL file from yesterday ( check if time difference over midnight is within range ) elsif( $startDiff == 1 ) { $timeDiff = $maxSecondsAnHour - $finishedInSeconds; $timeDiff += $actualInSeconds; # have more than MIS_MAX_DALLOADTIMEPASS_H hours gone after the last DAL files was loaded if( $timeDiff > &getTimeInSeconds( $Configuration{ MIS_MAX_DALLOADTIMEPASS_H }, 0, 0 ) ) { &ResCode("WARNING"); &BrowseCode("Last DAL load operation ended more than $Configuration{ MIS_MAX_DALLOADTIMEPASS_H } hours ago"); $status = $WARNING; } else { &ResCode("OK"); &BrowseCode("Last DAL load operation ended at @finishedTime"); } } # DAL file is more than one day old else { &ResCode("WARNING"); &BrowseCode("Last DAL load operation ended at @finishedTime"); $status = $WARNING; } if( $status == $TRUE ) { &SummaryCode("OK"); } elsif( $status == $WARNING ) { &SummaryCode("WARNING"); } else { &SummaryCode("E_MISLOAD_ERROR"); } return $status; } #### SQL3109N The utility is beginning to load data from file "/home/mis/jer/tMIS/MIS.05.23-TIX2/dalfiles/loadfiles//20050404_120000_". SQL3500W The utility is beginning the "LOAD" phase at time "04-29-2005 12:26:10.994507". SQL3112W There are fewer input file columns specified than database columns. SQL3519W Begin Load Consistency Point. Input record count = "5". SQL3520W Load Consistency Point was successful. SQL3110N The utility has completed processing. "7" rows were read from the input file. SQL3519W Begin Load Consistency Point. Input record count = "7". SQL3520W Load Consistency Point was successful. SQL3515W The utility has finished the "LOAD" phase at time "04-29-2005 12:26:11.761926".