--- loncom/loncron 2004/05/11 19:12:50 1.46
+++ loncom/loncron 2005/06/13 19:54:28 1.60
@@ -1,26 +1,42 @@
#!/usr/bin/perl
-# The LearningOnline Network
-# Housekeeping program, started by cron
+# Housekeeping program, started by cron, loncontrol and loncron.pl
#
-# (TCP networking package
-# 6/1/99,6/2,6/10,6/11,6/12,6/14,6/26,6/28,6/29,6/30,
-# 7/1,7/2,7/9,7/10,7/12 Gerd Kortemeyer)
+# $Id: loncron,v 1.60 2005/06/13 19:54:28 albertel Exp $
+#
+# Copyright Michigan State University Board of Trustees
+#
+# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
+#
+# LON-CAPA is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# LON-CAPA is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with LON-CAPA; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# /home/httpd/html/adm/gpl.txt
+#
+# http://www.lon-capa.org/
#
-# 7/14,7/15,7/19,7/21,7/22,11/18,
-# 2/8 Gerd Kortemeyer
-# 12/23 Gerd Kortemeyer
-# YEAR=2001
-# 09/04,09/06,11/26 Gerd Kortemeyer
$|=1;
+use strict;
use lib '/home/httpd/lib/perl/';
use LONCAPA::Configuration;
use IO::File;
use IO::Socket;
-use strict;
+use HTML::Entities;
+use Getopt::Long;
#globals
use vars qw (%perlvar %simplestatus $errors $warnings $notices $totalcount);
@@ -52,45 +68,52 @@ sub log {
sub errout {
my $fh=shift;
&log($fh,(<
+ Rotating error logs ... ");
+ &log($fh," Seems like it started ... ");
+ &log($fh," Seems like that did not work! ');
+ printf("%-15s ",$daemon);
if (-e "$perlvar{'lonDaemons'}/logs/$daemon.log"){
open (DFH,"tail -n25 $perlvar{'lonDaemons'}/logs/$daemon.log|");
while (my $line=
+
ENDERROUT
}
sub start_daemon {
- my ($fh,$daemon,$pidfile) = @_;
+ my ($fh,$daemon,$pidfile,$args) = @_;
my $progname=$daemon;
- if ($daemon eq 'lonc' && $ARGV[0] eq 'new') {
+ if ($daemon eq 'lonc' && $args eq 'new') {
$progname='loncnew';
print "new ";
}
- system("$perlvar{'lonDaemons'}/$progname 2>>$perlvar{'lonDaemons'}/logs/${daemon}_errors");
- sleep 2;
+ my $error_fname="$perlvar{'lonDaemons'}/logs/${daemon}_errors";
+ my $size=(stat($error_fname))[7];
+ if ($size>40000) {
+ &log($fh,"
Notices $notices Warnings $warnings
- Errors $errors '.$daemon.'
Log
');
- printf("%-10s ",$daemon);
+ &log($fh,'
");
+ &log($fh,"'.$daemon.'
Log
"); + &log($fh,"
Give it one more try ...
"); print " "; - if (&start_daemon($fh,$daemon,$pidfile)) { + if (&start_daemon($fh,$daemon,$pidfile,$args)) { &log($fh,""); + &log($fh,"
Unable to start $daemon
"); } } @@ -167,7 +197,7 @@ sub checkon_daemon { if ($line=~/CRITICAL/) { $notices++; } }; close (DFH); - &log($fh,""); + &log($fh,""); } } @@ -179,7 +209,7 @@ sub checkon_daemon { $blksize,$blocks)=stat($fname); if ($size>$maxsize) { - &log($fh,"Rotating logs ..."); + &log($fh,"
Rotating logs ...
"); rename("$fname.2","$fname.3"); rename("$fname.1","$fname.2"); rename("$fname","$fname.1"); @@ -191,7 +221,7 @@ sub checkon_daemon { # --------------------------------------------------------------------- Machine sub log_machine_info { my ($fh)=@_; - &log($fh,'"); my $psproc=0; - open (PSH,"ps -aux --cols 140 |"); + open (PSH,"ps aux --cols 140 |"); while (my $line=) { - &log($fh,"$line"); + &log($fh,&encode_entities($line,'<>&"')); $psproc++; } close (PSH); @@ -264,35 +294,36 @@ sub start_logging { LON Status Report $perlvar{'lonHostID'} - +LON Status Report $perlvar{'lonHostID'}
$date ($now)
-
-- Configuration -
- Machine Information -
- Temporary Files -
- Session Tokens -
- httpd -
- lonsql -
- lond -
- lonc -
- lonhttpd -
- lonnet -
- Connections -
- Delayed Messages -
- Error Coindex.html.unt +
- Configuration
+- Machine Information
+- Temporary Files
+- Session Tokens
+- httpd
+- lonsql
+- lond
+- lonc
+- lonhttpd
+- lonnet
+- Connections
+- Delayed Messages
+- Error Count
- +
+Configuration
PerlVars
-