| Server IP : 182.53.201.61 / Your IP : 216.73.217.175 Web Server : Apache/2.2.15 (Fedora) System : Linux km10.dyndns.org 2.6.31.5-127.fc12.i686.PAE #1 SMP Sat Nov 7 21:25:57 EST 2009 i686 User : apache ( 48) PHP Version : 5.3.3 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/share/doc/squid-3.1.0.14/ |
Upload File : |
#!/usr/bin/perl
#
# John@MCC.ac.uk
# John@Pharmweb.NET
require "getopts.pl";
&Getopts('FML:');
open (ACCESS, "/opt/Squid/logs/useragent.0");
while (<ACCESS>) {
($host, $timestamp, $agent) =
/^(\S+) \[(.+)\] \"(.+)\"\s/;
if ($agent ne '-') {
if ($opt_M) {
$agent =~ tr/\// /;
$agent =~ tr/\(/ /;
}
if ($opt_F) {
next unless $seen{$agent}++;
} else {
@inline=split(/ /, $agent);
next unless $seen{$inline[0]}++;
}
}
}
$total=0;
if (!$opt_L) {$opt_L=0}
print "Summary of User-Agent Strings\n(greater than $opt_L percent)\n\n";
foreach $browser (keys(%seen)) {
$total=$total+$seen{$browser};
}
foreach $browser (sort keys(%seen)) {
$percent=$seen{$browser}/$total*100;
if ($percent >= $opt_L) { write; }
}
print "\n\nTotal entries in log = $total\n";
format STDOUT =
@>>>>>>> :@##.####% : @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$seen{$browser}, $percent, $browser
.