user-agents.pl
上传用户:liugui
上传日期:2007-01-04
资源大小:822k
文件大小:1k
- #!/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 Stringsn(greater than $opt_L percent)nn";
- foreach $browser (keys(%seen)) {
- $total=$total+$seen{$browser};
- }
- foreach $browser (sort keys(%seen)) {
- $percent=$seen{$browser}/$total*100;
- if ($percent >= $opt_L) { write; }
- }
- print "nnTotal entries in log = $totaln";
- format STDOUT =
- @>>>>>>> :@##.####% : @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- $seen{$browser}, $percent, $browser
- .