Created
March 1, 2016 21:14
-
-
Save kszarek/298417d0910ae5b9b9e1 to your computer and use it in GitHub Desktop.
Perl script to get uniq IP by path from heroku logs
This file contains hidden or 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 | |
use warnings; | |
use strict; | |
use Data::Dumper; | |
# cat 2016-02-29.timeout.log|./timeouts-webapp-by-url-ip.pl>2016-02-29.timeouts_path_uniq.csv | |
my $a; | |
while (<>) { | |
if (/path="(\S+?("|\?|\/\d+?)).+fwd="(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/) { | |
my ($path,$ip) = ($1,$3); | |
$a->{$path}->{'uniq_ip'}++ if !exists $a->{$path}->{$ip}; | |
$a->{$path}->{$ip}++; | |
} | |
} | |
foreach my $path (sort keys %{$a}){ | |
print "$path,$a->{$path}->{'uniq_ip'}\n"; | |
} | |
# print Dumper($a); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment