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