/[nn]/stat/calc.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /stat/calc.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations)
Thu Mar 7 17:10:47 2002 UTC (17 years, 3 months ago) by dpavlin
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +29 -4 lines
File MIME type: text/plain
misc

1 #!/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;
15 my %get;
16 my %post;
17
18 while(<>) {
19 chomp;
20 if (m,\[(\d+)/(\w+)/(\d{4}):(\d\d):(\d\d):\d\d\s+\S+\]\s+"([^"]+)"\s+,) {
21 my ($dd,$mmm,$yyyy,$hh,$mm,$method) = ($1,$2,$3,$4,$5,$6);
22 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 {
36 print STDERR "line '$_' skipped!\n";
37 }
38 }
39
40 foreach (keys %count) {
41 print "$_\t$count{$_}\t$get{$_}\t$post{$_}\n";
42 }

  ViewVC Help
Powered by ViewVC 1.1.26