Annotation of loncom/interface/domainstatus.pm, revision 1.8

1.1       raeburn     1: # The LearningOnline Network
                      2: # Generate a menu page containing links to server status pages accessible
                      3: # to user. 
                      4: #
1.8     ! raeburn     5: # $Id: domainstatus.pm,v 1.7 2014/03/17 02:36:56 raeburn Exp $
1.1       raeburn     6: #
                      7: # Copyright Michigan State University Board of Trustees
                      8: #
                      9: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
                     10: #
                     11: # LON-CAPA is free software; you can redistribute it and/or modify
                     12: # it under the terms of the GNU General Public License as published by
                     13: # the Free Software Foundation; either version 2 of the License, or
                     14: # (at your option) any later version.
                     15: #
                     16: # LON-CAPA is distributed in the hope that it will be useful,
                     17: # but WITHOUT ANY WARRANTY; without even the implied warranty of
                     18: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     19: # GNU General Public License for more details.
                     20: #
                     21: # You should have received a copy of the GNU General Public License
                     22: # along with LON-CAPA; if not, write to the Free Software
                     23: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
                     24: #
                     25: # /home/httpd/html/adm/gpl.txt
                     26: #
                     27: # http://www.lon-capa.org/
                     28: #
                     29: #
                     30: package Apache::domainstatus;
                     31: 
                     32: use strict;
                     33: use Apache::Constants qw(:common);
                     34: use Apache::lonnet;
                     35: use Apache::loncommon;
                     36: use Apache::lonhtmlcommon;
                     37: use Apache::lonlocal;
1.2       raeburn    38: use LONCAPA::lonauthcgi;
1.1       raeburn    39: 
                     40: sub handler {
                     41:     my $r = shift;
                     42:     &Apache::loncommon::content_type($r,'text/html');
                     43:     $r->send_http_header;
                     44:     if ($r->header_only) {
                     45:         return OK;
                     46:     }
                     47: 
                     48:     &Apache::lonlocal::get_language_handle();
                     49:     my $dom = &Apache::lonnet::default_login_domain();
                     50: 
                     51:     if (($env{'user.domain'} ne '') && ($env{'user.domain'} ne 'public')) {
                     52:         $dom = $env{'user.domain'};
                     53:         if ($env{'request.role.domain'} ne '') {
                     54:             $dom = $env{'request.role.domain'};
                     55:         }
                     56:     }
                     57:     my $domdesc = &Apache::lonnet::domain($dom,'description');
                     58: 
                     59:     my %candisplay;
1.2       raeburn    60:     my $titles = &LONCAPA::lonauthcgi::serverstatus_titles();
1.1       raeburn    61:     if (ref($titles) eq 'HASH') {
                     62:         foreach my $page (keys(%{$titles})) {
1.2       raeburn    63:             if (&LONCAPA::lonauthcgi::can_view($page)) {
1.1       raeburn    64:                 $candisplay{$page} = 'F';       
1.2       raeburn    65:             } elsif (&LONCAPA::lonauthcgi::check_ipbased_access($page)) {
1.1       raeburn    66:                 $candisplay{$page} = 'F';
                     67:             }
                     68:         }
                     69:     }
                     70: 
                     71:     &Apache::lonhtmlcommon::clear_breadcrumbs();
                     72:     &Apache::lonhtmlcommon::add_breadcrumb
                     73:     ({href=>"/adm/domainstatus",
                     74:       text=>"Server Status Information"});
                     75: 
                     76:     $r->print(&Apache::loncommon::start_page('Server Status').
1.3       bisitz     77:               &Apache::lonhtmlcommon::breadcrumbs('Server Status Information'));
1.1       raeburn    78: 
                     79:     if (keys(%candisplay) > 0) {
                     80:         $r->print('<h2>'.&mt('Server Utilities for Domain: [_1]','<i>'.$domdesc.'</i>').
1.6       raeburn    81:                   '</h2>'.&print_status_menu(\%candisplay,$dom));
1.1       raeburn    82:     } else {
1.3       bisitz     83:         $r->print(
                     84:             '<h2>'.&mt('No information available').'</h2>'
                     85:            .'<p class="LC_warning">'
                     86:            .&mt('Your current role and/or IP address does not have permission to display information about server status for servers in the domain: [_1].',
                     87:                 '<b>'.$domdesc.'</b> ('.$dom.')')
                     88:            .'</p>'
                     89:         ); 
1.1       raeburn    90:     }
                     91:     $r->print(&Apache::loncommon::end_page());
                     92:     return OK;
                     93: }
                     94: 
                     95: sub print_status_menu {
1.6       raeburn    96:     my ($candisplay,$dom) = @_;
1.1       raeburn    97:     return '' if (ref($candisplay) ne 'HASH');
1.3       bisitz     98:     return &Apache::lonhtmlcommon::generate_menu(
1.6       raeburn    99:                &servermenu_items($candisplay,$dom));
1.1       raeburn   100: }
                    101: 
                    102: sub servermenu_items {
1.6       raeburn   103:     my ($candisplay,$dom) = @_;
1.2       raeburn   104:     my $titles = &LONCAPA::lonauthcgi::serverstatus_titles();
1.1       raeburn   105:     my $linknames = &serverstatus_links();
                    106:     my @menu;
                    107:     if ((ref($candisplay) eq 'HASH') && (ref($titles) eq 'HASH') && 
                    108:         (ref($linknames) eq 'HASH')) { 
                    109:         @menu = ( {categorytitle => 'Status information',
                    110:                   items =>
                    111:                  [{
                    112:                  linktext => $linknames->{'userstatus'},
1.4       bisitz    113:                  icon => '',
                    114:                  alttext => '',
1.1       raeburn   115:                  #help => 'Domain_Coordination_Userstatus',
                    116:                  url => '/cgi-bin/userstatus.pl',
                    117:                  permission => $candisplay->{'userstatus'},
                    118:                  linktitle =>  $titles->{'userstatus'},
                    119:              },
                    120:              {
                    121:                  linktext => $linknames->{'lonstatus'},
1.4       bisitz    122:                  icon => '',
                    123:                  alttext => '',
1.1       raeburn   124:                  #help => 'Domain_Coordination_Connection_Status',
                    125:                  url => '/lon-status/',
                    126:                  permission => $candisplay->{'lonstatus'},
                    127:                  linktitle => $titles->{'lonstatus'},
                    128:              },
                    129:              {
                    130:                  linktext => $linknames->{'server-status'},
1.4       bisitz    131:                  icon => '',
                    132:                  alttext => '',
1.1       raeburn   133:                  #help => 'Domain_Coordination_Apache_Status',
                    134:                  url => '/server-status',
                    135:                  permission => $candisplay->{'server-status'},
                    136:                  linktitle => $titles->{'server-status'},
                    137:              },
                    138:              {
                    139:                  linktext => $linknames->{'clusterstatus'},
1.4       bisitz    140:                  icon => '',
                    141:                  alttext => '',
1.1       raeburn   142:                  #help => 'Domain_Coordination_Apache_Status',
                    143:                  url => '/cgi-bin/clusterstatus.pl',
                    144:                  permission => $candisplay->{'clusterstatus'},
                    145:                  linktitle => $titles->{'clusterstatus'},
                    146:              },
                    147:              {
1.8     ! raeburn   148:                  linktext => $linknames->{'certstatus'},
        !           149:                  icon => '',
        !           150:                  alttext => '',
        !           151:                  #help => 'Domain_Coordination_Apache_Status',
        !           152:                  url => '/cgi-bin/loncertstatus.pl',
        !           153:                  permission => $candisplay->{'certstatus'},
        !           154:                  linktitle => $titles->{'certstatus'},
        !           155:              },
        !           156:              {
1.1       raeburn   157:                  linktext => $linknames->{'codeversions'},
1.4       bisitz    158:                  icon => '',
                    159:                  alttext => '',
1.1       raeburn   160:                  #help => 'Domain_Coordination_Code_Versions',
                    161:                  url => '/cgi-bin/lonversions.pl',
                    162:                  permission => $candisplay->{'codeversions'},
                    163:                  linktitle => $titles->{'codeversions'},
                    164:              },
                    165:              {
1.5       raeburn   166:                  linktext => $linknames->{'checksums'},
                    167:                  icon => '',
                    168:                  alttext => '',
                    169:                  #help => 'Domain_Coordination_Code_Checksums',
                    170:                  url => '/cgi-bin/lonmodulecheck.pl',
                    171:                  permission => $candisplay->{'checksums'},
                    172:                  linktitle => $titles->{'checksums'},
                    173:              },
                    174:              {
1.7       raeburn   175:                  linktext => $linknames->{'diskusage'},
                    176:                  icon => '',
                    177:                  alttext => '',
                    178:                  #help => 'Domain_Coordination_Disk_Usage',
                    179:                  url => '/cgi-bin/quotacheck.pl?domain='.$dom,
                    180:                  permission => $candisplay->{'diskusage'},
                    181:                  linktitle => $titles->{'diskusage'},
                    182:              },
                    183:              {
1.6       raeburn   184:                  linktext => $linknames->{'uniquecodes'},
                    185:                  icon => '',
                    186:                  alttext => '',
                    187:                  #help => 'Domain_Coordination_Uniquecodes',
                    188:                  url => '/cgi-bin/listcodes.pl?domain='.$dom.'&amp;format=html',
                    189:                  permission => $candisplay->{'uniquecodes'},
                    190:                  linktitle => $titles->{'uniquecodes'},
                    191:              },
                    192:              {
1.1       raeburn   193:                  linktext => $linknames->{'showenv'},
1.4       bisitz    194:                  icon => '',
                    195:                  alttext => '',
1.1       raeburn   196:                  #help => 'Domain_Coordination_User_Environment',
                    197:                  url => '/adm/test',
                    198:                  permission => $candisplay->{'showenv'},
                    199:                  linktitle => $titles->{'showenv'},
                    200:              }]},
                    201:              {categorytitle => 'Server Actions',
                    202:              items =>
                    203:              [{
                    204:                  linktext => $linknames->{'loncron'},
1.4       bisitz    205:                  icon => '',
                    206:                  alttext => '',
1.1       raeburn   207:                  #help => 'Domain_Coordination_Connection_Reload',
                    208:                  url => '/cgi-bin/loncron.pl',
                    209:                  permission => $candisplay->{'loncron'},
                    210:                  linktitle => $titles->{'loncron'},
                    211:              },
                    212:              {
                    213:                  linktext => $linknames->{'takeoffline'},
1.4       bisitz    214:                  icon => '',
                    215:                  alttext => '',
1.1       raeburn   216:                  #help => 'Domain_Coordination_Server_Offline',
                    217:                  url => '/cgi-bin/takeoffline.pl',
                    218:                  permission => $candisplay->{'takeoffline'},
                    219:                  linktitle => $titles->{'takeoffline'},
                    220:              },
                    221:              {
                    222:                  linktext => $linknames->{'takeonline'},
1.4       bisitz    223:                  icon => '',
                    224:                  alttext => '',
1.1       raeburn   225:                  #help => 'Domain_Coordination_Server_Online',
                    226:                  url => '/cgi-bin/takeonline.pl',
                    227:                  permission => $candisplay->{'takeonline'},
                    228:                  linktitle => $titles->{'takeonline'},
                    229:              }]},
                    230:              {categorytitle => 'Metadata Information',
                    231:              items =>
                    232:              [{
                    233:                  linktext => $linknames->{'metadata_keywords'},
1.4       bisitz    234:                  icon => '',
                    235:                  alttext => '',
1.1       raeburn   236:                  #help => 'Domain_Coordination_Metadata_Keywords',
                    237:                  url => '/cgi-bin/metadata_keywords.pl',
                    238:                  permission => $candisplay->{'metadata_keywords'},
                    239:                  linktitle => $titles->{'metadata_keywords'},
                    240:              },
                    241:              {
                    242:                  linktext => $linknames->{'metadata_harvest'},
1.4       bisitz    243:                  icon => '',
                    244:                  alttext => '',
1.1       raeburn   245:                  #help => 'Domain_Coordination_Metadata_Harvest',
                    246:                  url => '/cgi-bin/metadata_harvest.pl',
                    247:                  permission => $candisplay->{'metadata_harvest'},
                    248:                  linktitle => $titles->{'metadata_harvest'},
                    249:              }]},
                    250:            );
                    251:         }
                    252:     return @menu;
                    253: }
                    254: 
                    255: sub serverstatus_links {
                    256:     my $linkname = { 
                    257:                     'userstatus' => 'User Sessions',
                    258:                     'lonstatus' => 'Connection Status',
                    259:                     'server-status' => 'Apache Server Status',
                    260:                     'clusterstatus' => 'Domain Status',
1.8     ! raeburn   261:                     'certstatus' => 'LON-CAPA SSL Certificates Status',   
1.1       raeburn   262:                     'codeversions' => 'LON-CAPA Modules',
1.5       raeburn   263:                     'checksums'    => 'Check for LON-CAPA Module changes',   
1.7       raeburn   264:                     'diskusage'    => 'Display quotas and usage for Course/Community Content',
1.1       raeburn   265:                     'showenv' => 'User Environment for current log-in',
                    266:                     'loncron' => 'Update Connections and Refresh Status Information',
1.6       raeburn   267:                     'uniquecodes' => "List Domain's Courses with Assigned Six Character codes",
1.1       raeburn   268:                     'takeoffline' => 'Replace log-in page with offline notice',
                    269:                     'takeonline' => 'Replace offline notice with log-in page',
                    270:                     'metadata_keywords' => 'Display Metadata Keywords',
                    271:                     'metadata_harvest' => 'Harvest Metadata Keywords',
                    272:     };
                    273:     return $linkname;
                    274: }
                    275: 
                    276: 1;

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>