Annotation of loncom/loncron, revision 1.8

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

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