/[nn.old]/trunk/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

Diff of /trunk/stat/calc.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 63 by dpavlin, Thu Mar 7 12:18:51 2002 UTC revision 64 by dpavlin, Thu Mar 7 17:10:47 2002 UTC
# Line 1  Line 1 
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  }  }

Legend:
Removed from v.63  
changed lines
  Added in v.64

  ViewVC Help
Powered by ViewVC 1.1.26