--- loncom/loncron 2018/11/18 22:50:46 1.114
+++ loncom/loncron 2018/12/22 20:05:16 1.116
@@ -2,7 +2,7 @@
# Housekeeping program, started by cron, loncontrol and loncron.pl
#
-# $Id: loncron,v 1.114 2018/11/18 22:50:46 raeburn Exp $
+# $Id: loncron,v 1.116 2018/12/22 20:05:16 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -34,6 +34,7 @@ use lib '/home/httpd/lib/perl/';
use LONCAPA::Configuration;
use LONCAPA::Checksumming;
use LONCAPA;
+use LONCAPA::LWPReq;
use Apache::lonnet;
use Apache::loncommon;
@@ -511,6 +512,34 @@ sub clean_lonIDs {
&log($fh,"
$active open session(s)
");
}
+# -------------------------------------------------------- clean out balanceIDs
+
+sub clean_balanceIDs {
+ my ($fh)=@_;
+ &log($fh,'
Session Tokens
');
+ my $cleaned=0;
+ my $active=0;
+ if (-d $perlvar{'lonBalanceDir'}) {
+ while (my $fname=<$perlvar{'balanceDir'}/*.id>) {
+ my ($dev,$ino,$mode,$nlink,
+ $uid,$gid,$rdev,$size,
+ $atime,$mtime,$ctime,
+ $blksize,$blocks)=stat($fname);
+ my $now=time;
+ my $since=$now-$mtime;
+ if ($since>$perlvar{'lonExpire'}) {
+ $cleaned++;
+ &log($fh,"Unlinking $fname
");
+ unlink("$fname");
+ } else {
+ $active++;
+ }
+ }
+ }
+ &log($fh,"Cleaned up ".$cleaned." stale balancer files
");
+ &log($fh,"$active unexpired balancer files
");
+}
+
# ------------------------------------------------ clean out webDAV Session IDs
sub clean_webDAV_sessionIDs {
my ($fh)=@_;
@@ -1095,7 +1124,7 @@ sub get_domain_config {
unless ($protocol eq 'https') {
$protocol = 'http';
}
- $url = $protocol.'://'.$hostname.'/cgi-bin/listdomconfig.pl';
+ $url = $protocol.'://'.$hostname.'/cgi-bin/listdomconfig.pl?primary='.$primlibserv.'&format=raw';
}
if ($isprimary) {
my $lonusersdir = $perlvar{'lonUsersDir'};
@@ -1116,14 +1145,12 @@ sub get_domain_config {
}
}
} else {
- if (open(PIPE,"wget --no-check-certificate '$url?primary=$primlibserv&format=raw' |")) {
- my $config = '';
- while () {
- $config .= $_;
- }
- close(PIPE);
- if ($config) {
- my @pairs=split(/\&/,$config);
+ my $request=new HTTP::Request('GET',$url);
+ my $response=&LONCAPA::LWPReq::makerequest($primlibserv,$request,'',\%perlvar,5);
+ unless ($response->is_error()) {
+ my $content = $response->content;
+ if ($content) {
+ my @pairs=split(/\&/,$content);
foreach my $item (@pairs) {
my ($key,$value)=split(/=/,$item,2);
my $what = &LONCAPA::unescape($key);
@@ -1471,6 +1498,7 @@ sub main () {
&log_machine_info($fh);
&clean_tmp($fh);
&clean_lonIDs($fh);
+ &clean_balanceIDs($fh);
&clean_webDAV_sessionIDs($fh);
&check_httpd_logs($fh);
&rotate_lonnet_logs($fh);