Diff for /loncom/loncron between versions 1.71 and 1.72

version 1.71, 2007/04/03 00:47:26 version 1.72, 2007/04/11 23:08:43
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 Apache::lonnet;
   
 use IO::File;  use IO::File;
 use IO::Socket;  use IO::Socket;
Line 43  use vars qw (%perlvar %simplestatus $err Line 44  use vars qw (%perlvar %simplestatus $err
 my $statusdir="/home/httpd/html/lon-status";  my $statusdir="/home/httpd/html/lon-status";
   
   
 # -------------------------------------------------- Non-critical communication  
 sub reply {  
     my ($cmd,$server,$hostname)=@_;  
     my $peerfile="$perlvar{'lonSockDir'}/".$hostname->{$server};  
     my $client=IO::Socket::UNIX->new(Peer    =>"$peerfile",  
                                      Type    => SOCK_STREAM,  
                                      Timeout => 10)  
        or return "con_lost";  
     print $client "sethost:$server:$cmd\n";  
     my $answer=<$client>;  
     chomp($answer);  
     if (!$answer) { $answer="con_lost"; }  
     return $answer;  
 }  
   
 # --------------------------------------------------------- Output error status  # --------------------------------------------------------- Output error status
   
 sub log {  sub log {
Line 297  sub log_machine_info { Line 283  sub log_machine_info {
 }  }
   
 sub start_logging {  sub start_logging {
     my ($hostdom,$hostrole,$hostname,$spareid)=@_;  
     my $fh=IO::File->new(">$statusdir/newstatus.html");      my $fh=IO::File->new(">$statusdir/newstatus.html");
     my %simplestatus=();      my %simplestatus=();
     my $now=time;      my $now=time;
Line 340  ENDHEADERS Line 325  ENDHEADERS
      &encode_entities($perlvar{$varname},'<>&"')."</td></tr>\n");       &encode_entities($perlvar{$varname},'<>&"')."</td></tr>\n");
     }      }
     &log($fh,"</table><h3>Hosts</h3><table border='2'>");      &log($fh,"</table><h3>Hosts</h3><table border='2'>");
     foreach my $id (sort(keys(%{$hostname}))) {      my %hostname = &Apache::lonnet::all_hostnames();
       foreach my $id (sort(keys(%hostname))) {
    my $role = (&Apache::lonnet::is_library($id) ? 'library'
                                        : 'access');
  &log($fh,   &log($fh,
     "<tr><td>$id</td><td>".$hostdom->{$id}.      "<tr><td>$id</td><td>".&Apache::lonnet::host_domain($id).
     "</td><td>".$hostrole->{$id}.      "</td><td>".$role.
     "</td><td>".$hostname->{$id}."</td></tr>\n");      "</td><td>".&Apache::lonnet::hostname($id)."</td></tr>\n");
     }      }
     &log($fh,"</table><h3>Spare Hosts</h3><ol>");      &log($fh,"</table><h3>Spare Hosts</h3><ul>");
     foreach my $id (sort(keys(%{$spareid}))) {      foreach my $type (sort(keys(%Apache::lonnet::spareid))) {
  &log($fh,"<li>$id\n</li>");   &log($fh,"<li>$type\n<ol>");
    foreach my $id (@{ $Apache::lonnet::spareid{$type} }) {
       &log($fh,"<li>$id</li>\n");
    }
    &log($fh,"</ol>\n</li>\n");
     }      }
     &log($fh,"</ol>\n");      &log($fh,"</ul>\n");
     return $fh;      return $fh;
 }  }
   
Line 477  sub rotate_lonnet_logs { Line 469  sub rotate_lonnet_logs {
   
 # ----------------------------------------------------------------- Connections  # ----------------------------------------------------------------- Connections
 sub test_connections {  sub test_connections {
     my ($fh,$hostname)=@_;      my ($fh)=@_;
     &log($fh,'<hr /><a name="connections" /><h2>Connections</h2>');      &log($fh,'<hr /><a name="connections" /><h2>Connections</h2>');
     print "testing connections\n";      print "testing connections\n";
     &log($fh,"<table border='2'>");      &log($fh,"<table border='2'>");
     my ($good,$bad)=(0,0);      my ($good,$bad)=(0,0);
     foreach my $tryserver (sort(keys(%{$hostname}))) {      my %hostname = &Apache::lonnet::all_hostnames();
       foreach my $tryserver (sort(keys(%hostname))) {
  print(".");   print(".");
  my $result;   my $result;
  my $answer=&reply("ping",$tryserver,$hostname);   my $answer=&Apache::lonnet::reply("ping",$tryserver);
  if ($answer eq "$tryserver:$perlvar{'lonHostID'}") {   if ($answer eq "$tryserver:$perlvar{'lonHostID'}") {
     $result="<b>ok</b>";      $result="<b>ok</b>";
     $good++;      $good++;
Line 510  sub test_connections { Line 503  sub test_connections {
   
 # ------------------------------------------------------------ Delayed messages  # ------------------------------------------------------------ Delayed messages
 sub check_delayed_msg {  sub check_delayed_msg {
     my ($fh,$hostname)=@_;      my ($fh)=@_;
     &log($fh,'<hr /><a name="delayed" /><h2>Delayed Messages</h2>');      &log($fh,'<hr /><a name="delayed" /><h2>Delayed Messages</h2>');
     print "checking buffers\n";      print "checking buffers\n";
           
Line 548  sub check_delayed_msg { Line 541  sub check_delayed_msg {
 # 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 (keys %servers) {
  my $answer=&reply("pong",$tryserver,$hostname);   my $answer=&Apache::lonnet::reply("pong",$tryserver);
  &log($fh,"Pong to $tryserver: $answer<br />");   &log($fh,"Pong to $tryserver: $answer<br />");
     }      }
 }  }
Line 662  sub main () { Line 655  sub main () {
  exit 1;   exit 1;
     }      }
   
 # ------------------------------------------------------------- Read hosts file  # -------------------------------------------- Force reload of host information
     my $config=IO::File->new("$perlvar{'lonTabDir'}/hosts.tab");      &Apache::lonnet::load_hosts_tab(1);
           &Apache::lonnet::load_domain_tab(1);
     my (%hostname,%hostdom,%hostrole,%spareid);      &Apache::lonnet::get_iphost(1);
     while (my $configline=<$config>) {  
  next if ($configline =~ /^(\#|\s*\$)/);  
  my ($id,$domain,$role,$name)=split(/:/,$configline);  
  if ($id && $domain && $role && $name) {  
     $name=~s/\s//g;  
     $hostname{$id}=$name;  
     $hostdom{$id}=$domain;  
     $hostrole{$id}=$role;  
  }  
     }  
     undef $config;  
   
 # ------------------------------------------------------ Read spare server file  
     $config=IO::File->new("$perlvar{'lonTabDir'}/spare.tab");  
       
     while (my $configline=<$config>) {  
  chomp($configline);  
  if (($configline) && ($configline ne $perlvar{'lonHostID'})) {  
     $spareid{$configline}=1;  
  }  
     }  
     undef $config;  
   
 # ---------------------------------------------------------------- Start report  # ---------------------------------------------------------------- Start report
   
Line 698  sub main () { Line 669  sub main () {
   
     my $fh;      my $fh;
     if (!$justcheckdaemons && !$justcheckconnections && !$justreload) {      if (!$justcheckdaemons && !$justcheckconnections && !$justreload) {
  $fh=&start_logging(\%hostdom,\%hostrole,\%hostname,\%spareid);   $fh=&start_logging();
   
  &log_machine_info($fh);   &log_machine_info($fh);
  &clean_tmp($fh);   &clean_tmp($fh);
Line 721  sub main () { Line 692  sub main () {
  &checkon_daemon($fh,'lonc',40000,'USR2');   &checkon_daemon($fh,'lonc',40000,'USR2');
     }      }
     if ($justcheckconnections) {      if ($justcheckconnections) {
  &test_connections($fh,\%hostname);   &test_connections($fh);
     }      }
     if (!$justcheckdaemons && !$justcheckconnections && !$justreload) {      if (!$justcheckdaemons && !$justcheckconnections && !$justreload) {
  &check_delayed_msg($fh,\%hostname);   &check_delayed_msg($fh);
  &finish_logging($fh);   &finish_logging($fh);
  &log_simplestatus();   &log_simplestatus();
   

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


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