Diff for /loncom/loncron between versions 1.101 and 1.103.2.2

version 1.101, 2014/12/16 18:18:44 version 1.103.2.2, 2019/02/10 03:02:10
Line 111  sub checkon_daemon { Line 111  sub checkon_daemon {
     my $result;      my $result;
     &log($fh,'<hr /><a name="'.$daemon.'" /><h2>'.$daemon.'</h2><h3>Log</h3><p style="white-space: pre;"><tt>');      &log($fh,'<hr /><a name="'.$daemon.'" /><h2>'.$daemon.'</h2><h3>Log</h3><p style="white-space: pre;"><tt>');
     printf("%-15s ",$daemon);      printf("%-15s ",$daemon);
     if (-e "$perlvar{'lonDaemons'}/logs/$daemon.log"){      if ($fh) {
  open (DFH,"tail -n25 $perlvar{'lonDaemons'}/logs/$daemon.log|");          if (-e "$perlvar{'lonDaemons'}/logs/$daemon.log"){
  while (my $line=<DFH>) {       if (open(DFH,"tail -n25 $perlvar{'lonDaemons'}/logs/$daemon.log|")) {
     &log($fh,"$line");          while (my $line=<DFH>) {
     if ($line=~/INFO/) { $notices++; }              &log($fh,"$line");
     if ($line=~/WARNING/) { $notices++; }              if ($line=~/INFO/) { $notices++; }
     if ($line=~/CRITICAL/) { $warnings++; }              if ($line=~/WARNING/) { $notices++; }
  };              if ($line=~/CRITICAL/) { $warnings++; }
  close (DFH);          }
           close (DFH);
               }
           }
           &log($fh,"</tt></p>");
     }      }
     &log($fh,"</tt></p>");     
       
     my $pidfile="$perlvar{'lonDaemons'}/logs/$daemon.pid";      my $pidfile="$perlvar{'lonDaemons'}/logs/$daemon.pid";
           
     my $restartflag=1;      my $restartflag=1;
Line 164  sub checkon_daemon { Line 167  sub checkon_daemon {
     `killall -9 $kadaemon 2>&1`.      `killall -9 $kadaemon 2>&1`.
     '</font><br />');      '</font><br />');
  &log($fh,"<h3>$daemon not running, trying to start</h3>");   &log($fh,"<h3>$daemon not running, trying to start</h3>");
   
  if (&start_daemon($fh,$daemon,$pidfile,$args)) {   if (&start_daemon($fh,$daemon,$pidfile,$args)) {
     &log($fh,"<h3>$daemon at pid $daemonpid responding</h3>");      &log($fh,"<h3>$daemon at pid $daemonpid responding</h3>");
     $simplestatus{$daemon}='restarted';      $simplestatus{$daemon}='restarted';
Line 189  sub checkon_daemon { Line 192  sub checkon_daemon {
  &log($fh,"<p>Unable to start $daemon</p>");   &log($fh,"<p>Unable to start $daemon</p>");
     }      }
  }   }
           if ($fh) {
  if (-e "$perlvar{'lonDaemons'}/logs/$daemon.log"){      if (-e "$perlvar{'lonDaemons'}/logs/$daemon.log"){
     &log($fh,"<p><pre>");          &log($fh,"<p><pre>");
     open (DFH,"tail -n100 $perlvar{'lonDaemons'}/logs/$daemon.log|");          if (open(DFH,"tail -n100 $perlvar{'lonDaemons'}/logs/$daemon.log|")) {
     while (my $line=<DFH>) {               while (my $line=<DFH>) { 
  &log($fh,"$line");          &log($fh,"$line");
  if ($line=~/WARNING/) { $notices++; }          if ($line=~/WARNING/) { $notices++; }
  if ($line=~/CRITICAL/) { $notices++; }          if ($line=~/CRITICAL/) { $notices++; }
     };              }
     close (DFH);              close (DFH);
     &log($fh,"</pre></p>");                  }
  }          &log($fh,"</pre></p>");
       }
           }
     }      }
           
     my $fname="$perlvar{'lonDaemons'}/logs/$daemon.log";      my $fname="$perlvar{'lonDaemons'}/logs/$daemon.log";
Line 300  sub start_logging { Line 305  sub start_logging {
 <li><a href="#machine">Machine Information</a></li>  <li><a href="#machine">Machine Information</a></li>
 <li><a href="#tmp">Temporary Files</a></li>  <li><a href="#tmp">Temporary Files</a></li>
 <li><a href="#tokens">Session Tokens</a></li>  <li><a href="#tokens">Session Tokens</a></li>
   <li><a href="#webdav">WebDAV Session Tokens</a></li>
 <li><a href="#httpd">httpd</a></li>  <li><a href="#httpd">httpd</a></li>
 <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>
Line 499  sub clean_lonIDs { Line 505  sub clean_lonIDs {
     &log($fh,"<h3>$active open session(s)</h3>");      &log($fh,"<h3>$active open session(s)</h3>");
 }  }
   
   # ------------------------------------------------ clean out webDAV Session IDs
   sub clean_webDAV_sessionIDs {
       my ($fh)=@_;
       if ($perlvar{'lonRole'} eq 'library') {
           &log($fh,'<hr /><a name="webdav" /><h2>WebDAV Session Tokens</h2>');
           my $cleaned=0;
           my $active=0;
           my $now = time;
           if (-d $perlvar{'lonDAVsessDir'}) {
               while (my $fname=<$perlvar{'lonDAVsessDir'}/*>) {
                   my @stats = stat($fname);
                   my $since=$now-$stats[9];
                   if ($since>$perlvar{'lonExpire'}) {
                       $cleaned++;
                       &log($fh,"Unlinking $fname<br />");
                       unlink("$fname");
                   } else {
                       $active++;
                   }
               }
               &log($fh,"<p>Cleaned up ".$cleaned." stale webDAV session token(s).</p>");
               &log($fh,"<h3>$active open webDAV session(s)</h3>");
           }
       }
   }
   
 # ----------------------------------------------------------- clean out sockets  # ----------------------------------------------------------- clean out sockets
 sub clean_sockets {  sub clean_sockets {
     my ($fh)=@_;      my ($fh)=@_;
Line 617  sub check_delayed_msg { Line 649  sub check_delayed_msg {
   
     my $unsend=0;      my $unsend=0;
   
       my %hostname = &Apache::lonnet::all_hostnames();
       my $numhosts = scalar(keys(%hostname));
   
     my $dfh=IO::File->new("$perlvar{'lonDaemons'}/logs/lonnet.perm.log");      my $dfh=IO::File->new("$perlvar{'lonDaemons'}/logs/lonnet.perm.log");
     while (my $line=<$dfh>) {      while (my $line=<$dfh>) {
  my ($time,$sdf,$dserv,$dcmd)=split(/:/,$line);   my ($time,$sdf,$dserv,$dcmd)=split(/:/,$line);
           if ($numhosts) {
               next unless ($hostname{$dserv});
           }
  if ($sdf eq 'F') {    if ($sdf eq 'F') { 
     my $local=localtime($time);      my $local=localtime($time);
     &log($fh,"<b>Failed: $time, $dserv, $dcmd</b><br />");      &log($fh,"<b>Failed: $time, $dserv, $dcmd</b><br />");
Line 646  sub check_delayed_msg { Line 684  sub check_delayed_msg {
     }      }
     &log($fh,"</pre>\n");      &log($fh,"</pre>\n");
     close (DFH);      close (DFH);
     my %hostname = &Apache::lonnet::all_hostnames();  
     my $numhosts = scalar(keys(%hostname));  
 # pong to all servers that have delayed messages  # pong to all servers that have delayed messages
 # this will trigger a reverse connection, which should flush the buffers  # this will trigger a reverse connection, which should flush the buffers
     foreach my $tryserver (sort(keys(%servers))) {      foreach my $tryserver (sort(keys(%servers))) {
Line 877  sub main () { Line 913  sub main () {
  chop $hostname;   chop $hostname;
  $hostname=~s/[^\w\.]//g; # make sure is safe to pass through shell   $hostname=~s/[^\w\.]//g; # make sure is safe to pass through shell
  my $subj="LON: Unconfigured machine $hostname";   my $subj="LON: Unconfigured machine $hostname";
  system("echo 'Unconfigured machine $hostname.' |\   system("echo 'Unconfigured machine $hostname.' |".
  mailto $emailto -s '$subj' > /dev/null");                 " mail -s '$subj' $emailto > /dev/null");
  exit 1;   exit 1;
     }      }
   
Line 888  sub main () { Line 924  sub main () {
  print("User ID mismatch. This program must be run as user 'www'.\n");   print("User ID mismatch. This program must be run as user 'www'.\n");
  my $emailto="$perlvar{'lonAdmEMail'},$perlvar{'lonSysEMail'}";   my $emailto="$perlvar{'lonAdmEMail'},$perlvar{'lonSysEMail'}";
  my $subj="LON: $perlvar{'lonHostID'} User ID mismatch";   my $subj="LON: $perlvar{'lonHostID'} User ID mismatch";
  system("echo 'User ID mismatch. loncron must be run as user www.' |\   system("echo 'User ID mismatch. loncron must be run as user www.' |".
  mailto $emailto -s '$subj' > /dev/null");                 " mail -s '$subj' $emailto > /dev/null");
  exit 1;   exit 1;
     }      }
   
 # -------------------------------------------- Force reload of host information  # -------------------------------------------- Force reload of host information
     &Apache::lonnet::load_hosts_tab(1);      my $nomemcache;
     &Apache::lonnet::load_domain_tab(1);      if ($justcheckdaemons) {
     &Apache::lonnet::get_iphost(1);          $nomemcache=1;
           my $memcachepidfile="$perlvar{'lonDaemons'}/logs/memcached.pid";
           my $memcachepid;
           if (-e $memcachepidfile) {
               my $memfh=IO::File->new($memcachepidfile);
               $memcachepid=<$memfh>;
               chomp($memcachepid);
               if ($memcachepid =~ /^\d+$/ && kill 0 => $memcachepid) {
                   undef($nomemcache);
               }
           }
       }
       &Apache::lonnet::load_hosts_tab(1,$nomemcache);
       &Apache::lonnet::load_domain_tab(1,$nomemcache);
       &Apache::lonnet::get_iphost(1,$nomemcache);
   
 # ----------------------------------------- Force firewall update for lond port    # ----------------------------------------- Force firewall update for lond port  
   
Line 933  sub main () { Line 983  sub main () {
  &log_machine_info($fh);   &log_machine_info($fh);
  &clean_tmp($fh);   &clean_tmp($fh);
  &clean_lonIDs($fh);   &clean_lonIDs($fh);
           &clean_webDAV_sessionIDs($fh);
  &check_httpd_logs($fh);   &check_httpd_logs($fh);
  &rotate_lonnet_logs($fh);   &rotate_lonnet_logs($fh);
  &rotate_other_logs($fh);   &rotate_other_logs($fh);

Removed from v.1.101  
changed lines
  Added in v.1.103.2.2


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