version 1.133, 2024/07/28 23:49:32
|
version 1.137, 2024/12/25 02:32:47
|
Line 134 sub checkon_daemon {
|
Line 134 sub checkon_daemon {
|
} |
} |
|
|
my $pidfile="$perlvar{'lonDaemons'}/logs/$daemon.pid"; |
my $pidfile="$perlvar{'lonDaemons'}/logs/$daemon.pid"; |
|
|
my $restartflag=1; |
my $restartflag=1; |
my $daemonpid; |
my $daemonpid; |
if (-e $pidfile) { |
if (-e $pidfile) { |
Line 206 sub checkon_daemon {
|
Line 206 sub checkon_daemon {
|
if (-e "$perlvar{'lonDaemons'}/logs/$daemon.log"){ |
if (-e "$perlvar{'lonDaemons'}/logs/$daemon.log"){ |
&log($fh,"<p><pre>"); |
&log($fh,"<p><pre>"); |
if (open(DFH,"tail -n100 $perlvar{'lonDaemons'}/logs/$daemon.log|")) { |
if (open(DFH,"tail -n100 $perlvar{'lonDaemons'}/logs/$daemon.log|")) { |
while (my $line=<DFH>) { |
while (my $line=<DFH>) { |
&log($fh,"$line"); |
&log($fh,"$line"); |
if ($line=~/WARNING/) { $notices++; } |
if ($line=~/WARNING/) { $notices++; } |
if ($line=~/CRITICAL/) { $notices++; } |
if ($line=~/CRITICAL/) { $notices++; } |
Line 249 sub log_machine_info {
|
Line 249 sub log_machine_info {
|
open (LOADAVGH,"/proc/loadavg"); |
open (LOADAVGH,"/proc/loadavg"); |
my $loadavg=<LOADAVGH>; |
my $loadavg=<LOADAVGH>; |
close (LOADAVGH); |
close (LOADAVGH); |
|
|
&log($fh,"<tt>$loadavg</tt>"); |
&log($fh,"<tt>$loadavg</tt>"); |
|
|
my @parts=split(/\s+/,$loadavg); |
my @parts=split(/\s+/,$loadavg); |
Line 309 sub log_machine_info {
|
Line 309 sub log_machine_info {
|
|
|
sub start_logging { |
sub start_logging { |
my $fh=IO::File->new(">$statusdir/newstatus.html"); |
my $fh=IO::File->new(">$statusdir/newstatus.html"); |
my %simplestatus=(); |
%simplestatus=(); |
my $now=time; |
my $now=time; |
my $date=localtime($now); |
my $date=localtime($now); |
|
|
|
|
&log($fh,(<<ENDHEADERS)); |
&log($fh,(<<ENDHEADERS)); |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
Line 426 sub recursive_clean_tmp {
|
Line 426 sub recursive_clean_tmp {
|
} else { |
} else { |
$innerdir = $subdir.'/'.$file; |
$innerdir = $subdir.'/'.$file; |
} |
} |
($cleaned,$old,$removed) = |
($cleaned,$old,$removed) = |
&recursive_clean_tmp($innerdir,$cleaned,$old,$removed,$errors); |
&recursive_clean_tmp($innerdir,$cleaned,$old,$removed,$errors); |
my @doms = &Apache::lonnet::current_machine_domains(); |
my @doms = &Apache::lonnet::current_machine_domains(); |
|
|
Line 472 sub recursive_clean_tmp {
|
Line 472 sub recursive_clean_tmp {
|
if ($line=~/^CHECKOUTTOKEN\&/) { |
if ($line=~/^CHECKOUTTOKEN\&/) { |
if ($since>365*$perlvar{'lonExpire'}) { |
if ($since>365*$perlvar{'lonExpire'}) { |
if (unlink($fname)) { |
if (unlink($fname)) { |
$cleaned++; |
$cleaned++; |
} elsif (ref($errors->{file}) eq 'ARRAY') { |
} elsif (ref($errors->{file}) eq 'ARRAY') { |
push(@{$errors->{file}},$fname); |
push(@{$errors->{file}},$fname); |
} |
} |
Line 638 sub clean_sockets {
|
Line 638 sub clean_sockets {
|
my $cleaned=0; |
my $cleaned=0; |
opendir(SOCKETS,$perlvar{'lonSockDir'}); |
opendir(SOCKETS,$perlvar{'lonSockDir'}); |
while (my $fname=readdir(SOCKETS)) { |
while (my $fname=readdir(SOCKETS)) { |
next if (-d $fname |
next if (-d $fname |
|| $fname=~/(mysqlsock|maximasock|rsock|\Q$perlvar{'lonSockDir'}\E)/); |
|| $fname=~/(mysqlsock|maximasock|rsock|\Q$perlvar{'lonSockDir'}\E)/); |
$cleaned++; |
$cleaned++; |
&log($fh,"Unlinking $fname<br />"); |
&log($fh,"Unlinking $fname<br />"); |
Line 745 sub check_delayed_msg {
|
Line 745 sub check_delayed_msg {
|
my ($fh,$weightsref,$exclusionsref)=@_; |
my ($fh,$weightsref,$exclusionsref)=@_; |
&log($fh,'<hr /><a name="delayed" /><h2>Delayed Messages</h2>'); |
&log($fh,'<hr /><a name="delayed" /><h2>Delayed Messages</h2>'); |
print "Checking buffers.\n"; |
print "Checking buffers.\n"; |
|
|
&log($fh,'<h3>Scanning Permanent Log</h3>'); |
&log($fh,'<h3>Scanning Permanent Log</h3>'); |
|
|
my $unsend=0; |
my $unsend=0; |
Line 816 sub check_delayed_msg {
|
Line 816 sub check_delayed_msg {
|
last; |
last; |
} |
} |
undef $dfh; |
undef $dfh; |
} |
} |
|
|
if ($checkbackwards) { |
if ($checkbackwards) { |
if (tie *BW, 'File::ReadBackwards', "$perlvar{'lonDaemons'}/logs/lonnet.perm.log") { |
if (tie *BW, 'File::ReadBackwards', "$perlvar{'lonDaemons'}/logs/lonnet.perm.log") { |
Line 996 sub finish_logging {
|
Line 996 sub finish_logging {
|
|
|
sub log_simplestatus { |
sub log_simplestatus { |
rename("$statusdir/newstatus.html","$statusdir/index.html"); |
rename("$statusdir/newstatus.html","$statusdir/index.html"); |
|
|
my $sfh=IO::File->new(">$statusdir/loncron_simple.txt"); |
my $sfh=IO::File->new(">$statusdir/loncron_simple.txt"); |
foreach (keys %simplestatus) { |
if (defined($sfh)) { |
print $sfh $_.'='.$simplestatus{$_}.'&'; |
foreach my $key (keys(%simplestatus)) { |
|
print $sfh $key.'='.$simplestatus{$key}.'&'; |
|
} |
|
print $sfh "\n"; |
|
$sfh->close(); |
|
} else { |
|
print "Could not write to $statusdir/loncron_simple.txt\n"; |
} |
} |
print $sfh "\n"; |
|
$sfh->close(); |
|
} |
} |
|
|
sub write_loncaparevs { |
sub write_loncaparevs { |
Line 1020 sub write_loncaparevs {
|
Line 1024 sub write_loncaparevs {
|
alarm(0); |
alarm(0); |
}; |
}; |
if ($@ && $@ =~ m/TIMEOUT/) { |
if ($@ && $@ =~ m/TIMEOUT/) { |
print "Time out while contacting lonHost: $id for version.\n"; |
print "Time out while contacting lonHost: $id for version.\n"; |
} |
} |
if ($loncaparev =~ /^[\w.\-]+$/) { |
if ($loncaparev =~ /^[\w.\-]+$/) { |
$output .= $id.':'.$loncaparev."\n"; |
$output .= $id.':'.$loncaparev."\n"; |
Line 1028 sub write_loncaparevs {
|
Line 1032 sub write_loncaparevs {
|
} |
} |
} |
} |
if ($output) { |
if ($output) { |
if (open(my $fh,">$perlvar{'lonTabDir'}/loncaparevs.tab")) { |
if (open(my $fh,'>',"$perlvar{'lonTabDir'}/loncaparevs.tab")) { |
print $fh $output; |
print $fh $output; |
close($fh); |
close($fh); |
&Apache::lonnet::load_loncaparevs(); |
&Apache::lonnet::load_loncaparevs(); |
|
} else { |
|
print "Could not write to $perlvar{'lonTabDir'}/loncaparevs.tab\n"; |
} |
} |
} |
} |
return; |
return; |
Line 1053 sub write_serverhomeIDs {
|
Line 1059 sub write_serverhomeIDs {
|
alarm(0); |
alarm(0); |
}; |
}; |
if ($@ && $@ =~ m/TIMEOUT/) { |
if ($@ && $@ =~ m/TIMEOUT/) { |
print "Time out while contacting server: $name\n"; |
print "Time out while contacting server: $name\n"; |
} |
} |
if ($serverhomeID ne '') { |
if ($serverhomeID ne '') { |
$output .= $name.':'.$serverhomeID."\n"; |
$output .= $name.':'.$serverhomeID."\n"; |
Line 1064 sub write_serverhomeIDs {
|
Line 1070 sub write_serverhomeIDs {
|
} |
} |
} |
} |
if ($output) { |
if ($output) { |
if (open(my $fh,">$perlvar{'lonTabDir'}/serverhomeIDs.tab")) { |
if (open(my $fh,'>',"$perlvar{'lonTabDir'}/serverhomeIDs.tab")) { |
print $fh $output; |
print $fh $output; |
close($fh); |
close($fh); |
&Apache::lonnet::load_serverhomeIDs(); |
&Apache::lonnet::load_serverhomeIDs(); |
|
} else { |
|
print "Could not write to $perlvar{'lonTabDir'}/serverhomeIDs.tab\n"; |
} |
} |
} |
} |
return; |
return; |
Line 1088 sub write_checksums {
|
Line 1096 sub write_checksums {
|
} |
} |
print "File version retrieved and checksumming completed for $numchksums files.\n"; |
print "File version retrieved and checksumming completed for $numchksums files.\n"; |
} else { |
} else { |
print "File version retrieval and checksumming skipped - could not determine Linux distro.\n"; |
print "File version retrieval and checksumming skipped - could not determine Linux distro.\n"; |
} |
} |
return; |
return; |
} |
} |
Line 1128 sub write_hostips {
|
Line 1136 sub write_hostips {
|
} |
} |
close($fh); |
close($fh); |
chmod(0644,$newfile); |
chmod(0644,$newfile); |
|
} else { |
|
print "Could not write to $lontabdir/currhostips.tab\n"; |
} |
} |
} |
} |
if (keys(%prevhosts) && keys(%currhosts)) { |
if (keys(%prevhosts) && keys(%currhosts)) { |
Line 1153 sub write_hostips {
|
Line 1163 sub write_hostips {
|
} |
} |
print $fh "\n*******************\n\n"; |
print $fh "\n*******************\n\n"; |
close($fh); |
close($fh); |
|
} else { |
|
print "Could not write to $perlvar{'lonDaemons'}/logs/hostip.log\n"; |
} |
} |
my $emailto = &Apache::loncommon::build_recipient_list(undef, |
my $emailto = &Apache::loncommon::build_recipient_list(undef, |
'hostipmail',$defdom); |
'hostipmail',$defdom); |
Line 1228 sub write_connection_config {
|
Line 1240 sub write_connection_config {
|
} |
} |
} |
} |
if (keys(%connectssl)) { |
if (keys(%connectssl)) { |
my %currconf; |
my %currconf; |
if (open(my $fh,'<',"$perlvar{'lonTabDir'}/connectionrules.tab")) { |
if (open(my $fh,'<',"$perlvar{'lonTabDir'}/connectionrules.tab")) { |
while (my $line = <$fh>) { |
while (my $line = <$fh>) { |
chomp($line); |
chomp($line); |
Line 1243 sub write_connection_config {
|
Line 1255 sub write_connection_config {
|
} |
} |
if (open(my $fh,'>',"$perlvar{'lonTabDir'}/connectionrules.tab")) { |
if (open(my $fh,'>',"$perlvar{'lonTabDir'}/connectionrules.tab")) { |
my $count = 0; |
my $count = 0; |
foreach my $key (sort(keys(%connectssl))) { |
foreach my $key (sort(keys(%connectssl))) { |
print $fh "$key=$connectssl{$key}\n"; |
print $fh "$key=$connectssl{$key}\n"; |
if (exists($currconf{$key})) { |
if (exists($currconf{$key})) { |
unless ($currconf{$key} eq $connectssl{$key}) { |
unless ($currconf{$key} eq $connectssl{$key}) { |
Line 1256 sub write_connection_config {
|
Line 1268 sub write_connection_config {
|
} |
} |
close($fh); |
close($fh); |
print "Completed writing SSL options for lonc/lond for $count items.\n"; |
print "Completed writing SSL options for lonc/lond for $count items.\n"; |
|
} else { |
|
print "Could not write to $perlvar{'lonTabDir'}/connectionrules.tab\n"; |
} |
} |
} else { |
} else { |
print "Writing of SSL options skipped - no connection rules in domain configuration.\n"; |
print "Writing of SSL options skipped - no connection rules in domain configuration.\n"; |
Line 1361 sub write_hosttypes {
|
Line 1375 sub write_hosttypes {
|
} |
} |
close($fh); |
close($fh); |
print "Completed writing host type data for $count hosts.\n"; |
print "Completed writing host type data for $count hosts.\n"; |
|
} else { |
|
print "Could not write to $perlvar{'lonTabDir'}/hosttypes.tab\n"; |
} |
} |
} else { |
} else { |
print "Writing of host types skipped - no hosts found.\n"; |
print "Writing of host types skipped - no hosts found.\n"; |
Line 1522 sub check_bash_settings {
|
Line 1538 sub check_bash_settings {
|
$bracketed_warning = 1; |
$bracketed_warning = 1; |
} |
} |
} else { |
} else { |
print "Unable to check if bracketed paste is set to off for www user's shell\n"; |
print "Unable to check if bracketed paste is set to off for www user's shell\n"; |
} |
} |
} |
} |
return ($bracketed_warning,$check_bracketed_paste); |
return ($bracketed_warning,$check_bracketed_paste); |
Line 1666 sub send_mail {
|
Line 1682 sub send_mail {
|
"Subject: ".$subj."\n". |
"Subject: ".$subj."\n". |
"Content-type: text/html\; charset=UTF-8\n". |
"Content-type: text/html\; charset=UTF-8\n". |
"MIME-Version: 1.0\n\n"; |
"MIME-Version: 1.0\n\n"; |
if (open(my $fh,"<$statusdir/index.html")) { |
if (open(my $fh,'<',"$statusdir/index.html")) { |
while (<$fh>) { |
while (<$fh>) { |
$loncronmail .= $_; |
$loncronmail .= $_; |
} |
} |
Line 1689 sub usage {
|
Line 1705 sub usage {
|
loncron - housekeeping program that checks up on various parts of LON-CAPA |
loncron - housekeeping program that checks up on various parts of LON-CAPA |
|
|
Options: |
Options: |
--help Display |
--help Display |
--noemail Do not send the status email |
--noemail Do not send the status email |
--justcheckconnections Only check the current status of the lonc/d |
--justcheckconnections Only check the current status of the lonc/d |
connections, do not send emails do not |
connections, do not send emails do not |
Line 1782 sub main () {
|
Line 1798 sub main () {
|
my $now = time; |
my $now = time; |
my $tmpfile = $perlvar{'lonDaemons'}.'/tmp/lciptables_iphost_'. |
my $tmpfile = $perlvar{'lonDaemons'}.'/tmp/lciptables_iphost_'. |
$now.$$.int(rand(10000)); |
$now.$$.int(rand(10000)); |
if (open(my $fh,">$tmpfile")) { |
if (open(my $fh,'>',"$tmpfile")) { |
my %iphosts = &Apache::lonnet::get_iphost(); |
my %iphosts = &Apache::lonnet::get_iphost(); |
foreach my $key (keys(%iphosts)) { |
foreach my $key (keys(%iphosts)) { |
print $fh "$key\n"; |
print $fh "$key\n"; |
Line 1832 sub main () {
|
Line 1848 sub main () {
|
&clean_nosslverify($fh); |
&clean_nosslverify($fh); |
&write_connection_config(); |
&write_connection_config(); |
&write_hosttypes(); |
&write_hosttypes(); |
&update_revocation_list(); |
&update_revocation_list(); |
&checkon_daemon($fh,'lond',40000,'USR2'); |
&checkon_daemon($fh,'lond',40000,'USR2'); |
&checkon_daemon($fh,'lonc',40000,'USR2'); |
&checkon_daemon($fh,'lonc',40000,'USR2'); |
} |
} |
Line 1860 sub main () {
|
Line 1876 sub main () {
|
&log($fh,'<p>'.$bash_update.'</p>'."\n"); |
&log($fh,'<p>'.$bash_update.'</p>'."\n"); |
} |
} |
} else { |
} else { |
&log($fh,'<p>No action needed; /home/www/.inputrc already set.</p>'."\n"); |
&log($fh,'<p>No action needed; /home/www/.inputrc already set.</p>'."\n"); |
} |
} |
} else { |
} else { |
&log($fh,'<hr /><a name="bashconf" /><h2>bash readline config</h2><h3>Bracketed Paste</h3>'. |
&log($fh,'<hr /><a name="bashconf" /><h2>bash readline config</h2><h3>Bracketed Paste</h3>'. |