Annotation of loncom/loncron, revision 1.19
1.1 albertel 1: #!/usr/bin/perl
2:
3: # The LearningOnline Network
4: # Housekeeping program, started by cron
5: #
6: # (TCP networking package
7: # 6/1/99,6/2,6/10,6/11,6/12,6/14,6/26,6/28,6/29,6/30,
8: # 7/1,7/2,7/9,7/10,7/12 Gerd Kortemeyer)
9: #
1.3 www 10: # 7/14,7/15,7/19,7/21,7/22,11/18,
11: # 2/8 Gerd Kortemeyer
1.11 www 12: # Dec 00 Scott Harrison
13: # 12/23 Gerd Kortemeyer
1.19 ! harris41 14: # 02/12/2001, 04/11/2001 Scott Harrison
1.1 albertel 15:
16: use IO::File;
17: use IO::Socket;
18:
19: # -------------------------------------------------- Non-critical communication
20: sub reply {
21: my ($cmd,$server)=@_;
22: my $peerfile="$perlvar{'lonSockDir'}/$server";
23: my $client=IO::Socket::UNIX->new(Peer =>"$peerfile",
24: Type => SOCK_STREAM,
25: Timeout => 10)
26: or return "con_lost";
27: print $client "$cmd\n";
28: my $answer=<$client>;
29: chomp($answer);
30: if (!$answer) { $answer="con_lost"; }
31: return $answer;
32: }
33:
34: # --------------------------------------------------------- Output error status
35:
36: sub errout {
37: my $fh=shift;
38: print $fh (<<ENDERROUT);
39: <p><table border=2 bgcolor="#CCCCCC">
40: <tr><td>Notices</td><td>$notices</td></tr>
41: <tr><td>Warnings</td><td>$warnings</td></tr>
42: <tr><td>Errors</td><td>$errors</td></tr>
43: </table><p><a href="#top">Top</a><p>
44: ENDERROUT
45: }
46:
47: # ================================================================ Main Program
48:
49: # ------------------------------------------------------------ Read access.conf
50: {
51: my $config=IO::File->new("/etc/httpd/conf/access.conf");
52:
53: while (my $configline=<$config>) {
54: if ($configline =~ /PerlSetVar/) {
55: my ($dummy,$varname,$varvalue)=split(/\s+/,$configline);
56: $perlvar{$varname}=$varvalue;
57: }
58: }
1.19 ! harris41 59: delete $perlvar{'lonReceipt'}; # remove since sensitive and not needed
! 60: delete $perlvar{'lonSqlAccess'}; # remove since sensitive and not needed
1.13 harris41 61: }
62:
1.14 harris41 63: # --------------------------------------- Make sure that LON-CAPA is configured
64: # I only test for one thing here (lonHostID). This is just a safeguard.
65: if ('{[[[[lonHostID]]]]}' eq $perlvar{'lonHostID'}) {
1.15 harris41 66: print("Unconfigured machine.\n");
1.14 harris41 67: $emailto=$perlvar{'lonSysEMail'};
68: $hostname=`/bin/hostname`;
69: chop $hostname;
70: $hostname=~s/[^\w\.]//g; # make sure is safe to pass through shell
71: $subj="LON: Unconfigured machine $hostname";
72: system("echo 'Unconfigured machine $hostname.' |\
73: mailto $emailto -s '$subj' > /dev/null");
74: exit 1;
75: }
76:
1.13 harris41 77: # ----------------------------- Make sure this process is running from user=www
78: my $wwwid=getpwnam('www');
79: if ($wwwid!=$<) {
1.14 harris41 80: print("User ID mismatch. This program must be run as user 'www'\n");
1.13 harris41 81: $emailto="$perlvar{'lonAdmEMail'},$perlvar{'lonSysEMail'}";
82: $subj="LON: $perlvar{'lonHostID'} User ID mismatch";
83: system("echo 'User ID mismatch. loncron must be run as user www.' |\
84: mailto $emailto -s '$subj' > /dev/null");
1.14 harris41 85: exit 1;
1.1 albertel 86: }
87:
88: # ------------------------------------------------------------- Read hosts file
89: {
90: my $config=IO::File->new("$perlvar{'lonTabDir'}/hosts.tab");
91:
92: while (my $configline=<$config>) {
93: my ($id,$domain,$role,$name,$ip)=split(/:/,$configline);
94: $hostname{$id}=$name;
95: $hostdom{$id}=$domain;
96: $hostrole{$id}=$role;
97: $hostip{$id}=$ip;
98: if (($role eq 'library') && ($id ne $perlvar{'lonHostID'})) {
99: $libserv{$id}=$name;
100: }
101: }
102: }
103:
104: # ------------------------------------------------------ Read spare server file
105: {
106: my $config=IO::File->new("$perlvar{'lonTabDir'}/spare.tab");
107:
108: while (my $configline=<$config>) {
109: chomp($configline);
110: if (($configline) && ($configline ne $perlvar{'lonHostID'})) {
111: $spareid{$configline}=1;
112: }
113: }
114: }
115:
116: # ---------------------------------------------------------------- Start report
117:
118: $statusdir="/home/httpd/html/lon-status";
119:
120: $errors=0;
121: $warnings=0;
122: $notices=0;
123:
124: $now=time;
125: $date=localtime($now);
126:
127: {
128: my $fh=IO::File->new(">$statusdir/newstatus.html");
129:
130: print $fh (<<ENDHEADERS);
131: <html>
132: <head>
133: <title>LON Status Report $perlvar{'lonHostID'}</title>
134: </head>
1.3 www 135: <body bgcolor="#AAAAAA">
1.1 albertel 136: <a name="top">
137: <h1>LON Status Report $perlvar{'lonHostID'}</h1>
138: <h2>$date ($now)</h2>
139: <ol>
140: <li><a href="#configuration">Configuration</a>
141: <li><a href="#machine">Machine Information</a>
1.11 www 142: <li><a href="#tmp">Temporary Files</a>
143: <li><a href="#tokens">Session Tokens</a>
1.1 albertel 144: <li><a href="#httpd">httpd</a>
1.11 www 145: <li><a href="#lonsql">lonsql</a>
1.1 albertel 146: <li><a href="#lond">lond</a>
147: <li><a href="#lonc">lonc</a>
148: <li><a href="#lonnet">lonnet</a>
149: <li><a href="#connections">Connections</a>
150: <li><a href="#delayed">Delayed Messages</a>
151: <li><a href="#errcount">Error Count</a>
152: </ol>
153: <hr>
154: <a name="configuration">
155: <h2>Configuration</h2>
156: <h3>PerlVars</h3>
157: <table border=2>
158: ENDHEADERS
159:
160: foreach $varname (keys %perlvar) {
161: print $fh "<tr><td>$varname</td><td>$perlvar{$varname}</td></tr>\n";
162: }
163: print $fh "</table><h3>Hosts</h3><table border=2>";
164: foreach $id (keys %hostname) {
165: print $fh
166: "<tr><td>$id</td><td>$hostdom{$id}</td><td>$hostrole{$id}</td>";
167: print $fh "<td>$hostname{$id}</td><td>$hostip{$id}</td></tr>\n";
168: }
169: print $fh "</table><h3>Spare Hosts</h3><ol>";
170: foreach $id (keys %spareid) {
171: print $fh "<li>$id\n";
172: }
173:
174: print $fh "</ol>\n";
175:
176: # --------------------------------------------------------------------- Machine
177:
178: print $fh '<hr><a name="machine"><h2>Machine Information</h2>';
179: print $fh "<h3>loadavg</h3>";
180:
181: open (LOADAVGH,"/proc/loadavg");
182: $loadavg=<LOADAVGH>;
183: close (LOADAVGH);
184:
185: print $fh "<tt>$loadavg</tt>";
186:
187: @parts=split(/\s+/,$loadavg);
1.4 www 188: if ($parts[1]>4.0) {
1.1 albertel 189: $errors++;
190: } elsif ($parts[1]>2.0) {
191: $warnings++;
192: } elsif ($parts[1]>1.0) {
193: $notices++;
194: }
195:
196: print $fh "<h3>df</h3>";
197: print $fh "<pre>";
198:
199: open (DFH,"df|");
200: while ($line=<DFH>) {
201: print $fh "$line";
202: @parts=split(/\s+/,$line);
203: $usage=$parts[4];
204: $usage=~s/\W//g;
205: if ($usage>90) {
1.4 www 206: $warnings++;
1.1 albertel 207: } elsif ($usage>80) {
208: $warnings++;
209: } elsif ($usage>60) {
210: $notices++;
211: }
1.4 www 212: if ($usage>95) { $warnings++; $warnings++ }
1.1 albertel 213: }
214: close (DFH);
215: print $fh "</pre>";
216: &errout($fh);
1.11 www 217:
218: # --------------------------------------------------------------- clean out tmp
219: print $fh '<hr><a name="tmp"><h2>Temporary Files</h2>';
220: $cleaned=0;
221: while ($fname=<$perlvar{'lonDaemons'}/tmp/*>) {
222: my ($dev,$ino,$mode,$nlink,
223: $uid,$gid,$rdev,$size,
224: $atime,$mtime,$ctime,
225: $blksize,$blocks)=stat($fname);
226: $now=time;
227: $since=$now-$mtime;
228: if ($since>$perlvar{'lonExpire'}) {
229: $cleaned++;
230: unlink("$fname");
231: }
232:
233: }
234: print $fh "Cleaned up ".$cleaned." files.";
235:
236: # ------------------------------------------------------------ clean out lonIDs
237: print $fh '<hr><a name="tokens"><h2>Session Tokens</h2>';
238: $cleaned=0;
239: $active=0;
240: while ($fname=<$perlvar{'lonIDsDir'}/*>) {
241: my ($dev,$ino,$mode,$nlink,
242: $uid,$gid,$rdev,$size,
243: $atime,$mtime,$ctime,
244: $blksize,$blocks)=stat($fname);
245: $now=time;
246: $since=$now-$mtime;
247: if ($since>$perlvar{'lonExpire'}) {
248: $cleaned++;
249: print $fh "Unlinking $fname<br>";
250: unlink("$fname");
251: } else {
252: $active++;
253: }
254:
255: }
256: print $fh "<p>Cleaned up ".$cleaned." stale session token(s).";
257: print $fh "<h3>$active open session(s)</h3>";
258:
1.1 albertel 259: # ----------------------------------------------------------------------- httpd
260:
261: print $fh '<hr><a name="httpd"><h2>httpd</h2><h3>Access Log</h3><pre>';
262:
263: open (DFH,"tail -n40 /etc/httpd/logs/access_log|");
264: while ($line=<DFH>) { print $fh "$line" };
265: close (DFH);
266:
267: print $fh "</pre><h3>Error Log</h3><pre>";
268:
269: open (DFH,"tail -n50 /etc/httpd/logs/error_log|");
270: while ($line=<DFH>) {
271: print $fh "$line";
272: if ($line=~/\[error\]/) { $notices++; }
273: };
274: close (DFH);
275: print $fh "</pre>";
276: &errout($fh);
1.5 harris41 277:
278:
1.11 www 279: # ---------------------------------------------------------------------- lonsql
280: #
281: # Do not run for now
282: #
1.18 harris41 283: if ($perlvar{'lonRole'} eq "library") {
1.5 harris41 284:
1.11 www 285: print $fh '<hr><a name="lonsql"><h2>lonsql</h2><h3>Log</h3><pre>';
1.5 harris41 286:
287: if (-e "$perlvar{'lonDaemons'}/logs/lonsql.log"){
288: open (DFH,"tail -n100 $perlvar{'lonDaemons'}/logs/lonsql.log|");
289: while ($line=<DFH>) {
290: print $fh "$line";
291: if ($line=~/INFO/) { $notices++; }
292: if ($line=~/WARNING/) { $notices++; }
293: if ($line=~/CRITICAL/) { $warnings++; }
294: };
295: close (DFH);
296: }
297: print $fh "</pre>";
298:
299: my $lonsqlfile="$perlvar{'lonDaemons'}/logs/lonsql.pid";
300:
301: if (-e $lonsqlfile) {
302: my $lfh=IO::File->new("$lonsqlfile");
303: my $lonsqlpid=<$lfh>;
304: chomp($lonsqlpid);
305: if (kill 0 => $lonsqlpid) {
306: print $fh "<h3>lonsql at pid $lonsqlpid responding</h3>";
307: } else {
308: $errors++; $errors++;
309: print $fh "<h3>lonsql at pid $lonsqlpid not responding</h3>";
310: }
311: } else {
312: $errors++;
313: print $fh "<h3>lonsql not running, trying to start</h3>";
1.16 harris41 314: system(
315: "$perlvar{'lonDaemons'}/lonsql 2>>$perlvar{'lonDaemons'}/logs/lonsql_errors");
1.5 harris41 316: sleep 120;
317: if (-e $lonsqlfile) {
318: print $fh "Seems like it started ...<p>";
319: my $lfh=IO::File->new("$lonsqlfile");
320: my $lonsqlpid=<$lfh>;
321: chomp($lonsqlpid);
322: sleep 30;
323: if (kill 0 => $lonsqlpid) {
324: print $fh "<h3>lonsql at pid $lonsqlpid responding</h3>";
325: } else {
326: $errors++; $errors++;
327: print $fh "<h3>lonsql at pid $lonsqlpid not responding</h3>";
328: print $fh "Give it one more try ...<p>";
1.16 harris41 329: system(
330: "$perlvar{'lonDaemons'}/lonsql 2>>$perlvar{'lonDaemons'}/logs/lonsql_errors");
1.5 harris41 331: sleep 120;
332: }
333: } else {
334: print $fh "Seems like that did not work!<p>";
335: $errors++;
336: }
337: if (-e "$perlvar{'lonDaemons'}/logs/lonsql.log"){
338: print $fh "<p><pre>";
339: open (DFH,"tail -n100 $perlvar{'lonDaemons'}/logs/lonsql.log|");
340: while ($line=<DFH>) {
341: print $fh "$line";
342: if ($line=~/WARNING/) { $notices++; }
343: if ($line=~/CRITICAL/) { $notices++; }
344: };
345: close (DFH);
346: print $fh "</pre>";
347: }
348: }
349:
350: $fname="$perlvar{'lonDaemons'}/logs/lonsql.log";
351:
352: my ($dev,$ino,$mode,$nlink,
353: $uid,$gid,$rdev,$size,
354: $atime,$mtime,$ctime,
355: $blksize,$blocks)=stat($fname);
356:
357: if ($size>40000) {
358: print $fh "Rotating logs ...<p>";
359: rename("$fname.2","$fname.3");
360: rename("$fname.1","$fname.2");
361: rename("$fname","$fname.1");
362: }
363:
364: &errout($fh);
365: }
1.1 albertel 366: # ------------------------------------------------------------------------ lond
367:
368: print $fh '<hr><a name="lond"><h2>lond</h2><h3>Log</h3><pre>';
369:
370: if (-e "$perlvar{'lonDaemons'}/logs/lond.log"){
1.3 www 371: open (DFH,"tail -n100 $perlvar{'lonDaemons'}/logs/lond.log|");
1.1 albertel 372: while ($line=<DFH>) {
373: print $fh "$line";
1.3 www 374: if ($line=~/INFO/) { $notices++; }
1.4 www 375: if ($line=~/WARNING/) { $notices++; }
376: if ($line=~/CRITICAL/) { $warnings++; }
1.1 albertel 377: };
378: close (DFH);
379: }
380: print $fh "</pre>";
381:
382: my $londfile="$perlvar{'lonDaemons'}/logs/lond.pid";
383:
1.7 harris41 384: my $restartflag=1;
385: if (-e $londfile) {
1.1 albertel 386: my $lfh=IO::File->new("$londfile");
387: my $londpid=<$lfh>;
388: chomp($londpid);
389: if (kill 0 => $londpid) {
390: print $fh "<h3>lond at pid $londpid responding</h3>";
1.7 harris41 391: $restartflag=0;
1.1 albertel 392: } else {
1.8 harris41 393: $errors++;
1.1 albertel 394: print $fh "<h3>lond at pid $londpid not responding</h3>";
1.7 harris41 395: # Intelligently handle this.
396: # Possibility #1: there is no process
397: # Solution: remove .pid file and restart
398: if (getpgrp($londpid)==-1) {
399: unlink($londfile);
400: $restartflag=1;
401: }
1.8 harris41 402: else {
1.10 harris41 403: # Possibility #2: there is a live process that is not responding
1.7 harris41 404: # for an unknown reason
1.10 harris41 405: # Solution: kill parent and children processes, remove .pid and restart
1.9 harris41 406: `killall -9 lond`;
1.8 harris41 407: unlink($londfile);
408: $restartflag=1;
409: }
410: print $fh
411: "<h3>Deciding to clean up stale .pid file and restart lond</h3>";
1.1 albertel 412: }
1.7 harris41 413: }
414: if ($restartflag==1) {
1.1 albertel 415: $errors++;
416: print $fh "<h3>lond not running, trying to start</h3>";
1.16 harris41 417: system(
418: "$perlvar{'lonDaemons'}/lond 2>>$perlvar{'lonDaemons'}/logs/lond_errors");
1.1 albertel 419: sleep 120;
420: if (-e $londfile) {
421: print $fh "Seems like it started ...<p>";
422: my $lfh=IO::File->new("$londfile");
423: my $londpid=<$lfh>;
424: chomp($londpid);
425: sleep 30;
426: if (kill 0 => $londpid) {
427: print $fh "<h3>lond at pid $londpid responding</h3>";
428: } else {
429: $errors++; $errors++;
430: print $fh "<h3>lond at pid $londpid not responding</h3>";
431: print $fh "Give it one more try ...<p>";
1.16 harris41 432: system(
433: "$perlvar{'lonDaemons'}/lond 2>>$perlvar{'lonDaemons'}/logs/lond_errors");
1.1 albertel 434: sleep 120;
435: }
436: } else {
437: print $fh "Seems like that did not work!<p>";
438: $errors++;
439: }
1.3 www 440: if (-e "$perlvar{'lonDaemons'}/logs/lond.log"){
441: print $fh "<p><pre>";
442: open (DFH,"tail -n100 $perlvar{'lonDaemons'}/logs/lond.log|");
443: while ($line=<DFH>) {
444: print $fh "$line";
1.4 www 445: if ($line=~/WARNING/) { $notices++; }
446: if ($line=~/CRITICAL/) { $notices++; }
1.3 www 447: };
448: close (DFH);
449: print $fh "</pre>";
450: }
1.1 albertel 451: }
452:
453: $fname="$perlvar{'lonDaemons'}/logs/lond.log";
454:
455: my ($dev,$ino,$mode,$nlink,
456: $uid,$gid,$rdev,$size,
457: $atime,$mtime,$ctime,
458: $blksize,$blocks)=stat($fname);
459:
460: if ($size>40000) {
461: print $fh "Rotating logs ...<p>";
462: rename("$fname.2","$fname.3");
463: rename("$fname.1","$fname.2");
464: rename("$fname","$fname.1");
465: }
466:
467: &errout($fh);
468: # ------------------------------------------------------------------------ lonc
469:
470: print $fh '<hr><a name="lonc"><h2>lonc</h2><h3>Log</h3><pre>';
471:
472: if (-e "$perlvar{'lonDaemons'}/logs/lonc.log"){
1.3 www 473: open (DFH,"tail -n100 $perlvar{'lonDaemons'}/logs/lonc.log|");
1.1 albertel 474: while ($line=<DFH>) {
475: print $fh "$line";
1.3 www 476: if ($line=~/INFO/) { $notices++; }
1.4 www 477: if ($line=~/WARNING/) { $notices++; }
478: if ($line=~/CRITICAL/) { $warnings++; }
1.1 albertel 479: };
480: close (DFH);
481: }
482: print $fh "</pre>";
483:
484: my $loncfile="$perlvar{'lonDaemons'}/logs/lonc.pid";
485:
1.7 harris41 486: $restartflag=1;
1.1 albertel 487: if (-e $loncfile) {
488: my $lfh=IO::File->new("$loncfile");
489: my $loncpid=<$lfh>;
490: chomp($loncpid);
491: if (kill 0 => $loncpid) {
492: print $fh "<h3>lonc at pid $loncpid responding, sending USR1</h3>";
493: kill USR1 => $loncpid;
1.7 harris41 494: $restartflag=0;
1.1 albertel 495: } else {
1.8 harris41 496: $errors++;
1.1 albertel 497: print $fh "<h3>lonc at pid $loncpid not responding</h3>";
1.7 harris41 498: # Intelligently handle this.
499: # Possibility #1: there is no process
500: # Solution: remove .pid file and restart
501: if (getpgrp($loncpid)==-1) {
502: unlink($loncfile);
503: $restartflag=1;
504: }
1.8 harris41 505: else {
1.10 harris41 506: # Possibility #2: there is a live process that is not responding
1.7 harris41 507: # for an unknown reason
1.10 harris41 508: # Solution: kill parent and children processes, remove .pid and restart
1.9 harris41 509: `killall -9 lonc`;
1.8 harris41 510: unlink($loncfile);
511: $restartflag=1;
512: }
513: print $fh
514: "<h3>Deciding to clean up stale .pid file and restart lonc</h3>";
1.1 albertel 515: }
1.7 harris41 516: }
517: if ($restartflag==1) {
1.1 albertel 518: $errors++;
519: print $fh "<h3>lonc not running, trying to start</h3>";
1.16 harris41 520: system(
1.17 harris41 521: "$perlvar{'lonDaemons'}/lonc 2>>$perlvar{'lonDaemons'}/logs/lonc_errors");
1.1 albertel 522: sleep 120;
523: if (-e $loncfile) {
524: print $fh "Seems like it started ...<p>";
525: my $lfh=IO::File->new("$loncfile");
526: my $loncpid=<$lfh>;
527: chomp($loncpid);
528: sleep 30;
529: if (kill 0 => $loncpid) {
530: print $fh "<h3>lonc at pid $loncpid responding</h3>";
531: } else {
532: $errors++; $errors++;
533: print $fh "<h3>lonc at pid $loncpid not responding</h3>";
534: print $fh "Give it one more try ...<p>";
1.16 harris41 535: system(
1.17 harris41 536: "$perlvar{'lonDaemons'}/lonc 2>>$perlvar{'lonDaemons'}/logs/lonc_errors");
1.1 albertel 537: sleep 120;
538: }
539: } else {
540: print $fh "Seems like that did not work!<p>";
541: $errors++;
542: }
1.3 www 543: if (-e "$perlvar{'lonDaemons'}/logs/lonc.log") {
544: print $fh "<p><pre>";
545: open (DFH,"tail -n100 $perlvar{'lonDaemons'}/logs/lonc.log|");
546: while ($line=<DFH>) {
547: print $fh "$line";
1.4 www 548: if ($line=~/WARNING/) { $notices++; }
549: if ($line=~/CRITICAL/) { $notices++; }
1.3 www 550: };
551: close (DFH);
552: print $fh "</pre>";
553: }
1.1 albertel 554: }
555:
556: $fname="$perlvar{'lonDaemons'}/logs/lonc.log";
557:
558: my ($dev,$ino,$mode,$nlink,
559: $uid,$gid,$rdev,$size,
560: $atime,$mtime,$ctime,
561: $blksize,$blocks)=stat($fname);
562:
563: if ($size>40000) {
564: print $fh "Rotating logs ...<p>";
565: rename("$fname.2","$fname.3");
566: rename("$fname.1","$fname.2");
567: rename("$fname","$fname.1");
568: }
569:
570:
571: &errout($fh);
572: # ---------------------------------------------------------------------- lonnet
573:
574: print $fh '<hr><a name="lonnet"><h2>lonnet</h2><h3>Temp Log</h3><pre>';
575: if (-e "$perlvar{'lonDaemons'}/logs/lonnet.log"){
576: open (DFH,"tail -n50 $perlvar{'lonDaemons'}/logs/lonnet.log|");
577: while ($line=<DFH>) {
578: print $fh "$line";
579: };
580: close (DFH);
581: }
1.11 www 582: print $fh "</pre><h3>Perm Log</h3><pre>";
1.1 albertel 583:
584: if (-e "$perlvar{'lonDaemons'}/logs/lonnet.perm.log") {
585: open(DFH,"tail -n10 $perlvar{'lonDaemons'}/logs/lonnet.perm.log|");
586: while ($line=<DFH>) {
587: print $fh "$line";
588: };
589: close (DFH);
590: } else { print $fh "No perm log\n" }
591:
592: $fname="$perlvar{'lonDaemons'}/logs/lonnet.log";
593:
594: my ($dev,$ino,$mode,$nlink,
595: $uid,$gid,$rdev,$size,
596: $atime,$mtime,$ctime,
597: $blksize,$blocks)=stat($fname);
598:
599: if ($size>40000) {
600: print $fh "Rotating logs ...<p>";
601: rename("$fname.2","$fname.3");
602: rename("$fname.1","$fname.2");
603: rename("$fname","$fname.1");
604: }
605:
606: print $fh "</pre>";
607: &errout($fh);
608: # ----------------------------------------------------------------- Connections
609:
610: print $fh '<hr><a name="connections"><h2>Connections</h2>';
611:
612: print $fh "<table border=2>";
613: foreach $tryserver (keys %hostname) {
614:
615: $answer=reply("pong",$tryserver);
616: if ($answer eq "$tryserver:$perlvar{'lonHostID'}") {
617: $result="<b>ok</b>";
618: } else {
619: $result=$answer;
620: $warnings++;
621: if ($answer eq 'con_lost') { $warnings++; }
622: }
623: print $fh "<tr><td>$tryserver</td><td>$result</td></tr>\n";
624:
625: }
626: print $fh "</table>";
627:
628: &errout($fh);
629: # ------------------------------------------------------------ Delayed messages
630:
631: print $fh '<hr><a name="delayed"><h2>Delayed Messages</h2>';
632:
633: print $fh '<h3>Scanning Permanent Log</h3>';
634:
635: $unsend=0;
636: {
637: my $dfh=IO::File->new("$perlvar{'lonDaemons'}/logs/lonnet.perm.log");
638: while ($line=<$dfh>) {
639: ($time,$sdf,$dserv,$dcmd)=split(/:/,$line);
640: if ($sdf eq 'F') {
641: $local=localtime($time);
642: print "<b>Failed: $time, $dserv, $dcmd</b><br>";
643: $warnings++;
644: }
645: if ($sdf eq 'S') { $unsend--; }
646: if ($sdf eq 'D') { $unsend++; }
647: }
648: }
649: print $fh "Total unsend messages: <b>$unsend</b><p>\n";
650: $warnings=$warnings+5*$unsend;
651:
652: print $fh "<h3>Outgoing Buffer</h3>";
653:
654: open (DFH,"ls -lF $perlvar{'lonSockDir'}/delayed|");
655: while ($line=<DFH>) {
656: print $fh "$line<br>";
657: };
658: close (DFH);
659:
660: # ------------------------------------------------------------------------- End
661: print $fh "<a name=errcount>\n";
662: $totalcount=$notices+4*$warnings+100*$errors;
663: &errout($fh);
664: print $fh "<h1>Total Error Count: $totalcount</h1>";
665: $now=time;
666: $date=localtime($now);
667: print $fh "<hr>$date ($now)</body></html>\n";
668:
669: }
670:
671: rename ("$statusdir/newstatus.html","$statusdir/index.html");
672:
673: if ($totalcount>200) {
674: $emailto="$perlvar{'lonAdmEMail'},$perlvar{'lonSysEMail'}";
675: $subj="LON: $perlvar{'lonHostID'} E:$errors W:$warnings N:$notices";
676: system(
677: "metasend -b -t $emailto -s '$subj' -f $statusdir/index.html -m text/html");
678: }
679: 1;
680:
681:
682:
683:
684:
685:
686:
687:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>