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

www lon-capa-cvs@mail.lon-capa.org
Tue, 19 Feb 2002 20:23:59 -0000


www		Tue Feb 19 15:23:59 2002 EDT

  Modified files:              
    /loncom	access.conf loncapa.conf 
    /loncom/cgi	clusterstatus.pl 
  Log:
  New Cluster Status Functionality
  
  
Index: loncom/access.conf
diff -u loncom/access.conf:1.27 loncom/access.conf:1.28
--- loncom/access.conf:1.27	Wed Nov 28 16:53:05 2001
+++ loncom/access.conf	Tue Feb 19 15:23:59 2002
@@ -82,14 +82,14 @@
 
 <Location /server-status>
 SetHandler server-status
-AuthName "HTTPD Server Status"
+AuthName "LON-CAPA Network Administration"
 AuthType Basic
 AuthUserFile /home/httpd/lonTabs/htpasswd
 require user lonadm
 </Location>
 
 <Location /lon-status>
-AuthName "LON Server Status"
+AuthName "LON-CAPA Network Administration"
 AuthType Basic
 AuthUserFile /home/httpd/lonTabs/htpasswd
 require user lonadm
Index: loncom/loncapa.conf
diff -u loncom/loncapa.conf:1.1 loncom/loncapa.conf:1.2
--- loncom/loncapa.conf:1.1	Fri Jan 11 11:42:14 2002
+++ loncom/loncapa.conf	Tue Feb 19 15:23:59 2002
@@ -1,7 +1,7 @@
 ##
 ## loncapa.conf -- Apache HTTP LON-CAPA configuration file
 ##
-## $Id: loncapa.conf,v 1.1 2002/01/11 16:42:14 harris41 Exp $
+## $Id: loncapa.conf,v 1.2 2002/02/19 20:23:59 www Exp $
 ##
 ## 1/11/2002 - Scott Harrison
 
@@ -423,21 +423,35 @@
 # ------------------------------------------------- Backdoor Adm Tests/Programs
 
 <Location /cgi-bin/loncron.pl>
-AuthName "LON Network Synchronization Handler"
+AuthName "LON-CAPA Network Administration"
+AuthType Basic
+AuthUserFile /home/httpd/lonTabs/htpasswd
+require user lonadm
+</Location>
+
+<Location /cgi-bin/lonversions.pl>
+AuthName "LON-CAPA Network Administration"
+AuthType Basic
+AuthUserFile /home/httpd/lonTabs/htpasswd
+require user lonadm
+</Location>
+
+<Location /cgi-bin/clusterstatus.pl>
+AuthName "LON-CAPA Network Administration"
 AuthType Basic
 AuthUserFile /home/httpd/lonTabs/htpasswd
 require user lonadm
 </Location>
 
 <Location /cgi-bin/metadata_keywords.pl>
-AuthName "LON Keyword Handler"
+AuthName "LON-CAPA Network Administration"
 AuthType Basic
 AuthUserFile /home/httpd/lonTabs/htpasswd
 require user lonadm
 </Location>
 
 <Location /adm/test>
-AuthName "LON Test Handler"
+AuthName "LON-CAPA Network Administration"
 AuthType Basic
 AuthUserFile /home/httpd/lonTabs/htpasswd
 require user lonadm
Index: loncom/cgi/clusterstatus.pl
diff -u loncom/cgi/clusterstatus.pl:1.1 loncom/cgi/clusterstatus.pl:1.2
--- loncom/cgi/clusterstatus.pl:1.1	Mon Feb 18 18:45:23 2002
+++ loncom/cgi/clusterstatus.pl	Tue Feb 19 15:23:59 2002
@@ -5,11 +5,21 @@
 # (Versions
 # (Running loncron
 # 09/06/01 Gerd Kortemeyer)
-# 02/18/02 Gerd Kortemeyer)
+# 02/18/02,02/19/02 Gerd Kortemeyer)
 #
 use LWP::UserAgent();
 use HTTP::Headers;
 use IO::File;
+use Net::Ping;
+
+sub online {
+    my $host=shift;
+    my $p=Net::Ping->new("tcp",10);
+    my $online=$p->ping("$host");
+    $p->close();
+    undef ($p);
+    return $online;
+}
 
 sub connected {
     my ($local,$remote)=@_;
@@ -19,6 +29,8 @@
     unless ($hostname{$local}) { return 'local_unknown'; }
     unless ($hostname{$remote}) { return 'remote_unknown'; }
 
+    unless (&online($hostname{$local})) { return 'local_offline'; }
+
     my $ua=new LWP::UserAgent;
     
     my $request=new HTTP::Request('GET',
@@ -26,7 +38,7 @@
 
     my $response=$ua->request($request);
 
-    unless ($response->is_success) { return 'local_offline'; }
+    unless ($response->is_success) { return 'local_error'; }
 
     my $reply=$response->content;
     $reply=(split("\n",$reply))[0];
@@ -56,19 +68,91 @@
 {
     my $config=IO::File->new("$perlvar{'lonTabDir'}/hosts.tab");
 
+    $total=0;
     while (my $configline=<$config>) {
        my ($id,$domain,$role,$name,$ip)=split(/:/,$configline);
        $hostname{$id}=$name;
        $hostdom{$id}=$domain;
        $hostrole{$id}=$role;
        $hostip{$id}=$ip;
+       $total++;
        if (($role eq 'library') && ($id ne $perlvar{'lonHostID'})) {
 	   $libserv{$id}=$name;
        }
     }
 }
 
-print "<h1>Cluster Status</h1>\n";
-print &connected('gerdl1','msul1');
-
+print 
+"<h1>Cluster Status</h1>";
+print "Please be patient while building cluster status ...<p>\n";
+$table='';
+
+$table.="<table border=2><tr><th rowspan=2>From (local)</th>".
+"<th colspan=$total>To (remote)</th></tr><tr>";
+foreach $remote (sort keys %hostname) {
+   $table.="<th";
+   if ($remote eq $perlvar{'lonHostID'}) {
+       $table.=" bgcolor=#CCFFBB";
+   } else {
+       if ($libserv{$remote}) { $table.=" bgcolor=#FFFF99"; }
+   }
+   $table.=
+ "><a href=http://".$hostname{$remote}."/lon-status/>$remote</a></th>";
+}
+$table.="</tr>";
+foreach $local (sort keys %hostname) {
+    print "Checking $local ";
+   $table.="<tr><td";
+   if ($local eq $perlvar{'lonHostID'}) {
+       $table.=" bgcolor=#CCFFBB";
+   } else {
+       if ($libserv{$local}) { $table.=" bgcolor=#FFFF99"; }
+   }
+   $table.=
+ "><b><a href=http://".$hostname{$local}."/lon-status/>$local</a></b><br>".
+     $hostrole{$local}.' '.$hostdom{$local}.'<br>'.
+     "<tt><a href=http://".$hostname{$local}."/server-status/>".
+      $hostname{$local}."</a></tt><br>".
+     "<a href=http://".$hostname{$local}."/cgi-bin/loncron.pl>New Report</a>".
+     "</td>";
+  if (&online($hostname{$local})) {
+   foreach $remote (sort keys %hostname) {
+       $status=&connected($local,$remote);
+       if ($status eq 'ok') {
+	   $table.="<td";
+           if ($libserv{$remote}) {
+	       if ($libserv{$local}) {
+		   $table.=" bgcolor=#FFFF44";
+               } else {
+                   $table.=" bgcolor=#FFFF99";
+               }
+           } elsif ($libserv{$local}) {
+               $table.=" bgcolor=#FFFF99";
+           }
+           $table.="><b><font color=#00FF00>OK</font></b></td>";
+           print ".";
+       } else {
+           print "X";
+           $table.="<td><b><font color=#FF0000>".$status."</font></b><br>".
+     "<a href=http://".$hostname{$local}.
+	 "/lon-status/loncstatus.txt>lonc</a>";
+           if (&online($hostname{$remote})) {
+              $table.=" <a href=http://".$hostname{$remote}.
+      "/lon-status/londstatus.txt>lond</a>".
+            "</td>";
+	  } else {
+              $table.=' offline';
+          }
+  
+       }
+   }
+  } else {
+      print "offline";
+      $table.='<th colspan='.$total.'><font color=#FF0000>Offline</font></th>';
+  }
+   $table.="</tr>\n";
+    print "<br>\n";
+}
+$table.="</table>";
+print $table;
 print "</body></html>";