version 1.91, 2011/10/28 14:26:15
|
version 1.97, 2013/02/02 14:42:01
|
Line 32 use strict;
|
Line 32 use strict;
|
|
|
use lib '/home/httpd/lib/perl/'; |
use lib '/home/httpd/lib/perl/'; |
use LONCAPA::Configuration; |
use LONCAPA::Configuration; |
|
use LONCAPA::Checksumming; |
use LONCAPA; |
use LONCAPA; |
use Apache::lonnet; |
use Apache::lonnet; |
use Apache::loncommon; |
use Apache::loncommon; |
Line 270 sub log_machine_info {
|
Line 271 sub log_machine_info {
|
|
|
&log($fh,"<h3>distprobe</h3>"); |
&log($fh,"<h3>distprobe</h3>"); |
&log($fh,"<pre>"); |
&log($fh,"<pre>"); |
open(DSH,"$perlvar{'lonDaemons'}/distprobe |"); |
&get_distro($perlvar{'lonDaemons'},$fh); |
while (my $line=<DSH>) { |
|
&log($fh,&encode_entities($line,'<>&"')); |
|
$psproc++; |
|
} |
|
close(DSH); |
|
&log($fh,"</pre>"); |
&log($fh,"</pre>"); |
|
|
&errout($fh); |
&errout($fh); |
Line 515 sub clean_sockets {
|
Line 511 sub clean_sockets {
|
# ----------------------------------------------------------------------- httpd |
# ----------------------------------------------------------------------- httpd |
sub check_httpd_logs { |
sub check_httpd_logs { |
my ($fh)=@_; |
my ($fh)=@_; |
&log($fh,'<hr /><a name="httpd" /><h2>httpd</h2><h3>Access Log</h3><pre>'); |
if (open(PIPE,"./lchttpdlogs|")) { |
|
while (my $line=<PIPE>) { |
open (DFH,"tail -n25 /etc/httpd/logs/access_log|"); |
&log($fh,$line); |
while (my $line=<DFH>) { &log($fh,&encode_entities($line,'<>&"')) }; |
if ($line=~/\[error\]/) { $notices++; } |
close (DFH); |
} |
|
close(PIPE); |
&log($fh,"</pre><h3>Error Log</h3><pre>"); |
|
|
|
open (DFH,"tail -n25 /etc/httpd/logs/error_log|"); |
|
while (my $line=<DFH>) { |
|
&log($fh,"$line"); |
|
if ($line=~/\[error\]/) { $notices++; } |
|
} |
} |
close (DFH); |
|
&log($fh,"</pre>"); |
|
&errout($fh); |
&errout($fh); |
} |
} |
|
|
Line 635 sub check_delayed_msg {
|
Line 623 sub check_delayed_msg {
|
} |
} |
|
|
&log($fh,"<p>Total unsend messages: <b>$unsend</b></p>\n"); |
&log($fh,"<p>Total unsend messages: <b>$unsend</b></p>\n"); |
$warnings=$warnings+5*$unsend; |
if ($unsend > 0) { |
|
$warnings=$warnings+5*$unsend; |
|
} |
|
|
if ($unsend) { $simplestatus{'unsend'}=$unsend; } |
if ($unsend) { $simplestatus{'unsend'}=$unsend; } |
&log($fh,"<h3>Outgoing Buffer</h3>\n<pre>"); |
&log($fh,"<h3>Outgoing Buffer</h3>\n<pre>"); |
Line 649 sub check_delayed_msg {
|
Line 639 sub check_delayed_msg {
|
} |
} |
&log($fh,"</pre>\n"); |
&log($fh,"</pre>\n"); |
close (DFH); |
close (DFH); |
|
my %hostname = &Apache::lonnet::all_hostnames(); |
|
my $numhosts = scalar(keys(%hostname)); |
# pong to all servers that have delayed messages |
# pong to all servers that have delayed messages |
# this will trigger a reverse connection, which should flush the buffers |
# this will trigger a reverse connection, which should flush the buffers |
foreach my $tryserver (keys %servers) { |
foreach my $tryserver (sort(keys(%servers))) { |
my $answer; |
if ($hostname{$tryserver} || !$numhosts) { |
eval { |
my $answer; |
local $SIG{ ALRM } = sub { die "TIMEOUT" }; |
eval { |
alarm(20); |
local $SIG{ ALRM } = sub { die "TIMEOUT" }; |
$answer = &Apache::lonnet::reply("pong",$tryserver); |
alarm(20); |
alarm(0); |
$answer = &Apache::lonnet::reply("pong",$tryserver); |
}; |
alarm(0); |
if ($@ && $@ =~ m/TIMEOUT/) { |
}; |
print "time out while contacting: $tryserver for pong\n"; |
if ($@ && $@ =~ m/TIMEOUT/) { |
|
&log($fh,"Attempted pong to $tryserver timed out<br />"); |
|
print "time out while contacting: $tryserver for pong\n"; |
|
} else { |
|
&log($fh,"Pong to $tryserver: $answer<br />"); |
|
} |
} else { |
} else { |
&log($fh,"Pong to $tryserver: $answer<br />"); |
&log($fh,"$tryserver has delayed messages, but is not part of the cluster -- skipping 'Pong'.<br />"); |
} |
} |
} |
} |
} |
} |
Line 754 sub write_serverhomeIDs {
|
Line 751 sub write_serverhomeIDs {
|
return; |
return; |
} |
} |
|
|
|
sub write_checksums { |
|
my $distro = &get_distro($perlvar{'lonDaemons'}); |
|
if ($distro) { |
|
print "Retrieving file version and checksumming.\n"; |
|
my $numchksums = 0; |
|
my ($chksumsref,$versionsref) = |
|
&LONCAPA::Checksumming::get_checksums($distro,$perlvar{'lonDaemons'}, |
|
$perlvar{'lonLib'}, |
|
$perlvar{'lonIncludes'}, |
|
$perlvar{'lonTabDir'}); |
|
if (ref($chksumsref) eq 'HASH') { |
|
$numchksums = scalar(keys(%{$chksumsref})); |
|
} |
|
print "File version retrieved and checksumming completed for $numchksums files.\n"; |
|
} else { |
|
print "File version retrieval and checksumming skipped - could not determine Linux distro.\n"; |
|
} |
|
return; |
|
} |
|
|
sub send_mail { |
sub send_mail { |
print "sending mail\n"; |
print "sending mail\n"; |
my $defdom = $perlvar{'lonDefDomain'}; |
my $defdom = $perlvar{'lonDefDomain'}; |
Line 771 sub send_mail {
|
Line 788 sub send_mail {
|
} |
} |
} |
} |
|
|
|
sub get_distro { |
|
my ($dir,$fh) = @_; |
|
my $distro; |
|
if (open(my $disth,"$dir/distprobe |")) { |
|
while (my $line=<$disth>) { |
|
if ($fh) { |
|
&log($fh,&encode_entities($line,'<>&"')); |
|
} |
|
$distro .= $line; |
|
} |
|
close($disth); |
|
} |
|
return $distro; |
|
} |
|
|
sub usage { |
sub usage { |
print(<<USAGE); |
print(<<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 |
Line 904 sub main () {
|
Line 936 sub main () {
|
&log_simplestatus(); |
&log_simplestatus(); |
&write_loncaparevs(); |
&write_loncaparevs(); |
&write_serverhomeIDs(); |
&write_serverhomeIDs(); |
|
&write_checksums(); |
if ($totalcount>200 && !$noemail) { &send_mail(); } |
if ($totalcount>200 && !$noemail) { &send_mail(); } |
} |
} |
} |
} |
Line 912 sub main () {
|
Line 944 sub main () {
|
&main(); |
&main(); |
1; |
1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|