~clint-fewbar/ubuntu/precise/squid3/ignore-sighup-early

« back to all changes in this revision

Viewing changes to contrib/user-agents.pl

  • Committer: Bazaar Package Importer
  • Author(s): Luigi Gangitano
  • Date: 2006-11-11 10:32:06 UTC
  • Revision ID: james.westby@ubuntu.com-20061111103206-f3p0r9g0vq44rp3r
Tags: upstream-3.0.PRE5
ImportĀ upstreamĀ versionĀ 3.0.PRE5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
#
 
3
# John@MCC.ac.uk
 
4
# John@Pharmweb.NET
 
5
 
 
6
require "getopts.pl";
 
7
&Getopts('FML:');
 
8
 
 
9
open (ACCESS, "/opt/Squid/logs/useragent.0");
 
10
 
 
11
while (<ACCESS>) {
 
12
        ($host, $timestamp, $agent) = 
 
13
        /^(\S+) \[(.+)\] \"(.+)\"\s/;
 
14
        if ($agent ne '-') {
 
15
                if ($opt_M) {
 
16
                        $agent =~ tr/\// /;
 
17
                        $agent =~ tr/\(/ /;
 
18
                }
 
19
                if ($opt_F) {
 
20
                        next unless $seen{$agent}++;
 
21
                } else {
 
22
                        @inline=split(/ /, $agent);
 
23
                        next unless $seen{$inline[0]}++;
 
24
                }
 
25
        }
 
26
}
 
27
 
 
28
$total=0;
 
29
if (!$opt_L) {$opt_L=0}
 
30
 
 
31
print "Summary of User-Agent Strings\n(greater than $opt_L percent)\n\n";
 
32
 
 
33
foreach $browser (keys(%seen)) {
 
34
        $total=$total+$seen{$browser};
 
35
}
 
36
 
 
37
foreach $browser (sort keys(%seen)) {
 
38
        $percent=$seen{$browser}/$total*100;
 
39
        if ($percent >= $opt_L) { write; }
 
40
}
 
41
 
 
42
print "\n\nTotal entries in log = $total\n";
 
43
 
 
44
format STDOUT =
 
45
@>>>>>>> :@##.####% : @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
46
$seen{$browser}, $percent, $browser
 
47
.