Last active
August 29, 2015 14:10
-
-
Save ixti/9a5fb9e814a29229f8d2 to your computer and use it in GitHub Desktop.
Simple apache logs parser and counter of calls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
while (<>) { | |
if (/^[^"]+"([A-Z]+)\s([^"? ]+)[^"]*"\s(\d+)/) { | |
my $m = $1; | |
my $p = $2; | |
my $s = $3; | |
$p =~ s/^[a-f0-9]{8}(-[a-f0-9]{4}){3}-[a-f0-9]{12}$/{uuid}/; | |
$records{ "$m $p [$s]" } += 1; | |
} | |
} | |
while (my ($key, $value) = each(%records)) { | |
print "$key x$value\n"; | |
} |
Output:
GET /foo [200] x123
POST /bar [200] x91
GET /baz [200] x100
GET /baz [500] x31
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: