Thread Logfile abarbeiten, brauche Denkanstoß
(6 answers)
Opened by FlorianL at 2010-11-19 11:59
Danke für die Hilfe :)
Ich habs jetzt so gelöst: Code (perl): (dl
)
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 #!/usr/bin/perl # Minecraft Logfile Audit # by m1ndgames for # Hexagon.de.tf ############################# use warnings; use strict; use FindBin '$Bin'; my @staff = ("m1ndgames", "Hexzel"); my $badwordsfile = "$Bin/badwords.db"; my $logfilepath = "/minecraft/bin/logs/"; my @logfiles = glob("$logfilepath*.log"); open( my $fh, '<', $badwordsfile ) or die("Error open $badwordsfile ($!)"); my @badwords = <$fh>; close($fh); chomp(@badwords); my @signreport; my @griefreport; for my $file (@logfiles) { open( my $fh, '<', $file ) or die("Error open $file ($!)"); my @logs = <$fh>; close($fh); foreach ( @logs ) { my $line = $_; if ( $line =~ /Line/ && grep { $line =~ /$_/ } @badwords ) { my $badline = $line; if ($badline =~ /(.+) \[INFO\] Line . : (.+)/) { my $date = $1; my $sign = $2; foreach ( @logs ) { if ($_ =~ /$date \[INFO\] Sign placed by (.+) at (.+)/) { push(@signreport,"$date - $1 placed Sign \"$sign\" at location: $2\n"); } } } } elsif ($line =~ /(.+) \[INFO\] Antigrief incident coordinates : (.+)/) { my $date = $1; my $location = $2; foreach ( @logs ) { if ($_ =~ /$date \[INFO\] Antigrief alarm : (.+)/) { push(@griefreport,"$date - Grief Alarm: $1 - Coordinates: $location\n"); } } } } } foreach(@signreport) { my $line = $_; if (grep { $line =~ /$_/ } @staff ) { shift; } else { print $_; } } foreach(@griefreport) { my $line = $_; if (grep { $line =~ /$_/ } @staff ) { shift; } else { print $_; } } Kann man sicherlich besser machen, aber es läuft ;) Last edited: 2010-11-19 14:10:39 +0100 (CET) |