#!/usr/bin/perl use strict; use warnings; use Getopt::Long; my $output; GetOptions('-output=s' => \$output); my $logfile = $ARGV[0]; print_usage() unless($logfile); my @errors = qw( FrontEndException SocketException ArrayIndexOutOfBoundsException NullPointerException LockedPinException AuthenticationException BusinessServiceException IllegalStateException NumberFormatException Exception NoSuchElementException RemoteException SQLException IOException FileNotFoundException ); my $string = ''; my ($key,$date,$time); open(my $fh,'<',$logfile) or die $!; while(my $line = <$fh>){ if($line =~ /Severity: Error/){ $hash{$key} = $string; $key = ''; $date = ''; $time = ''; } else{ $string .= $line; } if($line = /Date:/){ $date = $line; } elsif($line =~ /Zeit:/){ $time = $line; } if($date && $time){ $key = "serapis1".substr($Datum, 12, 4).substr($Datum, 9, 2).substr($Datum, 6, 2).$Zeit } for my $error(@errors){ if($line =~ /$error/){ $error_hash{$error}++; } } } close $fh; my $wh; if($output){ open(my $wh,'>>',$output) or die $!; } else{ $wh = STDOUT; } for my $key(sort(keys(%hash))){ print $wh $key,": ",$hash{$key},"\n"; } for my $error(@errors){ print $wh $error,": ",$error_hash{$error},"\n"; } close $wh; sub print_usage{ print qq~Usage: $0 [--output FILE] logfile\n~; exit; }