Annotation of loncom/debugging_tools/activity_to_accesscount.pl, revision 1.1
1.1 ! matthew 1: #!/usr/bin/perl -w
! 2: #
! 3: use strict;
! 4:
! 5: sub unescape {
! 6: my $str=shift;
! 7: $str =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
! 8: return $str;
! 9: }
! 10:
! 11: my %resourceaccess;
! 12:
! 13: sub main {
! 14: my $file=$ARGV[0];
! 15: print STDERR "Using $file\n";
! 16: my $line;
! 17: open FILEID,'<'.$file;
! 18: my @allaccess;
! 19: print STDERR "Access by resource\n\n";
! 20: my $numlines = 0;
! 21: while ($line=<FILEID>) {
! 22: $numlines++;
! 23: if (int($numlines / 1000)*1000 == $numlines) {
! 24: if (int($numlines / 10000)*10000 == $numlines) {
! 25: print STDERR '*';
! 26: } else {
! 27: print STDERR '.';
! 28: }
! 29: if (int($numlines / 50000)*50000 == $numlines) {
! 30: print STDERR $/;
! 31: }
! 32: }
! 33: next if ($line eq '' || $line !~ /:/);
! 34: chomp($line);
! 35: my ($time,$machine,$what)=split(':',$line);
! 36: $what=&unescape($what);
! 37: my @accesses = split(/(\d{10}):/,$what);
! 38: shift(@accesses);
! 39: while (@accesses) {
! 40: my $date = shift(@accesses);
! 41: my $access = shift(@accesses);
! 42: next if (! defined($access) || $access eq '' ||
! 43: ! defined($date) || $date eq '');
! 44: $access =~ s/(\&$|^:)//g;
! 45: my ($resource,$who,$domain,$post,@posts)=split(':',$access);
! 46: if (!$resource) {
! 47: next;
! 48: }
! 49: $resource = &unescape($resource);
! 50: if ($resource !~ m:/: || $resource =~ m:/prtspool/:) {
! 51: next;
! 52: }
! 53: if ($resource =~ /___\d+___/) {
! 54: (undef,$resource) = split(/___\d+___/,$resource);
! 55: }
! 56: next if ($resource =~ m:^/(res/adm|adm)/:);
! 57: $resource =~ s:^/?res/?::;
! 58: $resourceaccess{$resource}++;
! 59: }
! 60: }
! 61: print STDERR 'done.'.$/;
! 62: while (my ($resource,$count) = each(%resourceaccess)) {
! 63: print sprintf("%10.0f",$count).':'.$resource."\n";
! 64: }
! 65: }
! 66:
! 67: main;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>