wiki.pl: Port some fixes from upstream
[Orgmuse.git] / action-list
blob9fb8bfb7a025f3ad8bd7bf2aa1c51e1b89b19323
1 #!/usr/bin/perl
2 # Copyright (C) 2006 Alex Schroeder <alex@emacswiki.org>
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the
16 # Free Software Foundation, Inc.
17 # 59 Temple Place, Suite 330
18 # Boston, MA 02111-1307 USA
19 use Time::ParseDate;
20 while (<STDIN>) {
21 m/^(\S+) \S+ \S+ \[(.*?)\] "(.*?)" (\d+)/ or die "Cannot parse:\n$_";
22 $ip = $1;
23 $ts = $2;
24 $url = $3;
25 $code = $4;
26 $time = parsedate($ts);
27 $total++;
28 if ($url =~ /action=([a-z]+)/) {
29 $action = $1;
30 } else {
31 $action = 'browse'; # default action
33 $action .= " [$code]";
34 $count{$action}++;
35 $latest{$action} = $ts; # assuming chronological order in the log file
37 @result = sort {$count{$b} <=> $count{$a}} keys %count;
38 foreach $action (@result) {
39 printf "%20s %10d %3d%% %s\n", $action, $count{$action}, 100* $count{$action} / $total,
40 $latest{$action};