#!/usr/bin/perl $|=1; # The LearningOnline Network with CAPA # Cluster Status # (Versions # (Running loncron # 09/06/01 Gerd Kortemeyer) # 02/18/02,02/19/02 Gerd Kortemeyer) use lib '/home/httpd/lib/perl/'; use LONCAPA::Configuration; use LWP::UserAgent(); use HTTP::Headers; use IO::File; sub connected { my ($local,$remote)=@_; $local=~s/\W//g; $remote=~s/\W//g; unless ($hostname{$local}) { return 'local_unknown'; } unless ($hostname{$remote}) { return 'remote_unknown'; } my $ua=new LWP::UserAgent; my $request=new HTTP::Request('GET', "http://".$hostname{$local}.'/cgi-bin/ping.pl?'.$remote); my $response=$ua->request($request); unless ($response->is_success) { return 'local_error'; } my $reply=$response->content; $reply=(split("\n",$reply))[0]; $reply=~s/\W//g; if ($reply ne $remote) { return $reply; } return 'ok'; } print "Content-type: text/html\n\n". "\n"; # -------------------- Read loncapa.conf (and by default, loncapa_apache.conf). my $perlvarref=LONCAPA::Configuration::read_conf('loncapa.conf'); my %perlvar=%{$perlvarref}; undef $perlvarref; # remove since sensitive and not needed delete $perlvar{'lonReceipt'}; # remove since sensitive and not needed delete $perlvar{'lonSqlAccess'}; # remove since sensitive and not needed # ------------------------------------------------------------- Read hosts file { my $config=IO::File->new("$perlvar{'lonTabDir'}/hosts.tab"); $total=0; while (my $configline=<$config>) { $configline=~s/#.*$//; unless ($configline=~/\w/) { next; } 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 "

Cluster Status

"; print "Please be patient while building cluster status ...

\n"; $table=''; $table.="". ""; foreach $remote (sort keys %hostname) { $table.="$remote"; } $table.=""; foreach $local (sort keys %hostname) { print "Checking $local: "; $table.="$local
". $hostrole{$local}.' '.$hostdom{$local}.'
'. "". $hostname{$local}."
". "New Report". ""; foreach $remote (sort keys %hostname) { $status=&connected($local,$remote); if ($status eq 'ok') { $table.="
". "lonc". " lond". ""; } } $table.="
\n"; print "
\n"; } $table.="
From (local)To (remote)
"; print $table; print "";