Annotation of loncom/debugging_tools/user_login_count.pl, revision 1.1
1.1 ! albertel 1: use strict;
! 2: use File::Find;
! 3: use POSIX qw(strftime);
! 4: use lib '/home/httpd/lib/perl/';
! 5: use LONCAPA::Configuration;
! 6: use Date::Manip;
! 7:
! 8: my $start_time=&UnixDate("Aug 30th 00:00:00 2004","%s");
! 9: my @counts=('1','10','100','1000','10000','100000','250000');
! 10:
! 11:
! 12: sub only_user_activitylog_files {
! 13: print (join("\n",@_));
! 14: return 1;
! 15: }
! 16:
! 17: my %data;
! 18: my $numusers;
! 19: sub process_activitylog_file {
! 20: if ($File::Find::dir=~m|/\d/\d/\d/|) { return; }
! 21: if ($_ ne 'activity.log') { return; }
! 22: open(FILE,"<$File::Find::name");
! 23: $numusers++;
! 24: my $user=(split('/',$File::Find::dir))[-1];
! 25: while (my $line=<FILE>) {
! 26: if ($line !~ /Login/) { next; }
! 27: my ($date)=split(':',$line,2);
! 28: if ($date > $start_time) { $data{$user}++; }
! 29: }
! 30: if ($numusers%100 == 0) {
! 31: print "\b\b\b\b\b\b\b\b\b\b\b\b\b\bDid $user";
! 32: }
! 33: }
! 34:
! 35: sub print_data {
! 36: my $total_login=0;
! 37: my %byday;
! 38: print("\n");
! 39: my $i=0;
! 40: foreach my $key (sort {$data{$b} <=> $data{$a}} (keys(%data))) {
! 41: $i++;
! 42: print "$key -> $data{$key}\n";
! 43: if ($i>50) { last; }
! 44: }
! 45:
! 46: }
! 47:
! 48: $|=1;
! 49: sub main {
! 50: my $perlvar=LONCAPA::Configuration::read_conf('loncapa.conf');
! 51: find(
! 52: {
! 53: # preprocess => \&only_user_activitylog_files,
! 54: # wanted => \&print_filename,
! 55: # wanted => \&log_metadata,
! 56: wanted => \&process_activitylog_file,
! 57: },
! 58: $perlvar->{'lonUsersDir'}.'/'.$perlvar->{'lonDefDomain'});
! 59: &print_data();
! 60: }
! 61: &main();
! 62:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>