Annotation of loncom/cgi/clusterstatus.pl, revision 1.16
1.1 www 1: #!/usr/bin/perl
2: $|=1;
3: # The LearningOnline Network with CAPA
4: # Cluster Status
1.9 www 5: #
1.16 ! www 6: # $Id: clusterstatus.pl,v 1.15 2003/08/05 12:52:23 www Exp $
1.3 harris41 7:
8: use lib '/home/httpd/lib/perl/';
9: use LONCAPA::Configuration;
1.16 ! www 10: use strict;
1.3 harris41 11:
1.1 www 12: use LWP::UserAgent();
13: use HTTP::Headers;
14: use IO::File;
15:
1.8 www 16: my %host=();
17: my $oneday=60*60*24;
18:
19: my %connectionstatus=();
1.9 www 20: my %perlvar=();
21:
22: my $mode;
1.14 www 23: my $concount=0;
1.16 ! www 24: my $fromcache;
! 25:
! 26: my %domaindescription = ();
! 27: my %domain_auth_def = ();
! 28: my %domain_auth_arg_def = ();
! 29:
! 30: my %hostname=();
! 31: my %hostip=();
! 32: my %hostdom=();
! 33: my %hostrole=();
! 34: my %libserv=();
! 35:
! 36: my $maxusers=0;
! 37: my $maxload=0;
! 38: my $totalusers=0;
! 39:
! 40: my %FORM=();
! 41:
! 42: my $stat_total=0;
! 43: my $stat_notyet=0;
! 44: my $stat_fromcache=0;
1.9 www 45:
46: sub select_form {
47: my ($def,$name,%hash) = @_;
48: my $selectform = "<select name=\"$name\" size=\"1\">\n";
49: foreach (sort keys %hash) {
50: $selectform.="<option value=\"$_\" ".
51: ($_ eq $def ? 'selected' : '').
52: ">".$hash{$_}."</option>\n";
53: }
54: $selectform.="</select>";
55: return $selectform;
56: }
57:
1.8 www 58:
59: sub key {
60: my ($local,$url)=@_;
61: my $key=$local.'_'.$url;
62: $key=~s/\W/\_/gs;
63: return $key;
64: }
65:
66: sub hidden {
67: my ($name,$value)=@_;
68: print "\n<input type='hidden' name='$name' value='$value' />";
69: }
70:
71: sub request {
72: my ($local,$url,$cachetime)=@_;
1.13 www 73: $cachetime*=(0.5+rand);
1.8 www 74: my $key=&key($local,$url);
75: my $reply='';
1.16 ! www 76: $stat_total++;
! 77: # if fromcache flag is set, only return cached values
! 78: if ($fromcache) {
! 79: if ($FORM{$key.'_time'}) {
! 80: return $FORM{$key};
! 81: $stat_fromcache++;
! 82: } else {
! 83: return 'not_yet';
! 84: $stat_notyet++;
! 85: }
! 86: }
! 87: # normal mode, refresh when expired or not yet present
1.8 www 88: if ($FORM{$key.'_time'}) {
89: if ((time-$FORM{$key.'_time'})<$cachetime) {
90: $reply=$FORM{$key};
91: &hidden($key.'_time',$FORM{$key.'_time'});
1.16 ! www 92: $stat_fromcache++;
1.8 www 93: }
94: }
95: unless ($reply) {
96: unless ($hostname{$local}) {
97: $reply='local_unknown';
98: } else {
99:
1.14 www 100: my $ua=new LWP::UserAgent(timeout => 10);
1.8 www 101:
102: my $request=new HTTP::Request('GET',
103: "http://".$hostname{$local}.$url);
104: $request->authorization_basic('lonadm','litelite');
105:
106: my $response=$ua->request($request);
107:
108: unless ($response->is_success) {
109: $reply='local_error';
110: } else {
111: $reply=$response->content;
112: chomp($reply);
113: }
114: }
115: &hidden($key.'_time',time);
116: }
117: &hidden($key,$reply);
118: return $reply;
119: }
120:
121: # ============================================= Are local and remote connected?
1.1 www 122: sub connected {
123: my ($local,$remote)=@_;
124: $local=~s/\W//g;
125: $remote=~s/\W//g;
126:
127: unless ($hostname{$remote}) { return 'remote_unknown'; }
1.8 www 128: my $url='/cgi-bin/ping.pl?'.$remote;
129: #
1.14 www 130: # Slowly phase this in: if not cached, only do 5 percent of the cases,
131: # but always do the first five.
1.8 www 132: #
133: unless ($FORM{&key($local,$url)}) {
1.16 ! www 134: unless (($concount<=5) || (rand>0.95)) {
! 135: $stat_total++;
! 136: $stat_notyet++;
1.14 www 137: return 'not_yet';
138: } else {
139: $concount++;
140: }
1.8 www 141: }
142: #
143: # Actually do the query
144: #
145: &statuslist($local,'connecting '.$remote);
1.9 www 146: my $reply=&request($local,$url,3600);
1.8 www 147: $reply=(split("\n",$reply))[0];
148: $reply=~s/\W//g;
149: if ($reply ne $remote) { return $reply; }
150: return 'ok';
151: }
152: # ============================================================ Get a reply hash
153:
154: sub replyhash {
155: my %returnhash=();
156: foreach (split(/\&/,&request(@_))) {
157: my ($name,$value)=split(/\=/,$_);
158: if ($name) {
159: unless ($value) { $value=''; }
160: $returnhash{$name}=$value;
161: }
162: }
163: return %returnhash;
164: }
1.1 www 165:
1.9 www 166: # ================================================================ Link to host
1.1 www 167:
1.8 www 168: sub otherwindow {
169: my ($local,$url,$label)=@_;
170: return
1.9 www 171: " <a href='http://$hostname{$local}$url' target='newwin$local'>$label</a> ";
172: }
173:
174: sub login {
175: my $local=shift;
176: print &otherwindow($local,'/adm/login?domain='.$perlvar{'lonDefDomain'},
177: 'Login');
178: }
179:
180: sub runloncron {
181: my $local=shift;
182: print &otherwindow($local,'/cgi-bin/loncron.pl','Run loncron');
183: }
184:
185: sub loncron {
186: my $local=shift;
187: print &otherwindow($local,'/lon-status','loncron');
188: }
189:
190: sub lonc {
191: my $local=shift;
192: print &otherwindow($local,'/lon-status/loncstatus.txt','lonc');
193: }
194:
195: sub lond {
196: my $local=shift;
197: print &otherwindow($local,'/lon-status/londstatus.txt','lond');
198: }
199:
200: sub users {
201: my $local=shift;
202: print &otherwindow($local,'/cgi-bin/userstatus.pl','Users');
203: }
204:
205: sub versions {
206: my $local=shift;
207: print &otherwindow($local,'/cgi-bin/lonversions.pl','Versions');
208: }
209:
210: sub server {
211: my $local=shift;
212: print &otherwindow($local,'/server-status','Server Status');
1.8 www 213: }
1.1 www 214:
1.11 www 215: # ========================================================= Produce a green bar
216: sub bar {
217: my $parm=shift;
218: my $number=int($parm+0.5);
219: print "<table><tr><td bgcolor='#225522'><font color='#225522'>";
220: for (my $i=0;$i<$number;$i++) {
221: print "+";
222: }
223: print "</font></table>";
224: }
225:
1.9 www 226: # ========================================================== Show server status
227:
1.8 www 228: sub serverstatus {
1.11 www 229: my ($local,$trouble)=@_;
1.9 www 230: print (<<ENDHEADER);
1.11 www 231: <a name="$local" />
1.9 www 232: <table width="100%" bgcolor="#225522" cellspacing="2" cellpadding="2" border="0">
233: <tr><td bgcolor="#BBDDBB"><font color="#225522" face="arial"><b>
234: $local $hostdom{$local}</b> <tt>($hostname{$local}; $hostrole{$local})</tt>
235: <br />$domaindescription{$hostdom{$local}}
1.10 www 236: </font></th></tr><tr><td bgcolor="#DDDDBB"><font color="#225522">
1.9 www 237: ENDHEADER
238: &login($local);&server($local);&users($local);&versions($local);
239: &loncron($local);&lond($local);&lonc($local);&runloncron($local);
1.11 www 240: print "</font></td></tr>";
241: if ($trouble) {
242: print ("<tr><td bgcolor='#DDBBBB'><font color='#552222' size='+2'>$trouble</font></td></tr>");
243: }
244: print "<tr><td bgcolor='#BBBBBB'>";
1.15 www 245: # version
246: if ($host{$local.'_version'}) {
247: print "<br />Version: ".$host{$local.'_version'}
248: }
1.9 www 249: # load
250: if (($host{$local.'_load_doomed'}>0.5) || ($mode eq 'load_doomed')) {
251: print "<br />Load: ".$host{$local.'_load'}
252: }
253: # users
254: if (($host{$local.'_users_doomed'}>10) || ($mode eq 'users_doomed')) {
255: print "<br />Active Users: ".$host{$local.'_users'}
256: }
257:
1.8 www 258: # checkrpms
259: if ($host{$local.'_checkrpms'}) {
260: print "<br />RPMs: ".$host{$local.'_checkrpms'}
261: }
262: # mysql
263: if ($host{$local.'_mysql'}) {
264: print "<br />MySQL Database: ".$host{$local.'_mysql'}
265: }
1.11 www 266: # connections
267: if ($host{$local.'_notconnected'}) {
268: print "<br />Not connected: ";
269: foreach (split(/ /,$host{$local.'_notconnected'})) {
270: if ($_) {
271: print " <a href='#$_'>$_</a>";
272: }
273: }
274: }
275: # errors
276: if ($host{$local.'_errors'}) {
277: print "<br />loncron errors: ".$host{$local.'_errors'};
278: }
1.9 www 279: print "</td></tr></table><br />";
280: }
281:
282: # =========================================================== Doomedness sorted
283:
284: sub doomedness {
285: my $crit=shift;
286: my %alldoomed=();
287: my @allhosts=();
288: foreach (keys %host) {
289: if ($_=~/^(\w+)\_$crit$/) {
290: if ($host{$_}) {
291: push (@allhosts,$1);
292: $alldoomed{$1}=$host{$_};
293: }
294: }
295: }
296: return sort { $alldoomed{$b} <=> $alldoomed{$a} } @allhosts;
1.8 www 297: }
1.1 www 298:
1.16 ! www 299: sub resetvars {
! 300: $maxusers=0;
! 301: $maxload=0;
! 302: $totalusers=0;
! 303: $stat_total=0;
! 304: $stat_notyet=0;
! 305: $stat_fromcache=0;
1.1 www 306:
1.16 ! www 307: undef %host;
! 308: %host=();
1.1 www 309: }
1.8 www 310:
1.16 ! www 311: sub mainloop {
! 312: &resetvars();
1.8 www 313: # ==================================================== Main Loop over all Hosts
314:
1.16 ! www 315: foreach my $local (sort keys %hostname) {
1.9 www 316: $host{$local.'_unresponsive_doomed'}=0;
1.8 www 317: # -- Check general status
318: &statuslist($local,'General');
319: my %loncron=&replyhash($local,'/lon-status/loncron_simple.txt',1200);
320: if (defined($loncron{'local_error'})) {
321: $host{$local.'_loncron'}='Could not determine.';
1.9 www 322: $host{$local.'_unresponsive_doomed'}++;
1.8 www 323: } else {
324: if ((time-$loncron{'time'})>$oneday) {
325: $host{$local.'_loncron'}='Stale.';
1.9 www 326: $host{$local.'_unresponsive_doomed'}++;
1.8 www 327: } else {
1.11 www 328: $host{$local.'_loncron_doomed'}=$loncron{'notices'}
329: +4*$loncron{'warnings'}
330: +100*$loncron{'errors'};
331: $host{$local.'_errors'}=$loncron{'errors'};
1.8 www 332: }
333: }
1.15 www 334: # -- Check version
335: &statuslist($local,'Version');
336: my $version=&request($local,'/lon-status/version.txt',7200);
337: if ($version eq 'local_error') {
338: $host{$local.'_version'}='Could not determine.';
339: $host{$local.'_unresponsive_doomed'}++;
340: } else {
341: $host{$local.'_version'}=$version;
342: }
1.8 www 343: # -- Check user status
344: &statuslist($local,'Users');
345: my %userstatus=&replyhash($local,'/cgi-bin/userstatus.pl?simple',600);
346: if (defined($userstatus{'local_error'})) {
347: $host{$local.'_userstatus'}='Could not determine.';
1.9 www 348: $host{$local.'_unresponsive_doomed'}++;
1.8 www 349: } else {
1.9 www 350: $host{$local.'_users_doomed'}=$userstatus{'Active'};
351: $host{$local.'_users'}=$userstatus{'Active'};
1.11 www 352: unless ($host{$local.'_users'}) { $host{$local.'_users'}=0; }
353: if ($host{$local.'_users'}>$maxusers) {
354: $maxusers=$host{$local.'_users'};
355: }
356: $totalusers+=$host{$local.'_users'};
1.9 www 357: my ($sload,$mload,$lload)=split(/ /,$userstatus{'loadavg'});
358: $host{$local.'_load_doomed'}=$mload;
1.11 www 359: if ($mload>$maxload) {
360: $maxload=$mload;
361: }
1.9 www 362: $host{$local.'_load'}=$userstatus{'loadavg'};
1.8 www 363: }
364: # -- Check mysql status
365: &statuslist($local,'Database');
1.9 www 366: my %mysql=&replyhash($local,'/lon-status/mysql.txt',3600);
1.8 www 367: if (defined($mysql{'local_error'})) {
368: $host{$local.'_mysql'}='Could not determine.';
1.9 www 369: $host{$local.'_unresponsive_doomed'}++;
1.8 www 370: } else {
371: if ((time-$mysql{'time'})>(7*$oneday)) {
372: if ($hostrole{$local} eq 'library') {
373: $host{$local.'_mysql'}='Stale.';
374: $host{$local.'_mysql_doomed'}=1;
375: }
376: if ($mysql{'mysql'} eq 'defunct') {
377: $host{$local.'_mysql'}='Defunct (maybe stale).';
378: $host{$local.'_mysql_doomed'}=2;
379: }
380: } elsif ($mysql{'mysql'} eq 'defunct') {
381: $host{$local.'_mysql'}='Defunct.';
382: $host{$local.'_mysql_doomed'}=3;
383: }
384: }
385: # -- Check rpm status
386: &statuslist($local,'RPMs');
1.9 www 387: my %checkrpms=&replyhash($local,'/lon-status/checkrpms.txt',7200);
1.8 www 388: if (defined($checkrpms{'local_error'})) {
389: $host{$local.'_checkrpms'}='Could not determine.';
1.9 www 390: $host{$local.'_unresponsive_doomed'}++;
1.8 www 391: } else {
392: if ((time-$checkrpms{'time'})>(4*$oneday)) {
393: $host{$local.'_checkrpms'}='Stale.';
394: $host{$local.'_checkrpms_doomed'}=50;
1.9 www 395: $host{$local.'_unresponsive_doomed'}++;
1.8 www 396: } elsif ($checkrpms{'status'} eq 'fail') {
397: $host{$local.'_checkrpms'}='Could not checked RPMs.';
398: $host{$local.'_checkrpms_doomed'}=100;
399: } elsif ($checkrpms{'rpmcount'}) {
400: $host{$local.'_checkrpms'}='Outdated RPMs: '.
401: $checkrpms{'rpmcount'};
402: $host{$local.'_checkrpms_doomed'}=$checkrpms{'rpmcount'};
403: }
404: }
405: # -- Check connections
406: &statuslist($local,'Connections');
407: $host{$local.'_notconnected'}='';
408: $host{$local.'_notconnected_doomed'}=0;
1.16 ! www 409: foreach my $remote (sort keys %hostname) {
1.8 www 410: my $status=&connected($local,$remote);
411: $connectionstatus{$local.'_TO_'.$remote}=$status;
412: unless (($status eq 'ok') || ($status eq 'not_yet')) {
413: $host{$local.'_notconnected'}.=' '.$remote;
414: $host{$local.'_notconnected_doomed'}++;
415: }
416: }
1.16 ! www 417: # =============================================================== End Main Loop
! 418: }
! 419:
1.8 www 420: }
1.16 ! www 421:
! 422: sub reports {
1.9 www 423: # ====================================================================== Output
424: if ($mode=~/\_doomed$/) {
425: # Output by doomedness
426: foreach (&doomedness($mode)) {
427: &serverstatus($_);
428: }
1.10 www 429: } elsif ($mode eq 'connections') {
430: print
431: "<table cellspacing='3' cellpadding='3' border='0' bgcolor='#225522'>".
432: "<tr><td bgcolor='#225522'> </td>";
1.11 www 433: foreach my $remote (sort keys %hostname) {
1.10 www 434: print '<th bgcolor="#DDDDBB">'.$remote.'</th>';
435: }
436: print "</tr>\n";
437: # connection matrix
1.11 www 438: foreach my $local (sort keys %hostname) {
1.10 www 439: print '<tr><th bgcolor="#DDDDBB">'.$local.'</th>';
1.11 www 440: foreach my $remote (sort keys %hostname) {
1.10 www 441: if ($connectionstatus{$local.'_TO_'.$remote} eq 'not_yet') {
1.14 www 442: my $cellcolor='#FFFFFF';
443: if ($local eq $remote) { $cellcolor='#DDDDDD'; }
444: print '<td bgcolor="'.$cellcolor.'"><font color="#555522" size="-2">not yet tested</font></td>';
1.10 www 445: } elsif ($connectionstatus{$local.'_TO_'.$remote} eq 'ok') {
1.14 www 446: my $cellcolor='#BBDDBB';
447: if ($local eq $remote) { $cellcolor='#99DD99'; }
1.10 www 448: print
1.14 www 449: '<td bgcolor="'.$cellcolor.'"><font color="#225522" face="arial"><b>ok</b></td>';
1.10 www 450: } else {
1.14 www 451: my $cellcolor='#DDBBBB';
452: if ($connectionstatus{$local.'_TO_'.$remote} eq 'local_error') {
453: if ($local eq $remote) {
454: $cellcolor='#DD88AA';
455: } else {
456: $cellcolor='#DDAACC';
457: }
458: } else {
459: if ($local eq $remote) { $cellcolor='#DD9999'; }
460: }
1.10 www 461: print
1.14 www 462: '<td bgcolor="'.$cellcolor.'"><font color="#552222" size="-2">'.
1.10 www 463: $connectionstatus{$local.'_TO_'.$remote}.'<br />';
464: &lonc($local); &lond($remote);
465: print '</td>';
466: }
467: }
468: print "</tr>\n";
469: }
1.11 www 470: print "</table>";
471: } elsif ($mode eq 'users') {
472: # Users
473: if ($maxusers) {
474: my $factor=50/$maxusers;
475: print "<h3>Total active user(s): $totalusers</h3>".
476: "<table cellspacing='3' cellpadding='3' border='0' bgcolor='#225522'>";
477:
1.16 ! www 478: foreach my $local (sort keys %hostname) {
1.11 www 479: if (defined($host{$local.'_users'})) {
480: print
1.16 ! www 481: '<tr><td bgcolor="#BBDDBB"><font face="arial" color="#225522" size="+1">'.$local.
! 482: '</font><br /><font size="-2">'.
! 483: $domaindescription{$hostdom{$local}}.
! 484: '</font></td><td bgcolor="#DDDDBB">';
1.12 www 485: &users($local);
1.11 www 486: print
487: '</td><td bgcolor="#DDDDBB"><font face="arial" color="#225522">'.
488: $host{$local.'_users'}.'</font></td><td bgcolor="#DDDDBB"';
489: &bar($factor*$host{$local.'_users'});
490: print "</td></tr>\n";
491: }
492: }
493: print "</table>";
494: } else {
495: print "No active users logged in.";
496: }
497: } elsif ($mode eq 'load') {
498: # Load
499: if ($maxload) {
500: my $factor=50/$maxload;
501: print
502: "<table cellspacing='3' cellpadding='3' border='0' bgcolor='#225522'>";
1.16 ! www 503: foreach my $local (sort keys %hostname) {
1.11 www 504: if (defined($host{$local.'_load_doomed'})) {
505: print
1.16 ! www 506: '<tr><td bgcolor="#BBDDBB"><font face="arial" color="#225522" size="+1">'.
1.11 www 507: $local.
1.16 ! www 508: '</font><br /><font size="-2">'.
! 509: $domaindescription{$hostdom{$local}}.
! 510: '</font></td><td bgcolor="#DDDDBB">';
1.12 www 511: &server($local);
1.11 www 512: print
513: '</td><td bgcolor="#DDDDBB"><font face="arial" color="#225522">'.
514: $host{$local.'_load_doomed'}.'</font></td><td bgcolor="#DDDDBB"';
515: &bar($factor*$host{$local.'_load_doomed'});
516: print "</td></tr>\n";
517: }
518: }
519: print "</table>";
520: } else {
521: print "No workload.";
522: }
523: } elsif ($mode eq 'trouble') {
524: my $count=0;
1.16 ! www 525: foreach my $local (sort keys %hostname) {
1.11 www 526: my $trouble='';
1.15 www 527: if ($host{$local.'_unresponsive_doomed'}>3) {
528: $trouble='Does not respond to several queries.<br />';
529: }
1.11 www 530: if ($host{$local.'_errors'}) {
531: $trouble='Has loncron errors.<br />';
532: } elsif ($host{$local.'_loncron_doomed'}>600) {
533: $trouble='High loncron count.<br />';
534: }
535: if ($host{$local.'_load_doomed'}>5) {
536: $trouble='High load.<br />';
537: }
538: if ($host{$local.'_users_doomed'}>200) {
539: $trouble='High user volume.<br />';
540: }
541: if ($host{$local.'_mysql_doomed'}>1) {
542: $trouble='MySQL database apparently offline.<br />';
543: }
544: if ($host{$local.'_checkrpms_doomed'}>100) {
545: $trouble='RPMs outdated.<br />';
546: }
547: if ($trouble) { $count++; &serverstatus($local,$trouble); }
548: }
549: unless ($count) { print "No mayor trouble."; }
1.9 www 550: }
1.16 ! www 551: }
! 552:
! 553: # ====================================================================== Status
! 554: sub statuslist {
! 555: my ($local,$what)=@_;
! 556: print
! 557: "<script>document.prgstat.progress.value='Testing $local ($hostname{$local}): $what';</script>\n";
! 558: }
! 559:
! 560: # =============================================================================
! 561: # =============================================================================
! 562: # Main program
! 563: #
! 564: # ========================================================= Get form parameters
! 565: my $buffer;
! 566:
! 567: read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
! 568: my @pairs=split(/&/,$buffer);
! 569: my $pair; my $name; my $value;
! 570: undef %FORM;
! 571: %FORM=();
! 572: foreach $pair (@pairs) {
! 573: ($name,$value) = split(/=/,$pair);
! 574: $value =~ tr/+/ /;
! 575: $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
! 576: $FORM{$name}=$value;
! 577: }
! 578:
! 579: $buffer=$ENV{'QUERY_STRING'};
! 580: @pairs=split(/&/,$buffer);
! 581: foreach $pair (@pairs) {
! 582: ($name,$value) = split(/=/,$pair);
! 583: $value =~ tr/+/ /;
! 584: $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
! 585: $FORM{$name}=$value;
! 586: }
! 587:
! 588: # ====================================================== Determine refresh rate
! 589:
! 590: my $refresh=(($FORM{'refresh'}=~/^\d+$/)?$FORM{'refresh'}:30);
! 591: if ($refresh<30) { $refresh=30; }
! 592: my $starttime=time;
! 593:
! 594: # ============================================================== Determine mode
! 595:
! 596: my %modes=('trouble' => 'Trouble',
! 597: 'users_doomed' => 'Doomed: Users',
! 598: 'loncron_doomed' => 'Doomed: General (loncron)',
! 599: 'mysql_doomed' => 'Doomed: Database (mysql)',
! 600: 'notconnected_doomed' => 'Doomed: Connections',
! 601: 'checkrpms_doomed' => 'Doomed: RPMs',
! 602: 'load_doomed' => 'Doomed: Load',
! 603: 'unresponsive_doomed' => 'Doomed: Status could not be determined',
! 604: 'users' => 'User Report',
! 605: 'load' => 'Load Report',
! 606: 'connections' => 'Connections Matrix');
! 607:
! 608: $mode=$FORM{'mode'};
! 609: unless ($modes{$mode}) { $mode='trouble'; }
! 610: # ================================================================ Send Headers
! 611: print "Content-type: text/html\n\n".
! 612: "<html><body bgcolor='#FFFFFF'>\n";
! 613: # -------------------- Read loncapa.conf (and by default, loncapa_apache.conf).
! 614: my $perlvarref=LONCAPA::Configuration::read_conf('loncapa.conf');
! 615: %perlvar=%{$perlvarref};
! 616: undef $perlvarref; # remove since sensitive and not needed
! 617: delete $perlvar{'lonReceipt'}; # remove since sensitive and not needed
! 618: delete $perlvar{'lonSqlAccess'}; # remove since sensitive and not needed
! 619:
! 620: # ------------------------------------------------------------- Read hosts file
! 621: {
! 622: my $config=IO::File->new("$perlvar{'lonTabDir'}/hosts.tab");
! 623:
! 624: while (my $configline=<$config>) {
! 625: $configline=~s/#.*$//;
! 626: unless ($configline=~/\w/) { next; }
! 627: my ($id,$domain,$role,$name,$ip)=split(/:/,$configline);
! 628: $hostname{$id}=$name;
! 629: $hostdom{$id}=$domain;
! 630: $hostrole{$id}=$role;
! 631: $hostip{$id}=$ip;
! 632: if (($role eq 'library') && ($id ne $perlvar{'lonHostID'})) {
! 633: $libserv{$id}=$name;
! 634: }
! 635: }
! 636: }
! 637: # ------------------------------------------------------------ Read domain file
! 638: {
! 639: my $fh=IO::File->new($perlvar{'lonTabDir'}.'/domain.tab');
! 640: if ($fh) {
! 641: while (<$fh>) {
! 642: next if (/^(\#|\s*$)/);
! 643: chomp;
! 644: my ($domain, $domain_description, $def_auth, $def_auth_arg)
! 645: = split(/:/,$_,4);
! 646: $domain_auth_def{$domain}=$def_auth;
! 647: $domain_auth_arg_def{$domain}=$def_auth_arg;
! 648: $domaindescription{$domain}=$domain_description;
! 649: }
! 650: }
! 651: }
! 652:
! 653: print "<img src='/adm/lonIcons/lonlogos.gif' align='right' /><h1>LON-CAPA Cluster Status ".localtime()."</h1>";
! 654: print "<form name='prgstat'>\n".
! 655: "<input type='text' name='progress' value='Starting ...' size='100' /><br />".
! 656: "</form>\n";;
! 657: print "<form name='status' method='post'>\n";
! 658: print 'Choose next report: '.&select_form($mode,'mode',%modes).'<hr />';
! 659: &hidden('refresh',$refresh);
! 660:
! 661: if (!$FORM{'runonetime'}) {
! 662: print
! 663: "<h3>Gathering initial cluster data</h3>This may take some time ...<br />";
! 664: $fromcache=0;
! 665: &mainloop();
! 666: &statuslist('Done initial run.');
! 667: &reports();
! 668: } else {
! 669: $fromcache=1;
! 670: &mainloop();
! 671: &statuslist('Done gathering cached data');
! 672: &reports();
! 673: $fromcache=0;
! 674: &mainloop();
! 675: }
! 676: &hidden('runonetime',1);
! 677: print '<tt><br />Total number of queries: '.$stat_total.
! 678: '<br />Percent complete: '.
! 679: int(($stat_total-$stat_notyet)/$stat_total*100.).
! 680: '<br />Percent from cache: '.
! 681: int($stat_fromcache/$stat_total*100.).'</tt>';
! 682:
1.9 www 683: # ============================================================== Close, refresh
1.8 www 684: print "</form><script>";
1.16 ! www 685: my $runtime=time-$starttime;
! 686: if (($refresh-$runtime)<0) {
! 687: print "document.status.submit();";
1.8 www 688: } else {
1.16 ! www 689: my $refreshtime=int(1000*($refresh-$runtime));
1.11 www 690: print "setTimeout('document.status.submit()',$refreshtime);\n".
691: "document.prgstat.progress.value='Will automatically refresh ($refresh secs refresh cycle)'";
1.2 www 692: }
1.8 www 693: print "</script></body></html>";
694: exit 0;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>