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

1.1       raeburn     1: # The LearningOnline Network
                      2: # Generate a menu page containing links to server status pages accessible
                      3: # to user. 
                      4: #
1.9     ! raeburn     5: # $Id: domainstatus.pm,v 1.8 2016/07/25 19:50:30 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) {
1.9     ! raeburn    80:         $r->print(&print_status_menu(\%candisplay,$dom));
1.1       raeburn    81:     } else {
1.3       bisitz     82:         $r->print(
                     83:             '<h2>'.&mt('No information available').'</h2>'
                     84:            .'<p class="LC_warning">'
                     85:            .&mt('Your current role and/or IP address does not have permission to display information about server status for servers in the domain: [_1].',
                     86:                 '<b>'.$domdesc.'</b> ('.$dom.')')
                     87:            .'</p>'
                     88:         ); 
1.1       raeburn    89:     }
                     90:     $r->print(&Apache::loncommon::end_page());
                     91:     return OK;
                     92: }
                     93: 
                     94: sub print_status_menu {
1.6       raeburn    95:     my ($candisplay,$dom) = @_;
1.1       raeburn    96:     return '' if (ref($candisplay) ne 'HASH');
1.3       bisitz     97:     return &Apache::lonhtmlcommon::generate_menu(
1.6       raeburn    98:                &servermenu_items($candisplay,$dom));
1.1       raeburn    99: }
                    100: 
                    101: sub servermenu_items {
1.6       raeburn   102:     my ($candisplay,$dom) = @_;
1.2       raeburn   103:     my $titles = &LONCAPA::lonauthcgi::serverstatus_titles();
1.1       raeburn   104:     my $linknames = &serverstatus_links();
                    105:     my @menu;
                    106:     if ((ref($candisplay) eq 'HASH') && (ref($titles) eq 'HASH') && 
                    107:         (ref($linknames) eq 'HASH')) { 
                    108:         @menu = ( {categorytitle => 'Status information',
                    109:                   items =>
                    110:                  [{
                    111:                  linktext => $linknames->{'userstatus'},
1.4       bisitz    112:                  icon => '',
                    113:                  alttext => '',
1.1       raeburn   114:                  #help => 'Domain_Coordination_Userstatus',
                    115:                  url => '/cgi-bin/userstatus.pl',
                    116:                  permission => $candisplay->{'userstatus'},
                    117:                  linktitle =>  $titles->{'userstatus'},
                    118:              },
                    119:              {
                    120:                  linktext => $linknames->{'lonstatus'},
1.4       bisitz    121:                  icon => '',
                    122:                  alttext => '',
1.1       raeburn   123:                  #help => 'Domain_Coordination_Connection_Status',
                    124:                  url => '/lon-status/',
                    125:                  permission => $candisplay->{'lonstatus'},
                    126:                  linktitle => $titles->{'lonstatus'},
                    127:              },
                    128:              {
                    129:                  linktext => $linknames->{'server-status'},
1.4       bisitz    130:                  icon => '',
                    131:                  alttext => '',
1.1       raeburn   132:                  #help => 'Domain_Coordination_Apache_Status',
                    133:                  url => '/server-status',
                    134:                  permission => $candisplay->{'server-status'},
                    135:                  linktitle => $titles->{'server-status'},
                    136:              },
                    137:              {
                    138:                  linktext => $linknames->{'clusterstatus'},
1.4       bisitz    139:                  icon => '',
                    140:                  alttext => '',
1.1       raeburn   141:                  #help => 'Domain_Coordination_Apache_Status',
                    142:                  url => '/cgi-bin/clusterstatus.pl',
                    143:                  permission => $candisplay->{'clusterstatus'},
                    144:                  linktitle => $titles->{'clusterstatus'},
                    145:              },
                    146:              {
1.8       raeburn   147:                  linktext => $linknames->{'certstatus'},
                    148:                  icon => '',
                    149:                  alttext => '',
                    150:                  #help => 'Domain_Coordination_Apache_Status',
                    151:                  url => '/cgi-bin/loncertstatus.pl',
                    152:                  permission => $candisplay->{'certstatus'},
                    153:                  linktitle => $titles->{'certstatus'},
                    154:              },
                    155:              {
1.1       raeburn   156:                  linktext => $linknames->{'codeversions'},
1.4       bisitz    157:                  icon => '',
                    158:                  alttext => '',
1.1       raeburn   159:                  #help => 'Domain_Coordination_Code_Versions',
                    160:                  url => '/cgi-bin/lonversions.pl',
                    161:                  permission => $candisplay->{'codeversions'},
                    162:                  linktitle => $titles->{'codeversions'},
                    163:              },
                    164:              {
1.5       raeburn   165:                  linktext => $linknames->{'checksums'},
                    166:                  icon => '',
                    167:                  alttext => '',
                    168:                  #help => 'Domain_Coordination_Code_Checksums',
                    169:                  url => '/cgi-bin/lonmodulecheck.pl',
                    170:                  permission => $candisplay->{'checksums'},
                    171:                  linktitle => $titles->{'checksums'},
                    172:              },
                    173:              {
1.7       raeburn   174:                  linktext => $linknames->{'diskusage'},
                    175:                  icon => '',
                    176:                  alttext => '',
                    177:                  #help => 'Domain_Coordination_Disk_Usage',
                    178:                  url => '/cgi-bin/quotacheck.pl?domain='.$dom,
                    179:                  permission => $candisplay->{'diskusage'},
                    180:                  linktitle => $titles->{'diskusage'},
                    181:              },
                    182:              {
1.6       raeburn   183:                  linktext => $linknames->{'uniquecodes'},
                    184:                  icon => '',
                    185:                  alttext => '',
                    186:                  #help => 'Domain_Coordination_Uniquecodes',
                    187:                  url => '/cgi-bin/listcodes.pl?domain='.$dom.'&amp;format=html',
                    188:                  permission => $candisplay->{'uniquecodes'},
                    189:                  linktitle => $titles->{'uniquecodes'},
                    190:              },
                    191:              {
1.1       raeburn   192:                  linktext => $linknames->{'showenv'},
1.4       bisitz    193:                  icon => '',
                    194:                  alttext => '',
1.1       raeburn   195:                  #help => 'Domain_Coordination_User_Environment',
                    196:                  url => '/adm/test',
                    197:                  permission => $candisplay->{'showenv'},
                    198:                  linktitle => $titles->{'showenv'},
                    199:              }]},
                    200:              {categorytitle => 'Server Actions',
                    201:              items =>
                    202:              [{
                    203:                  linktext => $linknames->{'loncron'},
1.4       bisitz    204:                  icon => '',
                    205:                  alttext => '',
1.1       raeburn   206:                  #help => 'Domain_Coordination_Connection_Reload',
                    207:                  url => '/cgi-bin/loncron.pl',
                    208:                  permission => $candisplay->{'loncron'},
                    209:                  linktitle => $titles->{'loncron'},
                    210:              },
                    211:              {
                    212:                  linktext => $linknames->{'takeoffline'},
1.4       bisitz    213:                  icon => '',
                    214:                  alttext => '',
1.1       raeburn   215:                  #help => 'Domain_Coordination_Server_Offline',
                    216:                  url => '/cgi-bin/takeoffline.pl',
                    217:                  permission => $candisplay->{'takeoffline'},
                    218:                  linktitle => $titles->{'takeoffline'},
                    219:              },
                    220:              {
                    221:                  linktext => $linknames->{'takeonline'},
1.4       bisitz    222:                  icon => '',
                    223:                  alttext => '',
1.1       raeburn   224:                  #help => 'Domain_Coordination_Server_Online',
                    225:                  url => '/cgi-bin/takeonline.pl',
                    226:                  permission => $candisplay->{'takeonline'},
                    227:                  linktitle => $titles->{'takeonline'},
                    228:              }]},
                    229:              {categorytitle => 'Metadata Information',
                    230:              items =>
                    231:              [{
                    232:                  linktext => $linknames->{'metadata_keywords'},
1.4       bisitz    233:                  icon => '',
                    234:                  alttext => '',
1.1       raeburn   235:                  #help => 'Domain_Coordination_Metadata_Keywords',
                    236:                  url => '/cgi-bin/metadata_keywords.pl',
                    237:                  permission => $candisplay->{'metadata_keywords'},
                    238:                  linktitle => $titles->{'metadata_keywords'},
                    239:              },
                    240:              {
                    241:                  linktext => $linknames->{'metadata_harvest'},
1.4       bisitz    242:                  icon => '',
                    243:                  alttext => '',
1.1       raeburn   244:                  #help => 'Domain_Coordination_Metadata_Harvest',
                    245:                  url => '/cgi-bin/metadata_harvest.pl',
                    246:                  permission => $candisplay->{'metadata_harvest'},
                    247:                  linktitle => $titles->{'metadata_harvest'},
                    248:              }]},
                    249:            );
                    250:         }
                    251:     return @menu;
                    252: }
                    253: 
                    254: sub serverstatus_links {
                    255:     my $linkname = { 
                    256:                     'userstatus' => 'User Sessions',
                    257:                     'lonstatus' => 'Connection Status',
                    258:                     'server-status' => 'Apache Server Status',
                    259:                     'clusterstatus' => 'Domain Status',
1.8       raeburn   260:                     'certstatus' => 'LON-CAPA SSL Certificates Status',   
1.1       raeburn   261:                     'codeversions' => 'LON-CAPA Modules',
1.5       raeburn   262:                     'checksums'    => 'Check for LON-CAPA Module changes',   
1.7       raeburn   263:                     'diskusage'    => 'Display quotas and usage for Course/Community Content',
1.1       raeburn   264:                     'showenv' => 'User Environment for current log-in',
                    265:                     'loncron' => 'Update Connections and Refresh Status Information',
1.6       raeburn   266:                     'uniquecodes' => "List Domain's Courses with Assigned Six Character codes",
1.1       raeburn   267:                     'takeoffline' => 'Replace log-in page with offline notice',
                    268:                     'takeonline' => 'Replace offline notice with log-in page',
                    269:                     'metadata_keywords' => 'Display Metadata Keywords',
                    270:                     'metadata_harvest' => 'Harvest Metadata Keywords',
                    271:     };
                    272:     return $linkname;
                    273: }
                    274: 
                    275: 1;

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