Annotation of loncom/debugging_tools/user_login_count.pl, revision 1.2

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');
1.2     ! albertel   10: my @ignored_users=('^itds\d+$');
1.1       albertel   11: 
                     12: 
                     13: sub only_user_activitylog_files {
                     14:     print (join("\n",@_));
                     15:     return 1;
                     16: }
                     17: 
                     18: my %data;
                     19: my $numusers;
                     20: sub process_activitylog_file {
                     21:     if ($File::Find::dir=~m|/\d/\d/\d/|) { return; }
                     22:     if ($_ ne 'activity.log') {	return; }
                     23:     open(FILE,"<$File::Find::name");
                     24:     $numusers++;
                     25:     my $user=(split('/',$File::Find::dir))[-1];
1.2     ! albertel   26:     foreach my $expr (@ignored_users) {
        !            27: 	if ($user=~/$expr/) { print("\nignoring $user\n"); return; }
        !            28:     }
1.1       albertel   29:     while (my $line=<FILE>) {
                     30: 	if ($line !~ /Login/) { next; }
                     31: 	my ($date)=split(':',$line,2);
                     32: 	if ($date > $start_time) { $data{$user}++; }
                     33:     }
                     34:     if ($numusers%100 == 0) {
                     35: 	print "\b\b\b\b\b\b\b\b\b\b\b\b\b\bDid $user";
                     36:     }
                     37: }
                     38: 
                     39: sub print_data {
                     40:     my $total_login=0;
                     41:     my %byday;
                     42:     print("\n");
                     43:   my $i=0;
                     44:     foreach my $key (sort {$data{$b} <=> $data{$a}} (keys(%data))) {
                     45:         $i++;
                     46:         print "$key -> $data{$key}\n";
                     47:         if ($i>50) { last; }
                     48:     }
                     49: 
                     50: }
                     51: 
                     52: $|=1;
                     53: sub main {
                     54:     my $perlvar=LONCAPA::Configuration::read_conf('loncapa.conf');
                     55:     find(
                     56:          {
                     57: #          preprocess => \&only_user_activitylog_files,
                     58: #          wanted     => \&print_filename,
                     59: #          wanted     => \&log_metadata,
                     60: 	     wanted     => \&process_activitylog_file,
                     61: 	 }, 
                     62:          $perlvar->{'lonUsersDir'}.'/'.$perlvar->{'lonDefDomain'});
                     63:     &print_data();
                     64: }
                     65: &main();
                     66: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>