Annotation of loncom/loncron, revision 1.96

1.1       albertel    1: #!/usr/bin/perl
                      2: 
1.47      albertel    3: # Housekeeping program, started by cron, loncontrol and loncron.pl
                      4: #
1.96    ! raeburn     5: # $Id: loncron,v 1.95 2011/11/14 17:27:34 raeburn Exp $
1.47      albertel    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/
1.1       albertel   28: #
1.24      www        29: 
                     30: $|=1;
1.48      albertel   31: use strict;
1.1       albertel   32: 
1.26      harris41   33: use lib '/home/httpd/lib/perl/';
                     34: use LONCAPA::Configuration;
1.96    ! raeburn    35: use LONCAPA::Checksumming;
1.89      raeburn    36: use LONCAPA;
1.72      albertel   37: use Apache::lonnet;
1.79      raeburn    38: use Apache::loncommon;
1.26      harris41   39: 
1.1       albertel   40: use IO::File;
                     41: use IO::Socket;
1.48      albertel   42: use HTML::Entities;
1.49      albertel   43: use Getopt::Long;
1.46      albertel   44: #globals
                     45: use vars qw (%perlvar %simplestatus $errors $warnings $notices $totalcount);
                     46: 
                     47: my $statusdir="/home/httpd/html/lon-status";
                     48: 
1.1       albertel   49: 
                     50: # --------------------------------------------------------- Output error status
                     51: 
1.46      albertel   52: sub log {
                     53:     my $fh=shift;
                     54:     if ($fh) {	print $fh @_  }
                     55: }
                     56: 
1.1       albertel   57: sub errout {
                     58:    my $fh=shift;
1.46      albertel   59:    &log($fh,(<<ENDERROUT));
1.48      albertel   60:      <table border="2" bgcolor="#CCCCCC">
1.1       albertel   61:      <tr><td>Notices</td><td>$notices</td></tr>
                     62:      <tr><td>Warnings</td><td>$warnings</td></tr>
                     63:      <tr><td>Errors</td><td>$errors</td></tr>
1.48      albertel   64:      </table><p><a href="#top">Top</a></p>
1.1       albertel   65: ENDERROUT
                     66: }
                     67: 
1.73      albertel   68: sub rotate_logfile {
                     69:     my ($file,$fh,$description) = @_;
                     70:     my $size=(stat($file))[7];
                     71:     if ($size>40000) {
                     72: 	&log($fh,"<p>Rotating $description ...</p>");
                     73: 	rename("$file.2","$file.3");
                     74: 	rename("$file.1","$file.2");
                     75: 	rename("$file","$file.1");
                     76:     } 
                     77: }
                     78: 
1.42      albertel   79: sub start_daemon {
1.50      albertel   80:     my ($fh,$daemon,$pidfile,$args) = @_;
1.44      albertel   81:     my $progname=$daemon;
1.71      albertel   82:     if ($daemon eq 'lonc') {
1.44      albertel   83: 	$progname='loncnew'; 
                     84:     }
1.51      albertel   85:     my $error_fname="$perlvar{'lonDaemons'}/logs/${daemon}_errors";
1.73      albertel   86:     &rotate_logfile($error_fname,$fh,'error logs');
1.74      albertel   87:     if ($daemon eq 'lonc') {
                     88: 	&clean_sockets($fh);
                     89:     }
1.51      albertel   90:     system("$perlvar{'lonDaemons'}/$progname 2>$perlvar{'lonDaemons'}/logs/${daemon}_errors");
1.60      albertel   91:     sleep 1;
1.42      albertel   92:     if (-e $pidfile) {
1.48      albertel   93: 	&log($fh,"<p>Seems like it started ...</p>");
1.42      albertel   94: 	my $lfh=IO::File->new("$pidfile");
                     95: 	my $daemonpid=<$lfh>;
                     96: 	chomp($daemonpid);
1.62      albertel   97: 	if ($daemonpid =~ /^\d+$/ && kill 0 => $daemonpid) {
1.42      albertel   98: 	    return 1;
                     99: 	} else {
                    100: 	    return 0;
                    101: 	}
                    102:     }
1.48      albertel  103:     &log($fh,"<p>Seems like that did not work!</p>");
1.42      albertel  104:     $errors++;
                    105:     return 0;
                    106: }
                    107: 
                    108: sub checkon_daemon {
1.59      albertel  109:     my ($fh,$daemon,$maxsize,$send,$args)=@_;
1.42      albertel  110: 
1.63      albertel  111:     my $result;
1.48      albertel  112:     &log($fh,'<hr /><a name="'.$daemon.'" /><h2>'.$daemon.'</h2><h3>Log</h3><p style="white-space: pre;"><tt>');
1.57      albertel  113:     printf("%-15s ",$daemon);
1.42      albertel  114:     if (-e "$perlvar{'lonDaemons'}/logs/$daemon.log"){
                    115: 	open (DFH,"tail -n25 $perlvar{'lonDaemons'}/logs/$daemon.log|");
1.46      albertel  116: 	while (my $line=<DFH>) { 
                    117: 	    &log($fh,"$line");
1.42      albertel  118: 	    if ($line=~/INFO/) { $notices++; }
                    119: 	    if ($line=~/WARNING/) { $notices++; }
                    120: 	    if ($line=~/CRITICAL/) { $warnings++; }
                    121: 	};
                    122: 	close (DFH);
                    123:     }
1.48      albertel  124:     &log($fh,"</tt></p>");
1.42      albertel  125:     
                    126:     my $pidfile="$perlvar{'lonDaemons'}/logs/$daemon.pid";
                    127:     
                    128:     my $restartflag=1;
1.46      albertel  129:     my $daemonpid;
1.42      albertel  130:     if (-e $pidfile) {
                    131: 	my $lfh=IO::File->new("$pidfile");
1.46      albertel  132: 	$daemonpid=<$lfh>;
1.42      albertel  133: 	chomp($daemonpid);
1.62      albertel  134: 	if ($daemonpid =~ /^\d+$/ && kill 0 => $daemonpid) {
1.46      albertel  135: 	    &log($fh,"<h3>$daemon at pid $daemonpid responding");
1.59      albertel  136: 	    if ($send) { &log($fh,", sending $send"); }
1.46      albertel  137: 	    &log($fh,"</h3>");
1.59      albertel  138: 	    if ($send eq 'USR1') { kill USR1 => $daemonpid; }
                    139: 	    if ($send eq 'USR2') { kill USR2 => $daemonpid; }
1.42      albertel  140: 	    $restartflag=0;
1.59      albertel  141: 	    if ($send eq 'USR2') {
1.63      albertel  142: 		$result = 'reloaded';
1.59      albertel  143: 		print "reloaded\n";
                    144: 	    } else {
1.63      albertel  145: 		$result = 'running';
1.59      albertel  146: 		print "running\n";
                    147: 	    }
1.42      albertel  148: 	} else {
                    149: 	    $errors++;
1.46      albertel  150: 	    &log($fh,"<h3>$daemon at pid $daemonpid not responding</h3>");
1.42      albertel  151: 	    $restartflag=1;
1.46      albertel  152: 	    &log($fh,"<h3>Decided to clean up stale .pid file and restart $daemon</h3>");
1.42      albertel  153: 	}
                    154:     }
                    155:     if ($restartflag==1) {
                    156: 	$simplestatus{$daemon}='off';
                    157: 	$errors++;
1.57      albertel  158: 	my $kadaemon=$daemon;
                    159: 	if ($kadaemon eq 'lonmemcached') { $kadaemon='memcached'; }
1.46      albertel  160: 	&log($fh,'<br><font color="red">Killall '.$daemon.': '.
1.57      albertel  161: 	    `killall $kadaemon 2>&1`.' - ');
1.60      albertel  162: 	sleep 1;
1.46      albertel  163: 	&log($fh,unlink($pidfile).' - '.
1.57      albertel  164: 	    `killall -9 $kadaemon 2>&1`.
1.46      albertel  165: 	    '</font><br>');
                    166: 	&log($fh,"<h3>$daemon not running, trying to start</h3>");
1.42      albertel  167: 	
1.50      albertel  168: 	if (&start_daemon($fh,$daemon,$pidfile,$args)) {
1.46      albertel  169: 	    &log($fh,"<h3>$daemon at pid $daemonpid responding</h3>");
1.42      albertel  170: 	    $simplestatus{$daemon}='restarted';
1.63      albertel  171: 	    $result = 'started';
1.42      albertel  172: 	    print "started\n";
                    173: 	} else {
                    174: 	    $errors++;
1.46      albertel  175: 	    &log($fh,"<h3>$daemon at pid $daemonpid not responding</h3>");
1.48      albertel  176: 	    &log($fh,"<p>Give it one more try ...</p>");
1.42      albertel  177: 	    print " ";
1.50      albertel  178: 	    if (&start_daemon($fh,$daemon,$pidfile,$args)) {
1.46      albertel  179: 		&log($fh,"<h3>$daemon at pid $daemonpid responding</h3>");
1.42      albertel  180: 		$simplestatus{$daemon}='restarted';
1.63      albertel  181: 		$result = 'started';
1.42      albertel  182: 		print "started\n";
                    183: 	    } else {
1.63      albertel  184: 		$result = 'failed';
1.42      albertel  185: 		print " failed\n";
                    186: 		$simplestatus{$daemon}='failed';
                    187: 		$errors++; $errors++;
1.46      albertel  188: 		&log($fh,"<h3>$daemon at pid $daemonpid not responding</h3>");
1.48      albertel  189: 		&log($fh,"<p>Unable to start $daemon</p>");
1.42      albertel  190: 	    }
                    191: 	}
                    192: 
                    193: 	if (-e "$perlvar{'lonDaemons'}/logs/$daemon.log"){
1.46      albertel  194: 	    &log($fh,"<p><pre>");
1.42      albertel  195: 	    open (DFH,"tail -n100 $perlvar{'lonDaemons'}/logs/$daemon.log|");
1.46      albertel  196: 	    while (my $line=<DFH>) { 
                    197: 		&log($fh,"$line");
1.42      albertel  198: 		if ($line=~/WARNING/) { $notices++; }
                    199: 		if ($line=~/CRITICAL/) { $notices++; }
                    200: 	    };
                    201: 	    close (DFH);
1.48      albertel  202: 	    &log($fh,"</pre></p>");
1.42      albertel  203: 	}
                    204:     }
                    205:     
1.46      albertel  206:     my $fname="$perlvar{'lonDaemons'}/logs/$daemon.log";
1.73      albertel  207:     &rotate_logfile($fname,$fh,'logs');
1.42      albertel  208: 
                    209:     &errout($fh);
1.63      albertel  210:     return $result;
1.42      albertel  211: }
1.1       albertel  212: 
1.46      albertel  213: # --------------------------------------------------------------------- Machine
                    214: sub log_machine_info {
                    215:     my ($fh)=@_;
1.48      albertel  216:     &log($fh,'<hr /><a name="machine" /><h2>Machine Information</h2>');
1.46      albertel  217:     &log($fh,"<h3>loadavg</h3>");
                    218: 	
                    219:     open (LOADAVGH,"/proc/loadavg");
                    220:     my $loadavg=<LOADAVGH>;
                    221:     close (LOADAVGH);
                    222:     
                    223:     &log($fh,"<tt>$loadavg</tt>");
                    224:     
                    225:     my @parts=split(/\s+/,$loadavg);
                    226:     if ($parts[1]>4.0) {
                    227: 	$errors++;
                    228:     } elsif ($parts[1]>2.0) {
                    229: 	$warnings++;
                    230:     } elsif ($parts[1]>1.0) {
                    231: 	$notices++;
                    232:     }
1.13      harris41  233: 
1.46      albertel  234:     &log($fh,"<h3>df</h3>");
                    235:     &log($fh,"<pre>");
1.14      harris41  236: 
1.46      albertel  237:     open (DFH,"df|");
                    238:     while (my $line=<DFH>) { 
1.48      albertel  239: 	&log($fh,&encode_entities($line,'<>&"')); 
1.46      albertel  240: 	@parts=split(/\s+/,$line);
                    241: 	my $usage=$parts[4];
                    242: 	$usage=~s/\W//g;
                    243: 	if ($usage>90) { 
                    244: 	    $warnings++;
                    245: 	    $notices++; 
                    246: 	} elsif ($usage>80) {
                    247: 	    $warnings++;
                    248: 	} elsif ($usage>60) {
                    249: 	    $notices++;
1.31      albertel  250: 	}
1.46      albertel  251: 	if ($usage>95) { $warnings++; $warnings++; $simplestatus{'diskfull'}++; }
1.1       albertel  252:     }
1.46      albertel  253:     close (DFH);
                    254:     &log($fh,"</pre>");
1.1       albertel  255: 
                    256: 
1.46      albertel  257:     &log($fh,"<h3>ps</h3>");
                    258:     &log($fh,"<pre>");
                    259:     my $psproc=0;
1.1       albertel  260: 
1.53      albertel  261:     open (PSH,"ps aux --cols 140 |");
1.46      albertel  262:     while (my $line=<PSH>) { 
1.48      albertel  263: 	&log($fh,&encode_entities($line,'<>&"')); 
1.46      albertel  264: 	$psproc++;
                    265:     }
                    266:     close (PSH);
                    267:     &log($fh,"</pre>");
1.1       albertel  268: 
1.46      albertel  269:     if ($psproc>200) { $notices++; }
                    270:     if ($psproc>250) { $notices++; }
1.1       albertel  271: 
1.61      albertel  272:     &log($fh,"<h3>distprobe</h3>");
                    273:     &log($fh,"<pre>");
1.96    ! raeburn   274:     &get_distro($perlvar{'lonDaemons'},$fh);
1.61      albertel  275:     &log($fh,"</pre>");
                    276: 
1.46      albertel  277:     &errout($fh);
                    278: }
1.1       albertel  279: 
1.46      albertel  280: sub start_logging {
1.43      albertel  281:     my $fh=IO::File->new(">$statusdir/newstatus.html");
                    282:     my %simplestatus=();
1.46      albertel  283:     my $now=time;
                    284:     my $date=localtime($now);
1.43      albertel  285:     
1.46      albertel  286: 
                    287:     &log($fh,(<<ENDHEADERS));
1.1       albertel  288: <html>
                    289: <head>
                    290: <title>LON Status Report $perlvar{'lonHostID'}</title>
                    291: </head>
1.3       www       292: <body bgcolor="#AAAAAA">
1.48      albertel  293: <a name="top" />
1.1       albertel  294: <h1>LON Status Report $perlvar{'lonHostID'}</h1>
                    295: <h2>$date ($now)</h2>
                    296: <ol>
1.48      albertel  297: <li><a href="#configuration">Configuration</a></li>
                    298: <li><a href="#machine">Machine Information</a></li>
                    299: <li><a href="#tmp">Temporary Files</a></li>
                    300: <li><a href="#tokens">Session Tokens</a></li>
                    301: <li><a href="#httpd">httpd</a></li>
                    302: <li><a href="#lonsql">lonsql</a></li>
                    303: <li><a href="#lond">lond</a></li>
                    304: <li><a href="#lonc">lonc</a></li>
                    305: <li><a href="#lonnet">lonnet</a></li>
                    306: <li><a href="#connections">Connections</a></li>
                    307: <li><a href="#delayed">Delayed Messages</a></li>
                    308: <li><a href="#errcount">Error Count</a></li>
1.1       albertel  309: </ol>
1.48      albertel  310: <hr />
                    311: <a name="configuration" />
1.1       albertel  312: <h2>Configuration</h2>
                    313: <h3>PerlVars</h3>
1.48      albertel  314: <table border="2">
1.1       albertel  315: ENDHEADERS
                    316: 
1.46      albertel  317:     foreach my $varname (sort(keys(%perlvar))) {
1.48      albertel  318: 	&log($fh,"<tr><td>$varname</td><td>".
                    319: 	     &encode_entities($perlvar{$varname},'<>&"')."</td></tr>\n");
1.43      albertel  320:     }
1.48      albertel  321:     &log($fh,"</table><h3>Hosts</h3><table border='2'>");
1.72      albertel  322:     my %hostname = &Apache::lonnet::all_hostnames();
                    323:     foreach my $id (sort(keys(%hostname))) {
                    324: 	my $role = (&Apache::lonnet::is_library($id) ? 'library'
                    325: 		                                     : 'access');
1.46      albertel  326: 	&log($fh,
1.72      albertel  327: 	    "<tr><td>$id</td><td>".&Apache::lonnet::host_domain($id).
                    328: 	    "</td><td>".$role.
                    329: 	    "</td><td>".&Apache::lonnet::hostname($id)."</td></tr>\n");
                    330:     }
                    331:     &log($fh,"</table><h3>Spare Hosts</h3><ul>");
                    332:     foreach my $type (sort(keys(%Apache::lonnet::spareid))) {
                    333: 	&log($fh,"<li>$type\n<ol>");
                    334: 	foreach my $id (@{ $Apache::lonnet::spareid{$type} }) {
                    335: 	    &log($fh,"<li>$id</li>\n");
                    336: 	}
                    337: 	&log($fh,"</ol>\n</li>\n");
1.43      albertel  338:     }
1.72      albertel  339:     &log($fh,"</ul>\n");
1.46      albertel  340:     return $fh;
                    341: }
1.11      www       342: 
                    343: # --------------------------------------------------------------- clean out tmp
1.46      albertel  344: sub clean_tmp {
                    345:     my ($fh)=@_;
1.48      albertel  346:     &log($fh,'<hr /><a name="tmp" /><h2>Temporary Files</h2>');
1.82      raeburn   347:     my ($cleaned,$old,$removed) = (0,0,0);
                    348:     my %errors = (
                    349:                      dir       => [],
                    350:                      file      => [],
                    351:                      failopen  => [],
                    352:                  );
                    353:     my %error_titles = (
                    354:                          dir       => 'failed to remove empty directory:',
                    355:                          file      => 'failed to unlike stale file',
                    356:                          failopen  => 'failed to open file or directory'
                    357:                        );
                    358:     ($cleaned,$old,$removed) = &recursive_clean_tmp('',$cleaned,$old,$removed,\%errors);
                    359:     &log($fh,"Cleaned up: ".$cleaned." files; removed: $removed empty directories; (found: $old old checkout tokens)");
                    360:     foreach my $key (sort(keys(%errors))) {
                    361:         if (ref($errors{$key}) eq 'ARRAY') {
                    362:             if (@{$errors{$key}} > 0) {
                    363:                 &log($fh,"Error during cleanup ($error_titles{$key}):<ul><li>".
                    364:                      join('</li><li><tt>',@{$errors{$key}}).'</tt></li></ul><br />');
                    365:             }
                    366:         }
                    367:     }
                    368: }
                    369: 
                    370: sub recursive_clean_tmp {
                    371:     my ($subdir,$cleaned,$old,$removed,$errors) = @_;
                    372:     my $base = "$perlvar{'lonDaemons'}/tmp";
                    373:     my $path = $base;
                    374:     next if ($subdir =~ m{\.\./});
                    375:     next unless (ref($errors) eq 'HASH');
                    376:     unless ($subdir eq '') {
                    377:         $path .= '/'.$subdir;
                    378:     }
                    379:     if (opendir(my $dh,"$path")) {
                    380:         while (my $file = readdir($dh)) {
                    381:             next if ($file =~ /^\.\.?$/);
                    382:             my $fname = "$path/$file";
                    383:             if (-d $fname) {
                    384:                 my $innerdir;
                    385:                 if ($subdir eq '') {
                    386:                     $innerdir = $file;
                    387:                 } else {
                    388:                     $innerdir = $subdir.'/'.$file;
                    389:                 }
                    390:                 ($cleaned,$old,$removed) = 
                    391:                      &recursive_clean_tmp($innerdir,$cleaned,$old,$removed,$errors);
                    392:                 my @doms = &Apache::lonnet::current_machine_domains();
                    393:                 
                    394:                 if (open(my $dirhandle,$fname)) {
                    395:                     unless (($innerdir eq 'helprequests') ||
                    396:                             (($innerdir =~ /^addcourse/) && ($innerdir !~ m{/\d+$}))) {
                    397:                         my @contents = grep {!/^\.\.?$/} readdir($dirhandle);
                    398:                                       join('&&',@contents)."\n";    
                    399:                         if (scalar(grep {!/^\.\.?$/} readdir($dirhandle)) == 0) {
                    400:                             closedir($dirhandle);
                    401:                             if ($fname =~ m{^\Q$perlvar{'lonDaemons'}\E/tmp/}) {
                    402:                                 if (rmdir($fname)) {
                    403:                                     $removed ++;
                    404:                                 } elsif (ref($errors->{dir}) eq 'ARRAY') {
                    405:                                     push(@{$errors->{dir}},$fname);
                    406:                                 }
                    407:                             }
                    408:                         }
                    409:                     } else {
                    410:                         closedir($dirhandle);
                    411:                     }
                    412:                 }
                    413:             } else {
                    414:                 my ($dev,$ino,$mode,$nlink,
                    415:                     $uid,$gid,$rdev,$size,
                    416:                     $atime,$mtime,$ctime,
                    417:                     $blksize,$blocks)=stat($fname);
                    418:                 my $now=time;
                    419:                 my $since=$now-$mtime;
                    420:                 if ($since>$perlvar{'lonExpire'}) {
                    421:                     if ($subdir eq '') {
                    422:                         my $line='';
                    423:                         if ($fname =~ /\.db$/) {
                    424:                             if (unlink($fname)) {
                    425:                                 $cleaned++;
                    426:                             } elsif (ref($errors->{file}) eq 'ARRAY') {
                    427:                                 push(@{$errors->{file}},$fname);
                    428:                             }
                    429:                         } elsif (open(PROBE,$fname)) {
                    430:                             my $line='';
                    431:                             $line=<PROBE>;
                    432:                             close(PROBE);
                    433:                             if ($line=~/^CHECKOUTTOKEN\&/) {
                    434:                                 if ($since>365*$perlvar{'lonExpire'}) {
                    435:                                     if (unlink($fname)) {
                    436:                                         $cleaned++; 
                    437:                                     } elsif (ref($errors->{file}) eq 'ARRAY') {
                    438:                                         push(@{$errors->{file}},$fname);
                    439:                                     }
                    440:                                 } else {
                    441:                                     $old++;
                    442:                                 }
                    443:                             } else {
                    444:                                 if (unlink($fname)) {
                    445:                                     $cleaned++;
                    446:                                 } elsif (ref($errors->{file}) eq 'ARRAY') {
                    447:                                     push(@{$errors->{file}},$fname);
                    448:                                 }
                    449:                             }
                    450:                         } elsif (ref($errors->{failopen}) eq 'ARRAY') {
                    451:                             push(@{$errors->{failopen}},$fname); 
                    452:                         }
                    453:                     } else {
                    454:                         if (unlink($fname)) {
                    455:                             $cleaned++;
                    456:                         } elsif (ref($errors->{file}) eq 'ARRAY') {
                    457:                             push(@{$errors->{file}},$fname);
                    458:                         }
                    459:                     }
                    460:                 }
                    461:             }
                    462:         }
                    463:         closedir($dh);
                    464:     } elsif (ref($errors->{failopen}) eq 'ARRAY') {
                    465:         push(@{$errors->{failopen}},$path);
1.43      albertel  466:     }
1.82      raeburn   467:     return ($cleaned,$old,$removed);
1.46      albertel  468: }
1.11      www       469: 
                    470: # ------------------------------------------------------------ clean out lonIDs
1.46      albertel  471: sub clean_lonIDs {
                    472:     my ($fh)=@_;
1.48      albertel  473:     &log($fh,'<hr /><a name="tokens" /><h2>Session Tokens</h2>');
1.46      albertel  474:     my $cleaned=0;
                    475:     my $active=0;
                    476:     while (my $fname=<$perlvar{'lonIDsDir'}/*>) {
1.43      albertel  477: 	my ($dev,$ino,$mode,$nlink,
                    478: 	    $uid,$gid,$rdev,$size,
                    479: 	    $atime,$mtime,$ctime,
                    480: 	    $blksize,$blocks)=stat($fname);
1.46      albertel  481: 	my $now=time;
                    482: 	my $since=$now-$mtime;
1.43      albertel  483: 	if ($since>$perlvar{'lonExpire'}) {
                    484: 	    $cleaned++;
1.46      albertel  485: 	    &log($fh,"Unlinking $fname<br>");
1.43      albertel  486: 	    unlink("$fname");
                    487: 	} else {
                    488: 	    $active++;
                    489: 	}
1.46      albertel  490:     }
1.48      albertel  491:     &log($fh,"<p>Cleaned up ".$cleaned." stale session token(s).</p>");
1.46      albertel  492:     &log($fh,"<h3>$active open session(s)</h3>");
                    493: }
1.43      albertel  494: 
1.74      albertel  495: # ----------------------------------------------------------- clean out sockets
                    496: sub clean_sockets {
                    497:     my ($fh)=@_;
                    498:     my $cleaned=0;
                    499:     opendir(SOCKETS,$perlvar{'lonSockDir'});
                    500:     while (my $fname=readdir(SOCKETS)) {
                    501: 	next if (-d $fname 
1.80      www       502: 		 || $fname=~/(mysqlsock|maximasock|rsock|\Q$perlvar{'lonSockDir'}\E)/);
1.74      albertel  503: 	$cleaned++;
                    504: 	&log($fh,"Unlinking $fname<br />");
                    505: 	unlink("/home/httpd/sockets/$fname");
                    506:     }
                    507:     &log($fh,"<p>Cleaned up ".$cleaned." stale sockets.</p>");
                    508: }
                    509: 
1.11      www       510: 
1.1       albertel  511: # ----------------------------------------------------------------------- httpd
1.46      albertel  512: sub check_httpd_logs {
                    513:     my ($fh)=@_;
1.94      raeburn   514:     if (open(PIPE,"./lchttpdlogs|")) {
1.93      raeburn   515:         while (my $line=<PIPE>) {
                    516:             &log($fh,$line);
                    517:             if ($line=~/\[error\]/) { $notices++; }
                    518:         }
                    519:         close(PIPE);
1.46      albertel  520:     }
1.43      albertel  521:     &errout($fh);
1.46      albertel  522: }
1.1       albertel  523: 
                    524: # ---------------------------------------------------------------------- lonnet
                    525: 
1.48      albertel  526: sub rotate_lonnet_logs {
1.46      albertel  527:     my ($fh)=@_;
1.48      albertel  528:     &log($fh,'<hr /><a name="lonnet" /><h2>lonnet</h2><h3>Temp Log</h3><pre>');
1.43      albertel  529:     print "checking logs\n";
                    530:     if (-e "$perlvar{'lonDaemons'}/logs/lonnet.log"){
                    531: 	open (DFH,"tail -n50 $perlvar{'lonDaemons'}/logs/lonnet.log|");
1.46      albertel  532: 	while (my $line=<DFH>) { 
1.48      albertel  533: 	    &log($fh,&encode_entities($line,'<>&"'));
1.46      albertel  534: 	}
1.43      albertel  535: 	close (DFH);
                    536:     }
1.46      albertel  537:     &log($fh,"</pre><h3>Perm Log</h3><pre>");
1.43      albertel  538:     
                    539:     if (-e "$perlvar{'lonDaemons'}/logs/lonnet.perm.log") {
                    540: 	open(DFH,"tail -n10 $perlvar{'lonDaemons'}/logs/lonnet.perm.log|");
1.46      albertel  541: 	while (my $line=<DFH>) { 
1.48      albertel  542: 	    &log($fh,&encode_entities($line,'<>&"'));
1.46      albertel  543: 	}
1.43      albertel  544: 	close (DFH);
1.46      albertel  545:     } else { &log($fh,"No perm log\n") }
1.43      albertel  546: 
1.46      albertel  547:     my $fname="$perlvar{'lonDaemons'}/logs/lonnet.log";
1.73      albertel  548:     &rotate_logfile($fname,$fh,'lonnet log');
1.1       albertel  549: 
1.46      albertel  550:     &log($fh,"</pre>");
1.43      albertel  551:     &errout($fh);
1.46      albertel  552: }
                    553: 
1.73      albertel  554: sub rotate_other_logs {
                    555:     my ($fh) = @_;
1.83      raeburn   556:     my %logs = (
                    557:                   autoenroll          => 'Auto Enroll log',
                    558:                   autocreate          => 'Create Course log',
                    559:                   searchcat           => 'Search Cataloguing log',
                    560:                   autoupdate          => 'Auto Update log',
                    561:                   refreshcourseids_db => 'Refresh CourseIDs db log',
                    562:                );
                    563:     foreach my $item (keys(%logs)) {
                    564:         my $fname=$perlvar{'lonDaemons'}.'/logs/'.$item.'.log';
                    565:         &rotate_logfile($fname,$fh,$logs{$item});
                    566:     }
1.73      albertel  567: }
                    568: 
1.43      albertel  569: # ----------------------------------------------------------------- Connections
1.46      albertel  570: sub test_connections {
1.72      albertel  571:     my ($fh)=@_;
1.48      albertel  572:     &log($fh,'<hr /><a name="connections" /><h2>Connections</h2>');
1.43      albertel  573:     print "testing connections\n";
1.48      albertel  574:     &log($fh,"<table border='2'>");
1.49      albertel  575:     my ($good,$bad)=(0,0);
1.72      albertel  576:     my %hostname = &Apache::lonnet::all_hostnames();
                    577:     foreach my $tryserver (sort(keys(%hostname))) {
1.43      albertel  578: 	print(".");
1.46      albertel  579: 	my $result;
1.72      albertel  580: 	my $answer=&Apache::lonnet::reply("ping",$tryserver);
1.43      albertel  581: 	if ($answer eq "$tryserver:$perlvar{'lonHostID'}") {
                    582: 	    $result="<b>ok</b>";
1.49      albertel  583: 	    $good++;
1.43      albertel  584: 	} else {
                    585: 	    $result=$answer;
                    586: 	    $warnings++;
1.49      albertel  587: 	    if ($answer eq 'con_lost') {
                    588: 		$bad++;
                    589: 		$warnings++;
1.50      albertel  590: 	    } else {
                    591: 		$good++; #self connection
1.49      albertel  592: 	    }
1.43      albertel  593: 	}
                    594: 	if ($answer =~ /con_lost/) { print(" $tryserver down\n"); }
1.46      albertel  595: 	&log($fh,"<tr><td>$tryserver</td><td>$result</td></tr>\n");
1.1       albertel  596:     }
1.46      albertel  597:     &log($fh,"</table>");
1.49      albertel  598:     print "\n$good good, $bad bad connections\n";
1.43      albertel  599:     &errout($fh);
1.46      albertel  600: }
                    601: 
                    602: 
1.1       albertel  603: # ------------------------------------------------------------ Delayed messages
1.46      albertel  604: sub check_delayed_msg {
1.72      albertel  605:     my ($fh)=@_;
1.48      albertel  606:     &log($fh,'<hr /><a name="delayed" /><h2>Delayed Messages</h2>');
1.43      albertel  607:     print "checking buffers\n";
1.46      albertel  608:     
                    609:     &log($fh,'<h3>Scanning Permanent Log</h3>');
1.1       albertel  610: 
1.46      albertel  611:     my $unsend=0;
1.1       albertel  612: 
1.46      albertel  613:     my $dfh=IO::File->new("$perlvar{'lonDaemons'}/logs/lonnet.perm.log");
                    614:     while (my $line=<$dfh>) {
                    615: 	my ($time,$sdf,$dserv,$dcmd)=split(/:/,$line);
                    616: 	if ($sdf eq 'F') { 
                    617: 	    my $local=localtime($time);
                    618: 	    &log($fh,"<b>Failed: $time, $dserv, $dcmd</b><br>");
                    619: 	    $warnings++;
1.43      albertel  620: 	}
1.46      albertel  621: 	if ($sdf eq 'S') { $unsend--; }
                    622: 	if ($sdf eq 'D') { $unsend++; }
1.1       albertel  623:     }
1.46      albertel  624: 
1.48      albertel  625:     &log($fh,"<p>Total unsend messages: <b>$unsend</b></p>\n");
1.95      raeburn   626:     if ($unsend > 0) {
                    627:         $warnings=$warnings+5*$unsend;
                    628:     }
1.1       albertel  629: 
1.43      albertel  630:     if ($unsend) { $simplestatus{'unsend'}=$unsend; }
1.48      albertel  631:     &log($fh,"<h3>Outgoing Buffer</h3>\n<pre>");
1.68      www       632: # list directory with delayed messages and remember offline servers
                    633:     my %servers=();
1.43      albertel  634:     open (DFH,"ls -lF $perlvar{'lonSockDir'}/delayed|");
1.68      www       635:     while (my $line=<DFH>) {
                    636:         my ($server)=($line=~/\.(\w+)$/);
                    637:         if ($server) { $servers{$server}=1; }
1.48      albertel  638: 	&log($fh,&encode_entities($line,'<>&"'));
1.46      albertel  639:     }
1.48      albertel  640:     &log($fh,"</pre>\n");
1.43      albertel  641:     close (DFH);
1.95      raeburn   642:     my %hostname = &Apache::lonnet::all_hostnames();
                    643:     my $numhosts = scalar(keys(%hostname));
1.68      www       644: # pong to all servers that have delayed messages
                    645: # this will trigger a reverse connection, which should flush the buffers
1.95      raeburn   646:     foreach my $tryserver (sort(keys(%servers))) {
                    647:         if ($hostname{$tryserver} || !$numhosts) {
                    648:             my $answer;
                    649:             eval {
                    650:                 local $SIG{ ALRM } = sub { die "TIMEOUT" };
                    651:                 alarm(20);
                    652:                 $answer = &Apache::lonnet::reply("pong",$tryserver);
                    653:                 alarm(0);
                    654:             };
                    655:             if ($@ && $@ =~ m/TIMEOUT/) {
                    656:                 &log($fh,"Attempted pong to $tryserver timed out<br />");
                    657:                 print "time out while contacting: $tryserver for pong\n";
                    658:             } else {
                    659:                 &log($fh,"Pong to $tryserver: $answer<br />");
                    660:             }
1.91      raeburn   661:         } else {
1.95      raeburn   662:             &log($fh,"$tryserver has delayed messages, but is not part of the cluster -- skipping 'Pong'.<br />");
1.91      raeburn   663:         }
1.68      www       664:     }
1.46      albertel  665: }
1.1       albertel  666: 
1.46      albertel  667: sub finish_logging {
                    668:     my ($fh)=@_;
1.48      albertel  669:     &log($fh,"<a name='errcount' />\n");
1.43      albertel  670:     $totalcount=$notices+4*$warnings+100*$errors;
                    671:     &errout($fh);
1.46      albertel  672:     &log($fh,"<h1>Total Error Count: $totalcount</h1>");
                    673:     my $now=time;
                    674:     my $date=localtime($now);
1.48      albertel  675:     &log($fh,"<hr />$date ($now)</body></html>\n");
1.43      albertel  676:     print "lon-status webpage updated\n";
                    677:     $fh->close();
1.46      albertel  678: 
                    679:     if ($errors) { $simplestatus{'errors'}=$errors; }
                    680:     if ($warnings) { $simplestatus{'warnings'}=$warnings; }
                    681:     if ($notices) { $simplestatus{'notices'}=$notices; }
                    682:     $simplestatus{'time'}=time;
1.1       albertel  683: }
                    684: 
1.46      albertel  685: sub log_simplestatus {
1.73      albertel  686:     rename("$statusdir/newstatus.html","$statusdir/index.html");
1.46      albertel  687:     
1.43      albertel  688:     my $sfh=IO::File->new(">$statusdir/loncron_simple.txt");
                    689:     foreach (keys %simplestatus) {
                    690: 	print $sfh $_.'='.$simplestatus{$_}.'&';
                    691:     }
                    692:     print $sfh "\n";
                    693:     $sfh->close();
1.41      www       694: }
1.46      albertel  695: 
1.84      raeburn   696: sub write_loncaparevs {
1.90      raeburn   697:     print "Retrieving LON-CAPA version information\n";
1.84      raeburn   698:     if (open(my $fh,">$perlvar{'lonTabDir'}/loncaparevs.tab")) {
                    699:         my %hostname = &Apache::lonnet::all_hostnames();
                    700:         foreach my $id (sort(keys(%hostname))) {
                    701:             if ($id ne '') {
1.90      raeburn   702:                 my $loncaparev;
                    703:                 eval {
                    704:                     local $SIG{ ALRM } = sub { die "TIMEOUT" };
                    705:                     alarm(10);
                    706:                     $loncaparev =
                    707:                         &Apache::lonnet::get_server_loncaparev('',$id,1,'loncron');
                    708:                     alarm(0);
                    709:                 };
                    710:                 if ($@ && $@ =~ m/TIMEOUT/) {
                    711:                     print "time out while contacting lonHost: $id for version\n";   
                    712:                 }
1.86      raeburn   713:                 if ($loncaparev =~ /^[\w.\-]+$/) {
1.84      raeburn   714:                     print $fh $id.':'.$loncaparev."\n";
                    715:                 }
                    716:             }
                    717:         }
                    718:         close($fh);
                    719:     }
                    720:     return;
                    721: }
                    722: 
1.85      raeburn   723: sub write_serverhomeIDs {
1.90      raeburn   724:     print "Retrieving LON-CAPA lonHostID information\n";
1.85      raeburn   725:     if (open(my $fh,">$perlvar{'lonTabDir'}/serverhomeIDs.tab")) {
                    726:         my %name_to_host = &Apache::lonnet::all_names();
                    727:         foreach my $name (sort(keys(%name_to_host))) {
                    728:             if ($name ne '') {
                    729:                 if (ref($name_to_host{$name}) eq 'ARRAY') {
1.90      raeburn   730:                     my $serverhomeID;
                    731:                     eval {
                    732:                         local $SIG{ ALRM } = sub { die "TIMEOUT" };
                    733:                         alarm(10);
                    734:                         $serverhomeID = 
                    735:                             &Apache::lonnet::get_server_homeID($name,1,'loncron');
                    736:                         alarm(0);
                    737:                     };
                    738:                     if ($@ && $@ =~ m/TIMEOUT/) {
                    739:                         print "Time out while contacting server: $name\n"; 
                    740:                     }
1.85      raeburn   741:                     if ($serverhomeID ne '') {
                    742:                         print $fh $name.':'.$serverhomeID."\n";
                    743:                     } else {
                    744:                         print $fh $name.':'.$name_to_host{$name}->[0]."\n";
                    745:                     }
                    746:                 }
                    747:             }
                    748:         }
                    749:         close($fh);
                    750:     }
                    751:     return;
                    752: }
                    753: 
1.96    ! raeburn   754: sub write_checksums {
        !           755:     my ($perlvar) = @_;
        !           756:     return unless (ref($perlvar) eq 'HASH');
        !           757:     my $distro = &get_distro($perlvar->{'lonDaemons'});
        !           758:     if ($distro) {
        !           759:         print "Retrieving file version and checksumming.\n";
        !           760:         my ($chksumsref,$versionsref) =
        !           761:             &LONCAPA::Checksumming::get_checksums($distro,$perlvar->{'lonDaemons'},
        !           762:                                                   $perlvar->{'lonLib'},
        !           763:                                                   $perlvar->{'lonIncludes'},
        !           764:                                                   $perlvar->{'lonTabDir'});
        !           765:         if (ref($chksumsref) eq 'HASH') {
        !           766:             $numchksums = scalar(keys(%{$chksumsref}));
        !           767:         }
        !           768:         print "File version retrieved and checksumming completed for $numchksums files.\n";
        !           769:     } else {
        !           770:         print "File version retrieval and checksumming skipped - could not determine Linux distro.\n"; 
        !           771:     }
        !           772:     return'
        !           773: }
        !           774: 
1.46      albertel  775: sub send_mail {
1.43      albertel  776:     print "sending mail\n";
1.79      raeburn   777:     my $defdom = $perlvar{'lonDefDomain'};
                    778:     my $origmail = $perlvar{'lonAdmEMail'};
1.78      raeburn   779:     my $emailto = &Apache::loncommon::build_recipient_list(undef,
                    780:                                    'lonstatusmail',$defdom,$origmail);
1.54      www       781:     if ($totalcount>2500) {
1.43      albertel  782: 	$emailto.=",$perlvar{'lonSysEMail'}";
                    783:     }
1.46      albertel  784:     my $subj="LON: $perlvar{'lonHostID'} E:$errors W:$warnings N:$notices"; 
1.52      albertel  785: 
1.58      albertel  786:     my $result=system("metasend -b -S 4000000 -t $emailto -s '$subj' -f $statusdir/index.html -m text/html >& /dev/null");
1.52      albertel  787:     if ($result != 0) {
                    788: 	$result=system("mail -s '$subj' $emailto < $statusdir/index.html");
                    789:     }
1.1       albertel  790: }
1.46      albertel  791: 
1.96    ! raeburn   792: sub get_distro {
        !           793:     my ($dir,$fh) = @_;
        !           794:     my $distro;
        !           795:     if (open(my $disth,"$dir/distprobe |")) {
        !           796:         while (my $line=<$disth>) {
        !           797:             if ($fh) {
        !           798:                 &log($fh,&encode_entities($line,'<>&"'));
        !           799:             }
        !           800:             $distro .= $line;
        !           801:         }
        !           802:         close($disth);
        !           803:     }
        !           804:     return $distro;
        !           805: }
        !           806: 
1.49      albertel  807: sub usage {
                    808:     print(<<USAGE);
                    809: loncron - housekeeping program that checks up on various parts of Lon-CAPA
                    810: 
                    811: Options:
1.71      albertel  812:    --help     Display 
1.49      albertel  813:    --noemail  Do not send the status email
                    814:    --justcheckconnections  Only check the current status of the lonc/d
                    815:                                 connections, do not send emails do not
                    816:                                 check if the daemons are running, do not
                    817:                                 generate lon-status
                    818:    --justcheckdaemons      Only check that all of the Lon-CAPA daemons are
                    819:                                 running, do not send emails do not
                    820:                                 check the lonc/d connections, do not
                    821:                                 generate lon-status
1.59      albertel  822:    --justreload            Only tell the daemons to reload the config files,
                    823: 				do not send emails do not
                    824:                                 check if the daemons are running, do not
                    825:                                 generate lon-status
1.49      albertel  826:                            
                    827: USAGE
                    828: }
                    829: 
1.46      albertel  830: # ================================================================ Main Program
                    831: sub main () {
1.71      albertel  832:     my ($help,$justcheckdaemons,$noemail,$justcheckconnections,
1.59      albertel  833: 	$justreload);
1.49      albertel  834:     &GetOptions("help"                 => \$help,
                    835: 		"justcheckdaemons"     => \$justcheckdaemons,
                    836: 		"noemail"              => \$noemail,
1.59      albertel  837: 		"justcheckconnections" => \$justcheckconnections,
                    838: 		"justreload"           => \$justreload
1.49      albertel  839: 		);
                    840:     if ($help) { &usage(); return; }
1.46      albertel  841: # --------------------------------- Read loncapa_apache.conf and loncapa.conf
                    842:     my $perlvarref=LONCAPA::Configuration::read_conf('loncapa.conf');
                    843:     %perlvar=%{$perlvarref};
                    844:     undef $perlvarref;
                    845:     delete $perlvar{'lonReceipt'}; # remove since sensitive and not needed
                    846:     delete $perlvar{'lonSqlAccess'}; # remove since sensitive and not needed
1.75      albertel  847:     chdir($perlvar{'lonDaemons'});
1.46      albertel  848: # --------------------------------------- Make sure that LON-CAPA is configured
                    849: # I only test for one thing here (lonHostID).  This is just a safeguard.
                    850:     if ('{[[[[lonHostID]]]]}' eq $perlvar{'lonHostID'}) {
                    851: 	print("Unconfigured machine.\n");
                    852: 	my $emailto=$perlvar{'lonSysEMail'};
                    853: 	my $hostname=`/bin/hostname`;
                    854: 	chop $hostname;
                    855: 	$hostname=~s/[^\w\.]//g; # make sure is safe to pass through shell
                    856: 	my $subj="LON: Unconfigured machine $hostname";
                    857: 	system("echo 'Unconfigured machine $hostname.' |\
                    858:  mailto $emailto -s '$subj' > /dev/null");
                    859: 	exit 1;
                    860:     }
                    861: 
                    862: # ----------------------------- Make sure this process is running from user=www
                    863:     my $wwwid=getpwnam('www');
                    864:     if ($wwwid!=$<) {
                    865: 	print("User ID mismatch.  This program must be run as user 'www'\n");
                    866: 	my $emailto="$perlvar{'lonAdmEMail'},$perlvar{'lonSysEMail'}";
                    867: 	my $subj="LON: $perlvar{'lonHostID'} User ID mismatch";
                    868: 	system("echo 'User ID mismatch.  loncron must be run as user www.' |\
                    869:  mailto $emailto -s '$subj' > /dev/null");
                    870: 	exit 1;
                    871:     }
                    872: 
1.72      albertel  873: # -------------------------------------------- Force reload of host information
                    874:     &Apache::lonnet::load_hosts_tab(1);
                    875:     &Apache::lonnet::load_domain_tab(1);
                    876:     &Apache::lonnet::get_iphost(1);
1.46      albertel  877: 
1.81      raeburn   878: # ----------------------------------------- Force firewall update for lond port  
                    879: 
                    880:     if ((!$justcheckdaemons) && (!$justreload)) {
                    881:         my $now = time;
                    882:         my $tmpfile = $perlvar{'lonDaemons'}.'/tmp/lciptables_iphost_'.
                    883:                       $now.$$.int(rand(10000));
                    884:         if (open(my $fh,">$tmpfile")) {
                    885:             my %iphosts = &Apache::lonnet::get_iphost();
                    886:             foreach my $key (keys(%iphosts)) {
                    887:                 print $fh "$key\n";
                    888:             }
                    889:             close($fh);
1.89      raeburn   890:             if (&LONCAPA::try_to_lock('/tmp/lock_lciptables')) {
                    891:                 my $execpath = $perlvar{'lonDaemons'}.'/lciptables';
                    892:                 system("$execpath $tmpfile");
                    893:                 unlink('/tmp/lock_lciptables');  # Remove the lock file. 
                    894:             }
1.88      raeburn   895:             unlink($tmpfile);
1.81      raeburn   896:         }
                    897:     }
                    898: 
1.46      albertel  899: # ---------------------------------------------------------------- Start report
                    900: 
                    901:     $errors=0;
                    902:     $warnings=0;
                    903:     $notices=0;
                    904: 
                    905: 	
1.49      albertel  906:     my $fh;
1.59      albertel  907:     if (!$justcheckdaemons && !$justcheckconnections && !$justreload) {
1.72      albertel  908: 	$fh=&start_logging();
1.49      albertel  909: 
                    910: 	&log_machine_info($fh);
                    911: 	&clean_tmp($fh);
                    912: 	&clean_lonIDs($fh);
                    913: 	&check_httpd_logs($fh);
                    914: 	&rotate_lonnet_logs($fh);
1.73      albertel  915: 	&rotate_other_logs($fh);
1.49      albertel  916:     }
1.59      albertel  917:     if (!$justcheckconnections && !$justreload) {
1.76      albertel  918: 	&checkon_daemon($fh,'lonmemcached',40000);
1.49      albertel  919: 	&checkon_daemon($fh,'lonsql',200000);
1.63      albertel  920: 	if ( &checkon_daemon($fh,'lond',40000,'USR1') eq 'running') {
                    921: 	    &checkon_daemon($fh,'lond',40000,'USR2');
                    922: 	}
1.71      albertel  923: 	&checkon_daemon($fh,'lonc',40000,'USR1');
1.70      raeburn   924:         &checkon_daemon($fh,'lonmaxima',40000);
1.80      www       925:         &checkon_daemon($fh,'lonr',40000);
1.49      albertel  926:     }
1.59      albertel  927:     if ($justreload) {
                    928: 	&checkon_daemon($fh,'lond',40000,'USR2');
1.71      albertel  929: 	&checkon_daemon($fh,'lonc',40000,'USR2');
1.59      albertel  930:     }
1.63      albertel  931:     if ($justcheckconnections) {
1.72      albertel  932: 	&test_connections($fh);
1.49      albertel  933:     }
1.59      albertel  934:     if (!$justcheckdaemons && !$justcheckconnections && !$justreload) {
1.72      albertel  935: 	&check_delayed_msg($fh);
1.49      albertel  936: 	&finish_logging($fh);
                    937: 	&log_simplestatus();
1.87      raeburn   938:         &write_loncaparevs();
                    939:         &write_serverhomeIDs();
1.96    ! raeburn   940: 	&write_checksums(\%perlvar);
1.49      albertel  941: 	if ($totalcount>200 && !$noemail) { &send_mail(); }
                    942:     }
1.46      albertel  943: }
                    944: 
                    945: &main();
1.1       albertel  946: 1;
                    947: 

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