Diff for /loncom/loncron between versions 1.72 and 1.79

version 1.72, 2007/04/11 23:08:43 version 1.79, 2009/02/11 15:24:28
Line 33  use strict; Line 33  use strict;
 use lib '/home/httpd/lib/perl/';  use lib '/home/httpd/lib/perl/';
 use LONCAPA::Configuration;  use LONCAPA::Configuration;
 use Apache::lonnet;  use Apache::lonnet;
   use Apache::loncommon;
   
 use IO::File;  use IO::File;
 use IO::Socket;  use IO::Socket;
Line 62  sub errout { Line 63  sub errout {
 ENDERROUT  ENDERROUT
 }  }
   
   sub rotate_logfile {
       my ($file,$fh,$description) = @_;
       my $size=(stat($file))[7];
       if ($size>40000) {
    &log($fh,"<p>Rotating $description ...</p>");
    rename("$file.2","$file.3");
    rename("$file.1","$file.2");
    rename("$file","$file.1");
       } 
   }
   
 sub start_daemon {  sub start_daemon {
     my ($fh,$daemon,$pidfile,$args) = @_;      my ($fh,$daemon,$pidfile,$args) = @_;
     my $progname=$daemon;      my $progname=$daemon;
Line 69  sub start_daemon { Line 81  sub start_daemon {
  $progname='loncnew';    $progname='loncnew'; 
     }      }
     my $error_fname="$perlvar{'lonDaemons'}/logs/${daemon}_errors";      my $error_fname="$perlvar{'lonDaemons'}/logs/${daemon}_errors";
     my $size=(stat($error_fname))[7];      &rotate_logfile($error_fname,$fh,'error logs');
     if ($size>40000) {      if ($daemon eq 'lonc') {
  &log($fh,"<p>Rotating error logs ...</p>");   &clean_sockets($fh);
  rename("$error_fname.2","$error_fname.3");  
  rename("$error_fname.1","$error_fname.2");  
  rename("$error_fname","$error_fname.1");  
     }      }
     system("$perlvar{'lonDaemons'}/$progname 2>$perlvar{'lonDaemons'}/logs/${daemon}_errors");      system("$perlvar{'lonDaemons'}/$progname 2>$perlvar{'lonDaemons'}/logs/${daemon}_errors");
     sleep 1;      sleep 1;
Line 193  sub checkon_daemon { Line 202  sub checkon_daemon {
     }      }
           
     my $fname="$perlvar{'lonDaemons'}/logs/$daemon.log";      my $fname="$perlvar{'lonDaemons'}/logs/$daemon.log";
           &rotate_logfile($fname,$fh,'logs');
     my ($dev,$ino,$mode,$nlink,  
  $uid,$gid,$rdev,$size,  
  $atime,$mtime,$ctime,  
  $blksize,$blocks)=stat($fname);  
       
     if ($size>$maxsize) {  
  &log($fh,"<p>Rotating logs ...</p>");  
  rename("$fname.2","$fname.3");  
  rename("$fname.1","$fname.2");  
  rename("$fname","$fname.1");  
     }  
   
     &errout($fh);      &errout($fh);
     return $result;      return $result;
Line 307  sub start_logging { Line 305  sub start_logging {
 <li><a href="#lonsql">lonsql</a></li>  <li><a href="#lonsql">lonsql</a></li>
 <li><a href="#lond">lond</a></li>  <li><a href="#lond">lond</a></li>
 <li><a href="#lonc">lonc</a></li>  <li><a href="#lonc">lonc</a></li>
 <li><a href="#lonhttpd">lonhttpd</a></li>  
 <li><a href="#lonnet">lonnet</a></li>  <li><a href="#lonnet">lonnet</a></li>
 <li><a href="#connections">Connections</a></li>  <li><a href="#connections">Connections</a></li>
 <li><a href="#delayed">Delayed Messages</a></li>  <li><a href="#delayed">Delayed Messages</a></li>
Line 404  sub clean_lonIDs { Line 401  sub clean_lonIDs {
     &log($fh,"<h3>$active open session(s)</h3>");      &log($fh,"<h3>$active open session(s)</h3>");
 }  }
   
   # ----------------------------------------------------------- clean out sockets
   sub clean_sockets {
       my ($fh)=@_;
       my $cleaned=0;
       opendir(SOCKETS,$perlvar{'lonSockDir'});
       while (my $fname=readdir(SOCKETS)) {
    next if (-d $fname 
    || $fname=~/(mysqlsock|maximasock|\Q$perlvar{'lonSockDir'}\E)/);
    $cleaned++;
    &log($fh,"Unlinking $fname<br />");
    unlink("/home/httpd/sockets/$fname");
       }
       &log($fh,"<p>Cleaned up ".$cleaned." stale sockets.</p>");
   }
   
   
 # ----------------------------------------------------------------------- httpd  # ----------------------------------------------------------------------- httpd
 sub check_httpd_logs {  sub check_httpd_logs {
Line 450  sub rotate_lonnet_logs { Line 462  sub rotate_lonnet_logs {
     } else { &log($fh,"No perm log\n") }      } else { &log($fh,"No perm log\n") }
   
     my $fname="$perlvar{'lonDaemons'}/logs/lonnet.log";      my $fname="$perlvar{'lonDaemons'}/logs/lonnet.log";
       &rotate_logfile($fname,$fh,'lonnet log');
     my ($dev,$ino,$mode,$nlink,  
  $uid,$gid,$rdev,$size,  
  $atime,$mtime,$ctime,  
  $blksize,$blocks)=stat($fname);  
   
     if ($size>40000) {  
  &log($fh,"<p>Rotating logs ...</p>");  
  rename("$fname.2","$fname.3");  
  rename("$fname.1","$fname.2");  
  rename("$fname","$fname.1");  
     }  
   
     &log($fh,"</pre>");      &log($fh,"</pre>");
     &errout($fh);      &errout($fh);
 }  }
   
   sub rotate_other_logs {
       my ($fh) = @_;
       my $fname="$perlvar{'lonDaemons'}/logs/autoenroll.log";
       &rotate_logfile($fname,$fh,'Auto Enroll log');
       $fname="$perlvar{'lonDaemons'}/logs/autocreate.log";
       &rotate_logfile($fname,$fh,'Create Course log');
       $fname="$perlvar{'lonDaemons'}/logs/searchcat.log";
       &rotate_logfile($fname,$fh,'Search Cataloguing log');
   }
   
 # ----------------------------------------------------------------- Connections  # ----------------------------------------------------------------- Connections
 sub test_connections {  sub test_connections {
     my ($fh)=@_;      my ($fh)=@_;
Line 565  sub finish_logging { Line 576  sub finish_logging {
 }  }
   
 sub log_simplestatus {  sub log_simplestatus {
     rename ("$statusdir/newstatus.html","$statusdir/index.html");      rename("$statusdir/newstatus.html","$statusdir/index.html");
           
     my $sfh=IO::File->new(">$statusdir/loncron_simple.txt");      my $sfh=IO::File->new(">$statusdir/loncron_simple.txt");
     foreach (keys %simplestatus) {      foreach (keys %simplestatus) {
Line 577  sub log_simplestatus { Line 588  sub log_simplestatus {
   
 sub send_mail {  sub send_mail {
     print "sending mail\n";      print "sending mail\n";
     my $emailto="$perlvar{'lonAdmEMail'}";      my $defdom = $perlvar{'lonDefDomain'};
       my $origmail = $perlvar{'lonAdmEMail'};
       my $emailto = &Apache::loncommon::build_recipient_list(undef,
                                      'lonstatusmail',$defdom,$origmail);
     if ($totalcount>2500) {      if ($totalcount>2500) {
  $emailto.=",$perlvar{'lonSysEMail'}";   $emailto.=",$perlvar{'lonSysEMail'}";
     }      }
Line 629  sub main () { Line 643  sub main () {
     undef $perlvarref;      undef $perlvarref;
     delete $perlvar{'lonReceipt'}; # remove since sensitive and not needed      delete $perlvar{'lonReceipt'}; # remove since sensitive and not needed
     delete $perlvar{'lonSqlAccess'}; # remove since sensitive and not needed      delete $perlvar{'lonSqlAccess'}; # remove since sensitive and not needed
       chdir($perlvar{'lonDaemons'});
 # --------------------------------------- Make sure that LON-CAPA is configured  # --------------------------------------- Make sure that LON-CAPA is configured
 # I only test for one thing here (lonHostID).  This is just a safeguard.  # I only test for one thing here (lonHostID).  This is just a safeguard.
     if ('{[[[[lonHostID]]]]}' eq $perlvar{'lonHostID'}) {      if ('{[[[[lonHostID]]]]}' eq $perlvar{'lonHostID'}) {
Line 676  sub main () { Line 690  sub main () {
  &clean_lonIDs($fh);   &clean_lonIDs($fh);
  &check_httpd_logs($fh);   &check_httpd_logs($fh);
  &rotate_lonnet_logs($fh);   &rotate_lonnet_logs($fh);
    &rotate_other_logs($fh);
     }      }
     if (!$justcheckconnections && !$justreload) {      if (!$justcheckconnections && !$justreload) {
    &checkon_daemon($fh,'lonmemcached',40000);
  &checkon_daemon($fh,'lonsql',200000);   &checkon_daemon($fh,'lonsql',200000);
  if ( &checkon_daemon($fh,'lond',40000,'USR1') eq 'running') {   if ( &checkon_daemon($fh,'lond',40000,'USR1') eq 'running') {
     &checkon_daemon($fh,'lond',40000,'USR2');      &checkon_daemon($fh,'lond',40000,'USR2');
  }   }
  &checkon_daemon($fh,'lonc',40000,'USR1');   &checkon_daemon($fh,'lonc',40000,'USR1');
  &checkon_daemon($fh,'lonhttpd',40000);  
  &checkon_daemon($fh,'lonmemcached',40000);  
         &checkon_daemon($fh,'lonmaxima',40000);          &checkon_daemon($fh,'lonmaxima',40000);
     }      }
     if ($justreload) {      if ($justreload) {

Removed from v.1.72  
changed lines
  Added in v.1.79


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