8 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
while ( <lesen2> ) {
push @lines, $_;
my $Datum = $_ if m/Date: /;
my $Zeit = $_ if m/Zeit: /;
push @lines, $_;
$Zeit =~ s/\D//g;
#generierung von einem key
my $dt = "serapis1".substr($Datum, 12, 4).substr($Datum, 9, 2).substr($Datum, 6, 2).$Zeit;
if ( /^\s*$/ ) {
if ($errorFound eq 1) {
my %hashref = ($dt => @lines);
@lines = '';
$errorFound = 0;
}
}
$errorFound = 1 if /Severity: Error/;
m/NullPointerException/;
$LockedPinException++ if m/LockedPinException/;
$AuthenticationException++ if m/AuthenticationException/;
$Exception++ if m/\.Exception/;
$NoSuchElementException++ if m/NoSuchElementException/;
$RemoteException++ if m/RemoteException/;
}
while (($dt, @lines) = each %ENV) {
print OUT "$dt => @lines\n";
}
1
2
3
4
5
6
7
8
solange du eine zeile aus dem FH lesen lesen kannst, wird die zeile $_ zugewiesen
fuege die zeile (inkl. zeilenumbruch) ans ende von @lines an
wenn in der Zeile Date: steht, speichere sie in $Datum
wenn in der Zeile Zeit: steht, speichere sie in $Zeit
fuege die zeile (inkl. zeilenumbruch) nochmal ans ende von @lines an
loesche aus $Zeit alle Zeichen, die keine Ziffern sind, egal, ob $Zeit befuellt ist oder nicht
baue einen Key zusammen => $dt
...
if ($errorFound eq 1)
if ($errorFound == 1)
if ($errorFound)
m/NullPointerException/;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
use strict;
use warnings;
use Getopt::Long;
# the cmd-line-arg --output
my $output = 0;
GetOptions(
'output=s' => \$output,
);
#my $write_file = "/iwmnt/default/main/test-dekabank-01/WORKAREA/dev-deka/trxlogfile.txt";
my $write_file = "c:/trxlogfile.txt";
# print usage, if no logFile is
# given as cmd-line-arg
die "usage: TrxLogParser.pl [--output FILE] logFile\n"
unless $ARGV[0];
open (lesen1, "<$ARGV[0]") || die "Kann datei1 Nicht lesen: $!";
open (lesen2, "<$ARGV[1]") || die "Kann datei2 Nicht lesen: $!";
open( OUT, ">>$write_file" ) || die "Kann die Datei nicht erzeugen: $!";
# the lines and the errorFound-flag
my @lines;
my %hashref;
my $errorFound = 0;
my $FrontEndException = 0;
my $SocketException = 0;
my $ArrayIndexOutOfBoundsException = 0;
my $NullPointerException = 0;
my $LockedPinException = 0;
my $AuthenticationException = 0;
my $BusinessServiceException = 0;
my $IllegalStateException = 0;
my $NumberFormatException = 0;
my $Exception = 0;
my $NoSuchElementException = 0;
my $RemoteException = 0;
my $SQLException = 0;
my $IOException = 0;
my $FileNotFoundException = 0;
while ( <lesen1> ) {
push @lines, $_;
my $Datum = $_ if m/Date: /;
my $Zeit = $_ if m/Zeit: /;
push @lines, $_;
$Zeit =~ s/\D//g;
my $dt = "kemuer1".substr($Datum, 12, 4).substr($Datum, 9, 2).substr($Datum, 6, 2).$Zeit;
#hier erfolgt das zusammensetzten der string im richtig schlssel string
if ( /^\s*$/ ) {
if ($errorFound eq 1) {
%hashref = ($dt => @lines);
@lines = '';
$errorFound = 0;
}
}
$errorFound = 1 if /Severity: Error/;
$FrontEndException++ if m/FrontEndException/;
$SocketException++ if m/socketException/;
$ArrayIndexOutOfBoundsException++ if m/ArrayIndexOutOfBoundsException/;
$NullPointerException++ if m/NullPointerException/;
$LockedPinException++ if m/LockedPinException/;
$AuthenticationException++ if m/AuthenticationException/;
$BusinessServiceException++ if m/\.BusinessServiceException/;
$IllegalStateException++ if m/IllegalStateException/;
$NumberFormatException++ if m/NumberFormatException/;
$Exception++ if m/\.Exception/;
$NoSuchElementException++ if m/NoSuchElementException/;
$RemoteException++ if m/RemoteException/;
$SQLException++ if m/SQLException/;
$IOException++ if m/IOException/;
$FileNotFoundException++ if m/FileNotFoundException/;
foreach $dt (keys %hashref) {
print OUT "$dt => @lines\n";
}
while ( <lesen2> ) {
push @lines, $_;
my $Datum = $_ if m/Date: /;
my $Zeit = $_ if m/Zeit: /;
push @lines, $_;
$Zeit =~ s/\D//g;
#generierung von einem key
my $dt = "serapis1".substr($Datum, 12, 4).substr($Datum, 9, 2).substr($Datum, 6, 2).$Zeit;
if ( /^\s*$/ ) {
if ($errorFound eq 1) {
my %hashref = ($dt => @lines);
@lines = '';
$errorFound = 0;
}
}
$errorFound = 1 if /Severity: Error/;
$FrontEndException++ if m/FrontEndException/;
$SocketException++ if m/socketException/;
$ArrayIndexOutOfBoundsException++ if m/ArrayIndexOutOfBoundsException/;
$NullPointerException++ if m/NullPointerException/;
$LockedPinException++ if m/LockedPinException/;
$AuthenticationException++ if m/AuthenticationException/;
$BusinessServiceException++ if m/\.BusinessServiceException/;
$IllegalStateException++ if m/IllegalStateException/;
$NumberFormatException++ if m/NumberFormatException/;
$Exception++ if m/\.Exception/;
$NoSuchElementException++ if m/NoSuchElementException/;
$RemoteException++ if m/RemoteException/;
$SQLException++ if m/SQLException/;
$IOException++ if m/IOException/;
$FileNotFoundException++ if m/FileNotFoundException/;
foreach $dt (keys %hashref) {
print OUT "$dt => @lines\n";
}
#end for schleife
#}
}
print OUT "FrontEndException: $FrontEndException\n
SocketException: $SocketException\n
ArrayIndexOutOfBoundsException: $ArrayIndexOutOfBoundsException\n
NullPointerException: $NullPointerException\n
LockedPinException: $LockedPinException\n
AuthenticationException: $AuthenticationException\n
BusinessServiceException: $BusinessServiceException\n
IllegalStateException: $IllegalStateException\n
NumberFormatException: $NumberFormatException\n
Exception: $Exception\n
NoSuchElementException: $NoSuchElementException\n
RemoteException: $RemoteException\n
SQLException: $SQLException\n
IOException: $IOException\n
FileNotFoundException: $FileNotFoundException\n";
# close the handle
close OUT;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/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;
}
8 Einträge, 1 Seite |