[LON-CAPA-cvs] cvs: loncom /cgi clusterstatus.pl

www lon-capa-cvs@mail.lon-capa.org
Fri, 01 Aug 2003 14:47:44 -0000


www		Fri Aug  1 10:47:44 2003 EDT

  Modified files:              
    /loncom/cgi	clusterstatus.pl 
  Log:
  Speed up display by better distribution of non-cached queries, and lowering
  timeout values.
  
  
Index: loncom/cgi/clusterstatus.pl
diff -u loncom/cgi/clusterstatus.pl:1.12 loncom/cgi/clusterstatus.pl:1.13
--- loncom/cgi/clusterstatus.pl:1.12	Thu Jul 31 15:55:37 2003
+++ loncom/cgi/clusterstatus.pl	Fri Aug  1 10:47:44 2003
@@ -3,7 +3,7 @@
 # The LearningOnline Network with CAPA
 # Cluster Status
 #
-# $Id: clusterstatus.pl,v 1.12 2003/07/31 19:55:37 www Exp $
+# $Id: clusterstatus.pl,v 1.13 2003/08/01 14:47:44 www Exp $
 
 use lib '/home/httpd/lib/perl/';
 use LONCAPA::Configuration;
@@ -47,6 +47,7 @@
 
 sub request {
     my ($local,$url,$cachetime)=@_;
+    $cachetime*=(0.5+rand);
     my $key=&key($local,$url);
     my $reply='';
     if ($FORM{$key.'_time'}) {
@@ -61,7 +62,7 @@
 	    $reply='local_unknown'; 
 	} else {
 
-	    my $ua=new LWP::UserAgent(timeout => 20);
+	    my $ua=new LWP::UserAgent(timeout => 15);
     
 	    my $request=new HTTP::Request('GET',
 					  "http://".$hostname{$local}.$url);
@@ -94,7 +95,7 @@
 # Slowly phase this in: if not cached, only do 10 percent of the cases 
 #
     unless ($FORM{&key($local,$url)}) {
-	unless (rand>0.9) { return 'not_yet'; }
+	unless (rand>0.95) { return 'not_yet'; }
     }
 #
 # Actually do the query
@@ -482,7 +483,7 @@
 	    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>';
+		    print '<td bgcolor="#FFFFFF"><font color="#555522" size="-2">not yet tested</font></td>';
 		} elsif ($connectionstatus{$local.'_TO_'.$remote} eq 'ok') {
 		    print 
 '<td bgcolor="#BBDDBB"><font color="#225522" face="arial"><b>ok</b></td>';
@@ -573,8 +574,9 @@
 # ============================================================== Close, refresh
 print "</form><script>";
 $runtime=time-$starttime;
-if ($runtime>=$refresh) {
-    print 'document.status.submit();';
+if (($refresh-$runtime)<30) {
+    print "setTimeout('document.status.submit()',30000);\n".
+          "document.prgstat.progress.value='Will automatically refresh.'";
 } else {
     $refreshtime=int(1000*($refresh-$runtime));
     print "setTimeout('document.status.submit()',$refreshtime);\n".