--- loncom/loncron 2010/03/24 18:57:49 1.83 +++ loncom/loncron 2011/05/14 16:12:53 1.89 @@ -2,7 +2,7 @@ # Housekeeping program, started by cron, loncontrol and loncron.pl # -# $Id: loncron,v 1.83 2010/03/24 18:57:49 raeburn Exp $ +# $Id: loncron,v 1.89 2011/05/14 16:12:53 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -32,6 +32,7 @@ use strict; use lib '/home/httpd/lib/perl/'; use LONCAPA::Configuration; +use LONCAPA; use Apache::lonnet; use Apache::loncommon; @@ -685,6 +686,42 @@ sub log_simplestatus { $sfh->close(); } +sub write_loncaparevs { + if (open(my $fh,">$perlvar{'lonTabDir'}/loncaparevs.tab")) { + my %hostname = &Apache::lonnet::all_hostnames(); + foreach my $id (sort(keys(%hostname))) { + if ($id ne '') { + my $loncaparev = &Apache::lonnet::get_server_loncaparev('',$id,1,'loncron'); + if ($loncaparev =~ /^[\w.\-]+$/) { + print $fh $id.':'.$loncaparev."\n"; + } + } + } + close($fh); + } + return; +} + +sub write_serverhomeIDs { + if (open(my $fh,">$perlvar{'lonTabDir'}/serverhomeIDs.tab")) { + my %name_to_host = &Apache::lonnet::all_names(); + foreach my $name (sort(keys(%name_to_host))) { + if ($name ne '') { + if (ref($name_to_host{$name}) eq 'ARRAY') { + my $serverhomeID = &Apache::lonnet::get_server_homeID($name,1,'loncron'); + if ($serverhomeID ne '') { + print $fh $name.':'.$serverhomeID."\n"; + } else { + print $fh $name.':'.$name_to_host{$name}->[0]."\n"; + } + } + } + } + close($fh); + } + return; +} + sub send_mail { print "sending mail\n"; my $defdom = $perlvar{'lonDefDomain'}; @@ -785,9 +822,12 @@ sub main () { print $fh "$key\n"; } close($fh); - my $execpath = $perlvar{'lonDaemons'}.'/lciptables'; - system("$execpath $tmpfile"); - unlink($fh); + if (&LONCAPA::try_to_lock('/tmp/lock_lciptables')) { + my $execpath = $perlvar{'lonDaemons'}.'/lciptables'; + system("$execpath $tmpfile"); + unlink('/tmp/lock_lciptables'); # Remove the lock file. + } + unlink($tmpfile); } } @@ -830,6 +870,8 @@ sub main () { &check_delayed_msg($fh); &finish_logging($fh); &log_simplestatus(); + &write_loncaparevs(); + &write_serverhomeIDs(); if ($totalcount>200 && !$noemail) { &send_mail(); } }