/ Published in: Perl
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#!/usr/bin/perl -w use strict; # # List apache server clients IPs by occurence (with country and provider info) # perl administration web log apache # my %ips; my $logfile = '/var/log/apache2/access.log'; # # hash ip occurences while (<$fh>) { $ips{$1}++ if (/^(\d+\.\d+\.\d+\.\d+)/); } # # sort ip by occurence and print # get whois data, parse and print my ($country, $descr) = ('', ''); if ($result =~ /country:\s+(\w+)/) { $country = $1; } if ($result =~ /descr:\s+(.+?)\n/) { $descr = $1 ; } } # # command line alternative (without dns info): # awk '{print $1}' /var/log/apache2/access.log | sort | uniq -c