Tue Oct 16 17:48:03 2018
####
[file1] TIMESTAMP=Wed Oct 5 04:08:28 2018...
...
[file1] TIMESTAMP=Fri Nov 2 14:11:28 2018...
[file2] TIMESTAMP=Tue Oct 16 17:10:00 2018...
...
[file2] TIMESTAMP=Fri Nov 2 14:11:03 2018...
####
<13>{Mangled Date/Time} [pid]:
TIMESTAMP={I'm using this timestamp}
MSGCLS=
Title=
Severity=
message =
...
Message Id=
END OF REPORT
####
foreach my $log (@CommonLogFiles) {
print "Now Processing $log....\n";
open LOG, "$datadir/$log" or die "LOG $log: $!\n";
print "Just opened $datadir/$log...\n";
$linecnt = 0;
while () {
chomp $_;
$linecnt++;
if ( $linecnt == "1" ) {
$line .= "[$log] ";
}
$line .= $_;
push @lines, "$line\n";
#print "Just added " . $line . " to the lines array...\n";
$line = "";
$linecnt = 0;
}
close LOG;
}
print APPLOG "Files parsed and data inserted into array for further processing...\n";
@sortedlines = sort { ($a =~ /^\<\d+\>\w+\s+\d+:\d+:\d+\s+\w+:TIMESTAMP\=(\w+\s+\w+\s+\d+\s+\d+:\d+:\d+\s+\d+).*MSGCLS.*$/m)[0] cmp ($b =~ /^\<\d+\>\w+\s+\d+:\d+:\d+\s+\w+:TIMESTAMP\=(\w+\s+\w+\s+\d+\s+\d+:\d+:\d+\s+\d+).*MSGCLS.*$/m)[0] } @lines;
print SORTED "@sortedlines\n";
print APPLOG "Log files merged together with events in time order...\n";
close SORTED;