--- loncom/cgi/clusterstatus.pl 2002/02/19 20:23:59 1.2 +++ loncom/cgi/clusterstatus.pl 2003/02/25 21:56:48 1.7 @@ -6,20 +6,13 @@ $|=1; # (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; -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)=@_; @@ -29,8 +22,6 @@ sub connected { 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', @@ -50,19 +41,12 @@ sub connected { print "Content-type: text/html\n\n". "\n"; -# ------------------------------------------------------------ Read access.conf -{ - my $config=IO::File->new("/etc/httpd/conf/access.conf"); - - while (my $configline=<$config>) { - if ($configline =~ /PerlSetVar/) { - my ($dummy,$varname,$varvalue)=split(/\s+/,$configline); - $perlvar{$varname}=$varvalue; - } - } - delete $perlvar{'lonReceipt'}; # remove since sensitive and not needed - delete $perlvar{'lonSqlAccess'}; # remove since sensitive and not needed -} +# -------------------- 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 { @@ -70,6 +54,8 @@ print "Content-type: text/html\n\n". $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; @@ -101,7 +87,7 @@ foreach $remote (sort keys %hostname) { } $table.=""; foreach $local (sort keys %hostname) { - print "Checking $local "; + print "Checking $local: "; $table.="
". "New Report". ""; - if (&online($hostname{$local})) { foreach $remote (sort keys %hostname) { $status=&connected($local,$remote); if ($status eq 'ok') { @@ -135,21 +120,12 @@ foreach $local (sort keys %hostname) { print "X"; $table.="".$status."
". "lonc"; - if (&online($hostname{$remote})) { - $table.=" lonc". + " lond". ""; - } else { - $table.=' offline'; - } - } } - } else { - print "offline"; - $table.='Offline'; - } $table.="\n"; print "
\n"; }