Diff for /loncom/cgi/clusterstatus.pl between versions 1.9 and 1.11

version 1.9, 2003/07/31 15:35:02 version 1.11, 2003/07/31 19:18:16
Line 169  sub server { Line 169  sub server {
     print &otherwindow($local,'/server-status','Server Status');      print &otherwindow($local,'/server-status','Server Status');
 }  }
   
   # ========================================================= Produce a green bar
   sub bar {
       my $parm=shift;
       my $number=int($parm+0.5);
       print "<table><tr><td bgcolor='#225522'><font color='#225522'>";
       for (my $i=0;$i<$number;$i++) {
    print "+";
       }
       print "</font></table>";
   }
   
 # ========================================================== Show server status  # ========================================================== Show server status
   
 sub serverstatus {  sub serverstatus {
     my $local=shift;      my ($local,$trouble)=@_;
     print (<<ENDHEADER);      print (<<ENDHEADER);
   <a name="$local" />
 <table width="100%" bgcolor="#225522" cellspacing="2" cellpadding="2" border="0">  <table width="100%" bgcolor="#225522" cellspacing="2" cellpadding="2" border="0">
 <tr><td bgcolor="#BBDDBB"><font color="#225522" face="arial"><b>  <tr><td bgcolor="#BBDDBB"><font color="#225522" face="arial"><b>
 $local $hostdom{$local}</b> <tt>($hostname{$local}; $hostrole{$local})</tt>  $local $hostdom{$local}</b> <tt>($hostname{$local}; $hostrole{$local})</tt>
 <br />$domaindescription{$hostdom{$local}}  <br />$domaindescription{$hostdom{$local}}
 </font></th></tr><tr><td bgcolor="DDDDBB"><font color="#225522">  </font></th></tr><tr><td bgcolor="#DDDDBB"><font color="#225522">
 ENDHEADER  ENDHEADER
     &login($local);&server($local);&users($local);&versions($local);      &login($local);&server($local);&users($local);&versions($local);
     &loncron($local);&lond($local);&lonc($local);&runloncron($local);      &loncron($local);&lond($local);&lonc($local);&runloncron($local);
     print "</font></td></tr><tr><td bgcolor='#BBBBBB'>";      print "</font></td></tr>";
       if ($trouble) {
    print ("<tr><td bgcolor='#DDBBBB'><font color='#552222' size='+2'>$trouble</font></td></tr>");
       }
       print "<tr><td bgcolor='#BBBBBB'>";
 # load  # load
     if (($host{$local.'_load_doomed'}>0.5) || ($mode eq 'load_doomed')) {      if (($host{$local.'_load_doomed'}>0.5) || ($mode eq 'load_doomed')) {
  print "<br />Load: ".$host{$local.'_load'}   print "<br />Load: ".$host{$local.'_load'}
Line 200  ENDHEADER Line 216  ENDHEADER
     if ($host{$local.'_mysql'}) {      if ($host{$local.'_mysql'}) {
  print "<br />MySQL Database: ".$host{$local.'_mysql'}   print "<br />MySQL Database: ".$host{$local.'_mysql'}
     }      }
   # connections
       if ($host{$local.'_notconnected'}) {
    print "<br />Not connected: ";
    foreach (split(/ /,$host{$local.'_notconnected'})) {
       if ($_) {
    print " <a href='#$_'>$_</a>";
       }
    }
       }
   # errors
       if ($host{$local.'_errors'}) {
    print "<br />loncron errors: ".$host{$local.'_errors'};
       }
     print "</td></tr></table><br />";      print "</td></tr></table><br />";
 }  }
   
Line 256  foreach $pair (@pairs) { Line 285  foreach $pair (@pairs) {
   
 # ====================================================== Determine refresh rate  # ====================================================== Determine refresh rate
   
 my $refresh=(($FORM{'refresh'}=~/^\d+$/)?$FORM{'refresh'}:60);  my $refresh=(($FORM{'refresh'}=~/^\d+$/)?$FORM{'refresh'}:120);
 if ($refresh<30) { $refresh=30; }  if ($refresh<30) { $refresh=30; }
 my $starttime=time;  my $starttime=time;
   
Line 271  my %modes=('trouble' => 'Trouble', Line 300  my %modes=('trouble' => 'Trouble',
    'load_doomed' => 'Doomed: Load',     'load_doomed' => 'Doomed: Load',
    'unresponsive_doomed' => 'Doomed: Status could not be determined',     'unresponsive_doomed' => 'Doomed: Status could not be determined',
    'users' => 'User Report',     'users' => 'User Report',
      'load' => 'Load Report',
    'connections' => 'Connections Matrix');     'connections' => 'Connections Matrix');
   
 $mode=$FORM{'mode'};  $mode=$FORM{'mode'};
 unless ($modes{$mode}) { $mode='trouble'; }  unless ($modes{$mode}) { $mode='trouble'; }
 # ================================================================ Send Headers  # ================================================================ Send Headers
 print "Content-type: text/html\n\n".  print "Content-type: text/html\n\n".
     "<html><body bgcolor=#FFFFFF>\n";      "<html><body bgcolor='#FFFFFF'>\n";
 # -------------------- Read loncapa.conf (and by default, loncapa_apache.conf).  # -------------------- Read loncapa.conf (and by default, loncapa_apache.conf).
 my $perlvarref=LONCAPA::Configuration::read_conf('loncapa.conf');  my $perlvarref=LONCAPA::Configuration::read_conf('loncapa.conf');
 %perlvar=%{$perlvarref};  %perlvar=%{$perlvarref};
Line 323  delete $perlvar{'lonSqlAccess'}; # remov Line 353  delete $perlvar{'lonSqlAccess'}; # remov
     }      }
 }  }
   
   print "<img src='/adm/lonIcons/lonlogos.gif' align='right' /><h1>LON-CAPA Cluster Status ".localtime()."</h1>";
 print "<h1>Cluster Status ".localtime()."</h1>";  
 print "<form name='prgstat'>\n".  print "<form name='prgstat'>\n".
 "<input type='text' name='progress' value='Starting ...' size='100' /><br />".  "<input type='text' name='progress' value='Starting ...' size='100' /><br />".
 "</form>\n";;  "</form>\n";;
Line 334  print 'Choose next report: '.&select_for Line 363  print 'Choose next report: '.&select_for
   
 # ==================================================== Main Loop over all Hosts  # ==================================================== Main Loop over all Hosts
   
   my $maxusers=0;
   my $maxload=0;
   my $totalusers=0;
   
 foreach $local (sort keys %hostname) {  foreach $local (sort keys %hostname) {
     $host{$local.'_unresponsive_doomed'}=0;      $host{$local.'_unresponsive_doomed'}=0;
 # -- Check general status  # -- Check general status
Line 347  foreach $local (sort keys %hostname) { Line 380  foreach $local (sort keys %hostname) {
     $host{$local.'_loncron'}='Stale.';      $host{$local.'_loncron'}='Stale.';
     $host{$local.'_unresponsive_doomed'}++;      $host{$local.'_unresponsive_doomed'}++;
  } else {   } else {
       $host{$local.'_loncron_doomed'}=$loncron{'notices'}
                                    +4*$loncron{'warnings'}
                                  +100*$loncron{'errors'};
       $host{$local.'_errors'}=$loncron{'errors'};
  }   }
     }      }
 # -- Check user status  # -- Check user status
Line 358  foreach $local (sort keys %hostname) { Line 395  foreach $local (sort keys %hostname) {
     } else {      } else {
  $host{$local.'_users_doomed'}=$userstatus{'Active'};   $host{$local.'_users_doomed'}=$userstatus{'Active'};
  $host{$local.'_users'}=$userstatus{'Active'};   $host{$local.'_users'}=$userstatus{'Active'};
    unless ($host{$local.'_users'}) { $host{$local.'_users'}=0; }
    if ($host{$local.'_users'}>$maxusers) { 
       $maxusers=$host{$local.'_users'};
    }
    $totalusers+=$host{$local.'_users'};
  my ($sload,$mload,$lload)=split(/ /,$userstatus{'loadavg'});   my ($sload,$mload,$lload)=split(/ /,$userstatus{'loadavg'});
  $host{$local.'_load_doomed'}=$mload;   $host{$local.'_load_doomed'}=$mload;
    if ($mload>$maxload) { 
       $maxload=$mload;
    }
  $host{$local.'_load'}=$userstatus{'loadavg'};   $host{$local.'_load'}=$userstatus{'loadavg'};
     }      }
 # -- Check mysql status  # -- Check mysql status
Line 424  foreach $local (sort keys %hostname) { Line 469  foreach $local (sort keys %hostname) {
  foreach (&doomedness($mode)) {   foreach (&doomedness($mode)) {
     &serverstatus($_);      &serverstatus($_);
  }   }
       } elsif ($mode eq 'connections') {
    print 
          "<table cellspacing='3' cellpadding='3' border='0' bgcolor='#225522'>".
          "<tr><td bgcolor='#225522'>&nbsp;</td>";
    foreach my $remote (sort keys %hostname) {
       print '<th bgcolor="#DDDDBB">'.$remote.'</th>';
    }
    print "</tr>\n";
   # connection matrix
    foreach my $local (sort keys %hostname) {
       print '<tr><th bgcolor="#DDDDBB">'.$local.'</th>';
       foreach my $remote (sort keys %hostname) {
    if ($connectionstatus{$local.'_TO_'.$remote} eq 'not_yet') {
       print '<td bgcolor="#FFFFFF">&nbsp;</td>';
    } elsif ($connectionstatus{$local.'_TO_'.$remote} eq 'ok') {
       print 
   '<td bgcolor="#BBDDBB"><font color="#225522" face="arial"><b>ok</b></td>';
    } else {
       print 
     '<td bgcolor="#DDBBBB"><font color="#552222" size="-2">'.
     $connectionstatus{$local.'_TO_'.$remote}.'<br />';
       &lonc($local); &lond($remote);
       print '</td>';
    }
       }
       print "</tr>\n";
    }
    print "</table>";
       } elsif ($mode eq 'users') {
   # Users
    if ($maxusers) {
       my $factor=50/$maxusers;
       print "<h3>Total active user(s): $totalusers</h3>". 
          "<table cellspacing='3' cellpadding='3' border='0' bgcolor='#225522'>";
   
       foreach $local (sort keys %hostname) {
    if (defined($host{$local.'_users'})) {
       print 
   '<tr><th bgcolor="#BBDDBB"><font face="arial" color="#225522" size="+1">'.$local.
    '</font></th><td bgcolor="#DDDDBB">';
       &users();
       print 
         '</td><td bgcolor="#DDDDBB"><font face="arial" color="#225522">'.
         $host{$local.'_users'}.'</font></td><td bgcolor="#DDDDBB"';
       &bar($factor*$host{$local.'_users'});
       print "</td></tr>\n";
    }
       }
       print "</table>";
    } else {
       print "No active users logged in.";
    }
       } elsif ($mode eq 'load') {
   # Load
    if ($maxload) {
       my $factor=50/$maxload; 
       print
          "<table cellspacing='3' cellpadding='3' border='0' bgcolor='#225522'>";
       foreach $local (sort keys %hostname) {
    if (defined($host{$local.'_load_doomed'})) {
       print 
   '<tr><th bgcolor="#BBDDBB"><font face="arial" color="#225522" size="+1">'.
                           $local.
    '</font></th><td bgcolor="#DDDDBB">';
       &server();
       print 
         '</td><td bgcolor="#DDDDBB"><font face="arial" color="#225522">'.
         $host{$local.'_load_doomed'}.'</font></td><td bgcolor="#DDDDBB"';
       &bar($factor*$host{$local.'_load_doomed'});
       print "</td></tr>\n";
    }
       }
       print "</table>";
    } else {
       print "No workload.";
    }
       } elsif ($mode eq 'trouble') {
    my $count=0;
    foreach $local (sort keys %hostname) {
       my $trouble='';
       if ($host{$local.'_errors'}) {
    $trouble='Has loncron errors.<br />';
       } elsif ($host{$local.'_loncron_doomed'}>600) {
    $trouble='High loncron count.<br />';
       }
       if ($host{$local.'_load_doomed'}>5) {
    $trouble='High load.<br />';
       }
       if ($host{$local.'_users_doomed'}>200) {
    $trouble='High user volume.<br />';
       }
       if ($host{$local.'_mysql_doomed'}>1) {
    $trouble='MySQL database apparently offline.<br />';
       }
       if ($host{$local.'_checkrpms_doomed'}>100) {
    $trouble='RPMs outdated.<br />';
       }
       if ($trouble) { $count++; &serverstatus($local,$trouble); }
    }
    unless ($count) { print "No mayor trouble."; }
     }      }
 # ============================================================== Close, refresh  # ============================================================== Close, refresh
 print "</form><script>";  print "</form><script>";
Line 432  if ($runtime>=$refresh) { Line 577  if ($runtime>=$refresh) {
     print 'document.status.submit();';      print 'document.status.submit();';
 } else {  } else {
     $refreshtime=int(1000*($refresh-$runtime));      $refreshtime=int(1000*($refresh-$runtime));
     print "setTimeout('document.status.submit()',$refreshtime);";      print "setTimeout('document.status.submit()',$refreshtime);\n".
             "document.prgstat.progress.value='Will automatically refresh ($refresh secs refresh cycle)'";
 }  }
 print "</script></body></html>";  print "</script></body></html>";
 exit 0;  exit 0;

Removed from v.1.9  
changed lines
  Added in v.1.11


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