Diff for /loncom/loncron between versions 1.94 and 1.99

version 1.94, 2011/11/08 22:25:25 version 1.99, 2013/05/29 18:10:54
Line 32  use strict; Line 32  use strict;
   
 use lib '/home/httpd/lib/perl/';  use lib '/home/httpd/lib/perl/';
 use LONCAPA::Configuration;  use LONCAPA::Configuration;
   use LONCAPA::Checksumming;
 use LONCAPA;  use LONCAPA;
 use Apache::lonnet;  use Apache::lonnet;
 use Apache::loncommon;  use Apache::loncommon;
Line 270  sub log_machine_info { Line 271  sub log_machine_info {
   
     &log($fh,"<h3>distprobe</h3>");      &log($fh,"<h3>distprobe</h3>");
     &log($fh,"<pre>");      &log($fh,"<pre>");
     open(DSH,"$perlvar{'lonDaemons'}/distprobe |");      &log($fh,&encode_entities(&LONCAPA::distro(),'<>&"'));
     while (my $line=<DSH>) {   
  &log($fh,&encode_entities($line,'<>&"'));   
  $psproc++;  
     }  
     close(DSH);  
     &log($fh,"</pre>");      &log($fh,"</pre>");
   
     &errout($fh);      &errout($fh);
Line 627  sub check_delayed_msg { Line 623  sub check_delayed_msg {
     }      }
   
     &log($fh,"<p>Total unsend messages: <b>$unsend</b></p>\n");      &log($fh,"<p>Total unsend messages: <b>$unsend</b></p>\n");
     $warnings=$warnings+5*$unsend;      if ($unsend > 0) {
           $warnings=$warnings+5*$unsend;
       }
   
     if ($unsend) { $simplestatus{'unsend'}=$unsend; }      if ($unsend) { $simplestatus{'unsend'}=$unsend; }
     &log($fh,"<h3>Outgoing Buffer</h3>\n<pre>");      &log($fh,"<h3>Outgoing Buffer</h3>\n<pre>");
Line 641  sub check_delayed_msg { Line 639  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 (keys %servers) {      foreach my $tryserver (sort(keys(%servers))) {
         my $answer;          if ($hostname{$tryserver} || !$numhosts) {
         eval {              my $answer;
             local $SIG{ ALRM } = sub { die "TIMEOUT" };              eval {
             alarm(20);                  local $SIG{ ALRM } = sub { die "TIMEOUT" };
             $answer = &Apache::lonnet::reply("pong",$tryserver);                  alarm(20);
             alarm(0);                  $answer = &Apache::lonnet::reply("pong",$tryserver);
         };                  alarm(0);
         if ($@ && $@ =~ m/TIMEOUT/) {              };
             print "time out while contacting: $tryserver for pong\n";              if ($@ && $@ =~ m/TIMEOUT/) {
                   &log($fh,"Attempted pong to $tryserver timed out<br />");
                   print "time out while contacting: $tryserver for pong\n";
               } else {
                   &log($fh,"Pong to $tryserver: $answer<br />");
               }
         } else {          } else {
             &log($fh,"Pong to $tryserver: $answer<br />");              &log($fh,"$tryserver has delayed messages, but is not part of the cluster -- skipping 'Pong'.<br />");
         }          }
     }      }
 }  }
Line 690  sub log_simplestatus { Line 695  sub log_simplestatus {
   
 sub write_loncaparevs {  sub write_loncaparevs {
     print "Retrieving LON-CAPA version information\n";      print "Retrieving LON-CAPA version information\n";
     if (open(my $fh,">$perlvar{'lonTabDir'}/loncaparevs.tab")) {      my %hostname = &Apache::lonnet::all_hostnames();
         my %hostname = &Apache::lonnet::all_hostnames();      my $output;
         foreach my $id (sort(keys(%hostname))) {      foreach my $id (sort(keys(%hostname))) {
             if ($id ne '') {          if ($id ne '') {
                 my $loncaparev;              my $loncaparev;
               eval {
                   local $SIG{ ALRM } = sub { die "TIMEOUT" };
                   alarm(10);
                   $loncaparev =
                       &Apache::lonnet::get_server_loncaparev('',$id,1,'loncron');
                   alarm(0);
               };
               if ($@ && $@ =~ m/TIMEOUT/) {
                   print "time out while contacting lonHost: $id for version\n";   
               }
               if ($loncaparev =~ /^[\w.\-]+$/) {
                   $output .= $id.':'.$loncaparev."\n";
               }
           }
       }
       if ($output) {
           if (open(my $fh,">$perlvar{'lonTabDir'}/loncaparevs.tab")) {
               print $fh $output;
               close($fh);
               &Apache::lonnet::load_loncaparevs();
           }
       }
       return;
   }
   
   sub write_serverhomeIDs {
       print "Retrieving LON-CAPA lonHostID information\n";
       my %name_to_host = &Apache::lonnet::all_names();
       my $output;
       foreach my $name (sort(keys(%name_to_host))) {
           if ($name ne '') {
               if (ref($name_to_host{$name}) eq 'ARRAY') {
                   my $serverhomeID;
                 eval {                  eval {
                     local $SIG{ ALRM } = sub { die "TIMEOUT" };                      local $SIG{ ALRM } = sub { die "TIMEOUT" };
                     alarm(10);                      alarm(10);
                     $loncaparev =                      $serverhomeID = 
                         &Apache::lonnet::get_server_loncaparev('',$id,1,'loncron');                          &Apache::lonnet::get_server_homeID($name,1,'loncron');
                     alarm(0);                      alarm(0);
                 };                  };
                 if ($@ && $@ =~ m/TIMEOUT/) {                  if ($@ && $@ =~ m/TIMEOUT/) {
                     print "time out while contacting lonHost: $id for version\n";                         print "Time out while contacting server: $name\n"; 
                 }                  }
                 if ($loncaparev =~ /^[\w.\-]+$/) {                  if ($serverhomeID ne '') {
                     print $fh $id.':'.$loncaparev."\n";                      $output .= $name.':'.$serverhomeID."\n";
                   } else {
                       $output .= $name.':'.$name_to_host{$name}->[0]."\n";
                 }                  }
             }              }
         }          }
         close($fh);      }
       if ($output) {
           if (open(my $fh,">$perlvar{'lonTabDir'}/serverhomeIDs.tab")) {
               print $fh $output;
               close($fh);
               &Apache::lonnet::load_serverhomeIDs();
           }
     }      }
     return;      return;
 }  }
   
 sub write_serverhomeIDs {  sub write_checksums {
     print "Retrieving LON-CAPA lonHostID information\n";      my $distro = &LONCAPA::distro();
     if (open(my $fh,">$perlvar{'lonTabDir'}/serverhomeIDs.tab")) {      if ($distro) {
         my %name_to_host = &Apache::lonnet::all_names();          print "Retrieving file version and checksumming.\n";
         foreach my $name (sort(keys(%name_to_host))) {          my $numchksums = 0;
             if ($name ne '') {          my ($chksumsref,$versionsref) =
                 if (ref($name_to_host{$name}) eq 'ARRAY') {              &LONCAPA::Checksumming::get_checksums($distro,$perlvar{'lonDaemons'},
                     my $serverhomeID;                                                    $perlvar{'lonLib'},
                     eval {                                                    $perlvar{'lonIncludes'},
                         local $SIG{ ALRM } = sub { die "TIMEOUT" };                                                    $perlvar{'lonTabDir'});
                         alarm(10);          if (ref($chksumsref) eq 'HASH') {
                         $serverhomeID =               $numchksums = scalar(keys(%{$chksumsref}));
                             &Apache::lonnet::get_server_homeID($name,1,'loncron');  
                         alarm(0);  
                     };  
                     if ($@ && $@ =~ m/TIMEOUT/) {  
                         print "Time out while contacting server: $name\n";   
                     }  
                     if ($serverhomeID ne '') {  
                         print $fh $name.':'.$serverhomeID."\n";  
                     } else {  
                         print $fh $name.':'.$name_to_host{$name}->[0]."\n";  
                     }  
                 }  
             }  
         }          }
         close($fh);          print "File version retrieved and checksumming completed for $numchksums files.\n";
       } else {
           print "File version retrieval and checksumming skipped - could not determine Linux distro.\n"; 
     }      }
     return;      return;
 }  }
Line 896  sub main () { Line 931  sub main () {
  &log_simplestatus();   &log_simplestatus();
         &write_loncaparevs();          &write_loncaparevs();
         &write_serverhomeIDs();          &write_serverhomeIDs();
    &write_checksums();
  if ($totalcount>200 && !$noemail) { &send_mail(); }   if ($totalcount>200 && !$noemail) { &send_mail(); }
     }      }
 }  }
Line 904  sub main () { Line 939  sub main () {
 &main();  &main();
 1;  1;
   
   
   
   
   
   
   
   

Removed from v.1.94  
changed lines
  Added in v.1.99


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