--- loncom/cgi/clusterstatus.pl 2008/11/29 00:57:09 1.25
+++ loncom/cgi/clusterstatus.pl 2014/05/28 18:16:09 1.28
@@ -1,7 +1,7 @@
#!/usr/bin/perl
$|=1;
# Generates a html page showing various status reports about the domain or cluster
-# $Id: clusterstatus.pl,v 1.25 2008/11/29 00:57:09 raeburn Exp $
+# $Id: clusterstatus.pl,v 1.28 2014/05/28 18:16:09 bisitz Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -33,6 +33,7 @@ use Apache::lonnet;
use Apache::lonlocal;
use LONCAPA::Configuration;
use LONCAPA::loncgi;
+use LONCAPA::lonauthcgi;
use LWP::UserAgent();
use HTTP::Headers;
use IO::File;
@@ -164,7 +165,7 @@ sub connected {
#
# Actually do the query
#
- &statuslist($local,'connecting '.$remote);
+ &statuslist($local,&mt('connecting [_1]',$remote),1);
my $reply=&request($local,$url,3600);
$reply=(split("\n",$reply))[0];
$reply=~s/\W//g;
@@ -259,13 +260,15 @@ sub reroute {
sub allreroutes {
my $local=shift;
&takeoffline($local);
- print(&Apache::lonlocal::mt('Reroute to:').' ');
- foreach my $remote (sort keys %hostname) {
+ my $reroute;
+ foreach my $remote (sort(keys(%hostname))) {
unless ($local eq $remote) {
- &reroute($local,$remote);
+ $reroute .= &reroute($local,$remote);
}
}
- print('');
+ if ($reroute) {
+ print(&Apache::lonlocal::mt('Reroute to:').' '.$reroute.'');
+ }
}
# ========================================================= Produce a green bar
@@ -294,7 +297,7 @@ sub serverstatus {
vers => 'Version:',
load => 'Load:',
acti => 'Active Users:',
- rpms => 'RPMs',
+ rpms => 'RPMs:',
mysq => 'MySQL Database:',
notc => 'Not connected',
lonc => 'loncron errors',
@@ -651,13 +654,18 @@ sub reports {
# ====================================================================== Status
sub statuslist {
- my ($local,$what)=@_;
+ my ($local,$what,$nomt)=@_;
my $displaylocal;
if (defined($local)) {
$displaylocal = " $local ($hostname{$local})";
}
- print ''."\n";
+ my $output = &Apache::lonlocal::mt('Testing[_1]:',$displaylocal).' ';
+ if ($nomt) {
+ $output .= $what;
+ } else {
+ $output .= &Apache::lonlocal::mt($what);
+ }
+ print ''."\n";
}
# =============================================================================
@@ -726,9 +734,9 @@ if (!&LONCAPA::loncgi::check_cookie_and_
exit;
}
-if (!&LONCAPA::loncgi::can_view('clusterstatus')) {
+if (!&LONCAPA::lonauthcgi::can_view('clusterstatus')) {
&Apache::lonlocal::get_language_handle();
- print &LONCAPA::loncgi::unauthorized_msg('clusterstatus');
+ print &LONCAPA::lonauthcgi::unauthorized_msg('clusterstatus');
exit;
}
@@ -739,8 +747,22 @@ if ($Apache::lonnet::env{'request.role'}
%hostname = %allhostname;
$scope = 'Cluster';
} else {
+ my $roledom = $env{'request.role.domain'};
+ if ((!$roledom) || ($roledom eq 'public')) {
+ print &LONCAPA::lonauthcgi::unauthorized_msg('clusterstatus');
+ exit;
+ }
undef(%hostname);
my @poss_domains = &Apache::lonnet::current_machine_domains();
+ if (!grep(/^\Q$roledom\E$/,@poss_domains)) {
+ my $home = &Apache::lonnet::domain($roledom,'primary');
+ print &LONCAPA::lonauthcgi::unauthorized_msg('clusterstatus');
+ print '
'.&mt("You need to select a role in this server's domain ([_1]) to display domain status for this server and other servers in the domain.",$roledom).'
';
+ if ($home) {
+ print ''.&mt("Alternatively, you'll need to [_1]switch server[_2] to display domain status for servers in the domain of your current role ([_3]).",'','',$roledom).'/span>';
+ }
+ exit;
+ }
foreach my $host (keys(%allhostname)) {
if (grep(/^\Q$hostdom{$host}\E$/,@poss_domains)) {
$hostname{$host} = $allhostname{$host};
@@ -759,10 +781,10 @@ print &Apache::lonlocal::mt('Choose next
if (!$FORM{'runonetime'}) {
my $lcscope = lc($scope);
print ''.&Apache::lonlocal::mt("Gathering initial $lcscope data").'
'.
- &Apache::lonlocal::mt('This may take some time ..').'
';
+ &Apache::lonlocal::mt('This may take some time ...').'
';
$fromcache=0;
&mainloop();
- &statuslist(undef,'Done initial run.');
+ &statuslist(undef,'Done initial run');
&reports();
} else {
$fromcache=1;
@@ -775,7 +797,7 @@ print &Apache::lonlocal::mt('Choose next
&hidden('runonetime',1);
print '
'.&Apache::lonlocal::mt('Total number of queries: [_1]',$stat_total);
if ($stat_total != 0) {
- print '
'.&Apache::lonlocal::mt('Percent complete:').''.
+ print '
'.&Apache::lonlocal::mt('Percent complete:').' '.
int(($stat_total-$stat_notyet)/$stat_total*100.).
'
'.&Apache::lonlocal::mt('Percent from cache:').' '.
int($stat_fromcache/$stat_total*100.).'';