Diff for /loncom/loncron between versions 1.95 and 1.99

version 1.95, 2011/11/14 17:27:34 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 699  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 905  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 913  sub main () { Line 939  sub main () {
 &main();  &main();
 1;  1;
   
   
   
   
   
   
   
   

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


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