1 |
#!/usr/bin/perl -w |
#!/usr/bin/perl -w |
2 |
|
|
3 |
|
use strict; |
4 |
|
|
5 |
|
my @months = ( "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ); |
6 |
|
|
7 |
|
my $mon_nr=1; |
8 |
|
my %month2nr; |
9 |
|
foreach my $mon (@months) { |
10 |
|
$month2nr{$mon}=sprintf("%02d",$mon_nr); |
11 |
|
$mon_nr++; |
12 |
|
} |
13 |
|
|
14 |
my %count; |
my %count; |
15 |
|
my %get; |
16 |
|
my %post; |
17 |
|
|
18 |
while(<>) { |
while(<>) { |
19 |
chomp; |
chomp; |
20 |
if (m,\[(\d+/\w+/\d{4}:)(\d\d):(\d\d:)\d\d\s+\S+\]\s+"(\w+)\s+,) { |
if (m,\[(\d+)/(\w+)/(\d{4}):(\d\d):(\d\d):\d\d\s+\S+\]\s+"([^"]+)"\s+,) { |
21 |
my ($date,$hh,$mm,$method) = ($1,$2,$3,$4); |
my ($dd,$mmm,$yyyy,$hh,$mm,$method) = ($1,$2,$3,$4,$5,$6); |
22 |
$count{"$date$hh"}++; |
die "can't convert '$mmm' to number!" if (! defined($month2nr{$mmm})); |
23 |
|
# my $date="$yyyy-".$month2nr{$mmm}."-$dd $hh"; |
24 |
|
my $date="$yyyy-".$month2nr{$mmm}."-$dd 00"; |
25 |
|
if ($method =~ m/nn\.cgi/) { |
26 |
|
$count{$date}++; |
27 |
|
$get{$date}=0 if (! defined($get{$date})); |
28 |
|
$post{$date}=0 if (! defined($post{$date})); |
29 |
|
if ($method =~ m/get/i) { |
30 |
|
$get{$date}++; |
31 |
|
} else { |
32 |
|
$post{$date}++; |
33 |
|
} |
34 |
|
} |
35 |
} else { |
} else { |
36 |
print STDERR "line '$_' skipped!\n"; |
print STDERR "line '$_' skipped!\n"; |
37 |
} |
} |
38 |
} |
} |
39 |
|
|
40 |
foreach (keys %count) { |
foreach (keys %count) { |
41 |
print "$_\t$count{$_}\n"; |
print "$_\t$count{$_}\t$get{$_}\t$post{$_}\n"; |
42 |
} |
} |