--- loncom/loncron 2010/07/17 20:01:56 1.84 +++ 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.84 2010/07/17 20:01:56 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; @@ -691,7 +692,7 @@ sub write_loncaparevs { foreach my $id (sort(keys(%hostname))) { if ($id ne '') { my $loncaparev = &Apache::lonnet::get_server_loncaparev('',$id,1,'loncron'); - if ($loncaparev =~ /^[\d.\-]+$/) { + if ($loncaparev =~ /^[\w.\-]+$/) { print $fh $id.':'.$loncaparev."\n"; } } @@ -701,6 +702,26 @@ sub write_loncaparevs { 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'}; @@ -801,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); } } @@ -846,12 +870,11 @@ sub main () { &check_delayed_msg($fh); &finish_logging($fh); &log_simplestatus(); + &write_loncaparevs(); + &write_serverhomeIDs(); if ($totalcount>200 && !$noemail) { &send_mail(); } } - if (!$justcheckconnections && !$justreload) { - &write_loncaparevs(); - } } &main();