Article View: de.admin.news.software
Article #176Re: Bug in C News Performance Release
From: Matthias Urlichs
Date: Mon, 17 Aug 1992 07:52
Date: Mon, 17 Aug 1992 07:52
293 lines
7958 bytes
7958 bytes
In de.admin.news.software, article <wiljo.713771854@kiel.UUCP>,
wiljo@kiel.uucp (Wiljo Heinen) writes:
>
> o) Zumindest in 1 Fall, in dem ichs ueberpruefen konnte, tauchte der
> Artikel auch im togo auf
>
Aha. Folgerung: Der C-Batcher hat Probleme..?
Versuchs mal mit einem anderen Batcher. Der hier macht sich hier ganz gut
(installiere als "/usr/local/news/batch/sendbatches"):
#!/usr/local/bin/perl
# Master batching control, rewritten in Perl.
$defaultsys = "/default/";
$NEWSCTL="/usr/local/news/admin";
$NEWSBIN="/usr/local/news/bin";
$NEWSARTS="/usr/local/news/spool";
$ENV{'PATH'}="$NEWSBIN/innd:$NEWSBIN/batch:$NEWSBIN:/usr/local/bin:/usr/ucb:/usr/bin:/bin";
chdir "$NEWSARTS/out.going" || die "Cannot chdir to out.going\ $!";
$origpath=$ENV{'PATH'};
$parms="$NEWSCTL/batchparms";
$log="$NEWSCTL/batchlog";
$batchnext = $batchtemp = "togo.next";
$logtemp = "/tmp/batchlog.$$";
$recheck = 10; ## recheck for free space after N batches
open(CONF,"$parms") || die "Couldn't open batchparms: $!";
while (<CONF>) {
chop; s/#.*//; s/\s+$//; next if /^$/;
@data = split;
$sys = $data[0]; push(@syses, $sys) unless $sys eq $defaultsys;
$batchsize{$sys} = $data[1];
$queuelen{$sys} = $data[2];
$builder{$sys} = $data[3];
$muncher{$sys} = $data[4];
$sender{$sys} = $data[5];
}
close(CONF);
sub def {
local($s) = @_;
if(defined $batchsize{$s}) {
1;
} elsif(defined $batchsize{$defaultsys}) {
$batchsize{$s} = $batchsize{$defaultsys};
$queuelen{$s} = $queuelen{$defaultsys};
$builder{$s} = $builder{$defaultsys};
$muncher{$s} = $muncher{$defaultsys};
$sender{$s} = $sender{$defaultsys};
1;
} else {
0;
}
}
# Determine what systems are being requested, in what order.
if ($#ARGV >= $[) {
@syses = ();
foreach $sys (@ARGV) {
&def($sys) && push (@syses,$sys);
}
} elsif (-f "$NEWSCTL/batch_systems" && open(OUT,"$NEWSCTL/batch_systems")) {
@syses = ();
while(<OUT>) {
chop; s/#.*//; s/\s+$//; next if /^$/;
foreach $sys (split) {
&def($sys) && push (@syses,$sys);
}
}
close OUT;
} elsif (defined $batchsize{$defaultsys}) {
@syses = ();
opendir(OUT,".");
while($_ = readdir OUT) {
next if /^\./; next unless -d $_;
&def($_) && push(@syses, $_);
}
closedir(OUT);
} else {
# $syses already set up OK
}
if($debug) {
print join("\n",@syses),"\n";
exit 0;
}
# lock against multiple simultaneous execution
$lock="$NEWSCTL/LOCK.NONE";
$prelock="$NEWSCTL/LOCK.";
$ltemp="$NEWSCTL/L.$$";
open(LOCK,">$ltemp"); print LOCK "$$\n"; close LOCK;
sub unlock {
unlink ($lock,$ltemp);
}
$SIGNAL{'HUP'} = 'unlock';
$SIGNAL{'INT'} = 'unlock';
$SIGNAL{'TERM'} = 'unlock';
open(STDOUT,">>$log");
open(STDERR,">&STDOUT");
select(STDERR);$|=1;
select(STDOUT);$|=1;
# Start up logging.
print `date`;
# Run through them.
systems:
foreach $sys (@syses) {
$lock = $prelock.$sys;
if (! link($ltemp,$lock)) {
$lock = "";
next systems;
}
$here="$NEWSARTS/out.going/$sys";
if ( ! -d $here) {
&mailerr("$0: cannot find batch directory for \`$sys'");
next;
}
unless (-f "$NEWSARTS/in.coming/stop") {
system("$NEWSBIN/dyna/dofeeds $sys")
if -x "$NEWSBIN/dyna/dofeeds";
}
$ENV{'PATH'}="$here:$origpath";
$ENV{'NEWSSITE'} = $NEWSSITE=$sys;
$ENV{'NEWSSITEDIR'} = $NEWSSITEDIR=$here;
# How many to send?
$outstand=`queuelen $sys`;
$nbatch=$queuelen{$sys} - $outstand;
$roomfor=`spacefor $batchsize{$sys} outbound $sys`;
$nbatch=$roomfor if $nbatch > $roomfor;
$nbatch = 0 if -f "$NEWSARTS/in.coming/stop";
# If not allowed to send, remember reason.
if($nbatch > 0) {
$status='batches flowing';
} elsif ($roomfor <= 0) {
$status='disk too full for batching';
} else {
$status='queue full, no recent movement';
}
$somefile = 1;
$checkagain = $recheck;
# Try sending some.
$thefile = "";
batching:
while ($nbatch > 0) {
## send a batch
chdir $here;
if ($thefile eq "") {
if (-s $batchtemp) {
$thefile = $batchtemp;
} elsif (-s "togo.more") {
$thefile = "togo.more";
} elsif (-s $batchnext) {
rename($batchnext,"togo.more");
$thefile = "togo.more";
} elsif (-s "togo") {
$thefile = "togo";
} else {
unlink "togo";
system("/usr/local/news/bin/innd/ctlinnd -t 120 flush $sys >/dev/null 2>&1");
if (-s "togo") {
$thefile = "togo";
} else {
$somefile = 0;
last batching; ## no more batches
}
}
open(FILE,$thefile) ||
(&mailerr("Cannot open batch file $thefile: $!"),
last batching);
}
# make a batch and send it.
chdir $NEWSARTS;
$batch = $batchtemp;
$batch = "$here/$batchtemp" unless $batchtemp =~ /^\//;
if($thefile ne $batchtemp) {
open(BATCH,">$batch");
$batchsize = 0;
while(<FILE>) {
chop;
s/[ \t].*//;
(@state = stat $_) || next;
$batchsize += @state[7];
print BATCH $_,"\n";
last if $batchsize >= $batchsize{$sys};
}
close(BATCH);
if(eof(FILE)) {
close(FILE);
unlink "$here/$thefile"; $thefile = "";
}
} else {
$batchtemp = $thefile; close FILE; $thefile = "";
}
if(-s $batch) {
open(LOG,">&STDOUT");
open(STDOUT,">$logtemp"); open(STDERR,">&STDOUT");
system("$builder{$sys} $batch | $muncher{$sys} | "
."$sender{$sys} $sys");
open(STDOUT,">&LOG"); open(STDERR,">&LOG"); close(LOG);
chdir($here);
if ( -s $logtemp) {
open (MAIL,"|mail $NEWSMASTER");
print MAIL "\n$0: Batching for '$sys' failed!\n\n";
open(LOG,"$logtemp");
print MAIL while(<LOG>);
close(LOG); unlink $logtemp;
last batching;
} else {
unlink $batch;
unlink $logtemp;
}
}
$nbatch -= 1;
} continue {
if(--$checkagain = 0) {
$checkagain = $recheck;
# Recheck the space -- it can fall for other reasons.
$roomfor=`spacefor $batchsize{$sys} outbound $sys`;
$nbatch=$roomfor if $nbatch > $roomfor;
}
$nbatch = 0 if -f "$NEWSARTS/in.coming/stop";
}
if($thefile ne "" && $thefile ne $batchtemp) {
chdir $here;
# Batching has stopped. Copy the rest of this file.
open(OUTFILE,">>$batchnext") || next systems;
while(<FILE>) {
print OUTFILE;
}
close OUTFILE;
close FILE;
unlink($thefile);
if ( -s $batchnext ) {
rename($batchnext,$thefile);
} else {
unlink($batchnext);
}
}
if($somefile) {
# nart=`cat togo* | wc -l | awk '{print $1}'`
#if test " $nart" -gt 0
$nart="??";
print "$sys \tbacklog $nart ($status)\n";
}
} continue {
unlink ($lock) if $lock ne "";
}
unlink($ltemp);
print `date`,"\n";
exit(0);
sub mailerr {
open (MAIL,"|mail $NEWSMASTER");
print MAIL "\n";
print MAIL join("\n",@_);
print MAIL "\n\n";
close MAIL;
}
--
It took me fifteen years to discover I had no talent for
writing, but I couldn't give it up because by that time I
was too famous.
--
Matthias Urlichs -- urlichs@smurf.sub.org -- urlichs@smurf.ira.uka.de /(o\
Humboldtstrasse 7 -- 7500 Karlsruhe 1 -- Germany -- +49-721-9612521 \o)/
Technical Details
Message-ID:
<16nlshINNof7@smurf.smurf.sub.org>Path:
arc1-ca.pugleaf.net!sparky!uunet!gatech!darwin.sura.net!Sirius.dfn.de!math.fu-berlin.de!unidui!flyer!flatlin!smurf.sub.org!newsReferences:
<BspLCq.tp@deceiver.UUCP> <BsuD44.5FB@flatlin.ka.sub.org> <wiljo.713771854@kiel.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!gatech!darwin.sura.net!Sirius.dfn.de!math.fu-berlin.de!unidui!flyer!flatlin!smurf.sub.org!news From: urlichs@smurf.sub.org (Matthias Urlichs) Newsgroups: de.admin.news.software Subject: Re: Bug in C News Performance Release Date: 17 Aug 1992 09:52:49 +0200 Organization: University of Karlsruhe, FRG Lines: 293 Message-ID: <16nlshINNof7@smurf.smurf.sub.org> References: <BspLCq.tp@deceiver.UUCP> <BsuD44.5FB@flatlin.ka.sub.org> <wiljo.713771854@kiel.UUCP> NNTP-Posting-Host: 127.0.0.1