🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.nntp
5 messages
5 total messages Started by Scott W. Gifford Sat, 05 Jul 1997 00:00
Possible solution for keeping control.* clean
#19028
Author: Scott W. Gifford
Date: Sat, 05 Jul 1997 00:00
155 lines
5314 bytes
  All of the posts that I've seen here about keeping the control newsgroups
under...well, control...have involved either gigantic patches to INN, or
else have simply blown away all of the articles in the control.* groups
every hour or so, and taken the chance of not propagating control messages
for backlogged feeds.  It seems to me you can get the simplicity of the
"blow it all away" approach without the danger by simply scanning the
outgoing batch files, and leaving any files which have not yet been sent
around until they are.

  Here's my first attempt at doing so...It's just a Perl script that I run
from Cron every hour or so.  It has only been rudimentarily tested, so use
at your own risk.  Run with "-Vn" switches to see what it would do without
actually doing anything.

  If you currently have a lot of articles in your control.* groups, run
this once manually, then re-create the directories to make them shrink down
to a reasonable size.  For example:

	mv control/cancel control/cancel.OLD
	mkdir control/cancel.NEW
	mv control/cancel.OLD/* control/cancel.NEW
	rmdir control/cancel.OLD

  Enjoy!  Let me know if you have any problems or improvements, or for some
reason this turns out to be just a tremendously bad idea...

-----Scott.

#!/usr/local/bin/perl

# cleanifprop - Remove all articles in a newsgroup except
# ones which have not yet propogated to downstream sites.

# Set this to the dir with innshellvars.pl
$INNDIR="/usr/local/news/etc";

# Set this to the newsgroups to be cleaned.
@CLEANGROUPS=("control.cancel","control");

# You shouldn't have to touch anything below here.
# But if you want to, have a ball...

# $Id: cleanifprop,v 1.3 1997-07-05 03:12:40-04 sgifford Exp $
#
# $Log: cleanifprop,v $
# Revision 1.3  1997-07-05 03:12:40-04  sgifford
# Reformatted for posting to USENET.
#
# Revision 1.2  1997-07-05 03:02:28-04  sgifford
# Initial Release
#
#

require "getopts.pl";

&Getopts("vVn");

$verbose=$opt_v||$opt_V;
$veryverbose=$opt_V;
$noaction=$opt_n;

push(@INC,$INNDIR);
require "innshellvars.pl";

# Clean out all files from directories which have been propogated
# to all outgoing feeds.  Mostly useful for control.cancel, to
# keep the directory lean and mean without affecting cancel
# propogation.

# Change the dots to slashes in @CLEANGROUPS

foreach (@CLEANGROUPS)
{
  s/\./\//g;
  push(@CLEANDIRS,$_);
}

# Take a snapshot of all of our out.going files.
# If it's in the batch directory, assume it's really a batch
# file.  If you think I'm going to parse all of newsfeeds
# just to find out which are real outgoing batches, you're nuts...

$verbose && print "Scanning outgoing batches in $inn::batch...\n";
chdir($inn::batch) || die "Couldn't chdir($inn::batch) (BATCHDIR)";
opendir(BATCH,".");
while ($out_going=readdir(BATCH))
{
  next if (($out_going eq ".") || ($out_going eq ".."));
  $verbose && print "\tScanning $inn::batch/$out_going...\n";
  open(OUT_GOING,$out_going);
  while (<OUT_GOING>)
  {
    # Lines in the out.going files look like this:
    # alt/test/197780 <01bc8903$d612e140$d8298acd@sgifford.tir.com>

    ($grp,$art)=m|^(.*)/([0-9]*) |;
    if (grep(/^$grp$/,@CLEANDIRS))
    {
      $saveart{"$grp/$art"}=1;
      $veryverbose && print "\t\tSaving $grp/$art.\n";
    }
  }
  close(OUT_GOING);
  $verbose && print "\tDone scanning $inn::batch/$out_going.\n";
}
closedir(BATCH);

$verbose && print "Done scanning outgoing batch files in ",
    "$inn::batch\n";

# OK, we have our saved articles...Now go into the spool directory
# and fry them.

$verbose && print "Cleaning up spool directory $inn::spool...\n";

# Let's make sure their spool directory is where they say it
# is, just to be nice.
chdir($inn::spool) || die "Couldn't chdir($inn::spool) (SPOOL)";

foreach $groupdir (@CLEANDIRS)
{
  # There shouldn't be that many groups, so don't try to be fancy
  # about getting there.
  unless (chdir("$inn::spool/$groupdir"))
  {
    warn "WARNING: Skipping $inn::spool/$groupdir: " .
        "Couldn't chdir($inn::spool/$groupdir)";
    next;
  }
  $verbose && print "\tCleaning $inn::spool/$groupdir\n";

  # Flip through the articles
  opendir(ARTICLES,".");
  while ($art=readdir(ARTICLES))
  {
    # Skip over things that don't look like articles.
    next unless ($art =~ /[0-9]+/);

    # Perl unlink won't delete dirs, so just fire away...
    unless ($saveart{"$groupdir/$art"})
    {
      $veryverbose && print "\t\tunlink($art)\n";
      unlink($art) unless $noaction;
    }
  }
  $verbose && print "\tDone cleaning $inn::spool/$groupdir\n";
  closedir(ARTICLES);
}

$verbose && print "Done cleaning up spool directory $inn::spool.\n";



Re: Possible solution for keeping control.* clean
#19033
Author: Matt Dillon
Date: Sun, 06 Jul 1997 00:00
28 lines
1793 bytes
:In article <01bc8988$87554040$d8298acd@sgifford-home.tir.com>,
:Scott W. Gifford <sgifford@tir.com> wrote:
:>  Just in case somebody wants to run this script, I thought I'd better post
:>the updated version that has one very substantial improvement...It works
:>correctly (or at least MORE correctly... :) ).  The old version deleted any
:>articles which were posted after the script started, which meant it would
:>delete lots of them before they could be propogated...The new one checks
:>the modification time on the files before deleting them, and makes sure it
:>was there when the script started.  Unfortunately this means a stat() for
:>every article, but it's better than losing them...
:>
:>----Scott.
:>
:>#!/usr/local/bin/perl
:>
:># $Id: cleanifprop,v 1.5 1997-07-05 17:10:26-04 sgifford Exp $
:...

    My newsprune program will do all this a lot faster
    ( http://www.backplane.com/ ), but if you want to improve your perl script
    you should move the stat.  There is no sense doing the stat unless you
    actually get to the point where you would otherwise remove the article.

						-Matt


Re: Possible solution for keeping control.* clean
#19089
Author: Scott W. Gifford
Date: Tue, 08 Jul 1997 00:00
20 lines
1347 bytes
>     My newsprune program will do all this a lot faster
>     ( http://www.backplane.com/ ), but if you want to improve your perl
script
>     you should move the stat.  There is no sense doing the stat unless
you
>     actually get to the point where you would otherwise remove the
article.

  How do you configure newsprune to do this?...The cancel messages are
still in the history database AFAIK, and (at least from the README) it
looks like newsprune will only clean up messages that aren't in the
history.

  And you're right about the stat; feel free to move it.  If anybody wants
a patched copy, email me and I'll keep you up-to-date.

-----Scott.

Re: Possible solution for keeping control.* clean
#19118
Author: ralph
Date: Thu, 10 Jul 1997 00:00
159 lines
5750 bytes
On 5 Jul 1997 07:15:07 GMT, "Scott W. Gifford" <sgifford@tir.com> wrote:

>  All of the posts that I've seen here about keeping the control newsgroups
>under...well, control...have involved either gigantic patches to INN, or
>else have simply blown away all of the articles in the control.* groups
>every hour or so, and taken the chance of not propagating control messages
>for backlogged feeds.  It seems to me you can get the simplicity of the
>"blow it all away" approach without the danger by simply scanning the
>outgoing batch files, and leaving any files which have not yet been sent
>around until they are.
>
>  Here's my first attempt at doing so...It's just a Perl script that I run
>from Cron every hour or so.  It has only been rudimentarily tested, so use
>at your own risk.  Run with "-Vn" switches to see what it would do without
>actually doing anything.
>
>  If you currently have a lot of articles in your control.* groups, run
>this once manually, then re-create the directories to make them shrink down
>to a reasonable size.  For example:
>
>	mv control/cancel control/cancel.OLD
>	mkdir control/cancel.NEW
>	mv control/cancel.OLD/* control/cancel.NEW
>	rmdir control/cancel.OLD
>
>  Enjoy!  Let me know if you have any problems or improvements, or for some
>reason this turns out to be just a tremendously bad idea...
>
>-----Scott.
>
>#!/usr/local/bin/perl
>
># cleanifprop - Remove all articles in a newsgroup except
># ones which have not yet propogated to downstream sites.
>
># Set this to the dir with innshellvars.pl
>$INNDIR="/usr/local/news/etc";
>
># Set this to the newsgroups to be cleaned.
>@CLEANGROUPS=("control.cancel","control");
>
># You shouldn't have to touch anything below here.
># But if you want to, have a ball...
>
># $Id: cleanifprop,v 1.3 1997-07-05 03:12:40-04 sgifford Exp $
>#
># $Log: cleanifprop,v $
># Revision 1.3  1997-07-05 03:12:40-04  sgifford
># Reformatted for posting to USENET.
>#
># Revision 1.2  1997-07-05 03:02:28-04  sgifford
># Initial Release
>#
>#
>
>require "getopts.pl";
>
>&Getopts("vVn");
>
>$verbose=$opt_v||$opt_V;
>$veryverbose=$opt_V;
>$noaction=$opt_n;
>
>push(@INC,$INNDIR);
>require "innshellvars.pl";
>
># Clean out all files from directories which have been propogated
># to all outgoing feeds.  Mostly useful for control.cancel, to
># keep the directory lean and mean without affecting cancel
># propogation.
>
># Change the dots to slashes in @CLEANGROUPS
>
>foreach (@CLEANGROUPS)
>{
>  s/\./\//g;
>  push(@CLEANDIRS,$_);
>}
>
># Take a snapshot of all of our out.going files.
># If it's in the batch directory, assume it's really a batch
># file.  If you think I'm going to parse all of newsfeeds
># just to find out which are real outgoing batches, you're nuts...
>
>$verbose && print "Scanning outgoing batches in $inn::batch...\n";
>chdir($inn::batch) || die "Couldn't chdir($inn::batch) (BATCHDIR)";
>opendir(BATCH,".");
>while ($out_going=readdir(BATCH))
>{
>  next if (($out_going eq ".") || ($out_going eq ".."));
>  $verbose && print "\tScanning $inn::batch/$out_going...\n";
>  open(OUT_GOING,$out_going);
>  while (<OUT_GOING>)
>  {
>    # Lines in the out.going files look like this:
>    # alt/test/197780 <01bc8903$d612e140$d8298acd@sgifford.tir.com>
>
>    ($grp,$art)=m|^(.*)/([0-9]*) |;
>    if (grep(/^$grp$/,@CLEANDIRS))
>    {
>      $saveart{"$grp/$art"}=1;
>      $veryverbose && print "\t\tSaving $grp/$art.\n";
>    }
>  }
>  close(OUT_GOING);
>  $verbose && print "\tDone scanning $inn::batch/$out_going.\n";
>}
>closedir(BATCH);
>
>$verbose && print "Done scanning outgoing batch files in ",
>    "$inn::batch\n";
>
># OK, we have our saved articles...Now go into the spool directory
># and fry them.
>
>$verbose && print "Cleaning up spool directory $inn::spool...\n";
>
># Let's make sure their spool directory is where they say it
># is, just to be nice.
>chdir($inn::spool) || die "Couldn't chdir($inn::spool) (SPOOL)";
>
>foreach $groupdir (@CLEANDIRS)
>{
>  # There shouldn't be that many groups, so don't try to be fancy
>  # about getting there.
>  unless (chdir("$inn::spool/$groupdir"))
>  {
>    warn "WARNING: Skipping $inn::spool/$groupdir: " .
>        "Couldn't chdir($inn::spool/$groupdir)";
>    next;
>  }
>  $verbose && print "\tCleaning $inn::spool/$groupdir\n";
>
>  # Flip through the articles
>  opendir(ARTICLES,".");
>  while ($art=readdir(ARTICLES))
>  {
>    # Skip over things that don't look like articles.
>    next unless ($art =~ /[0-9]+/);
>
>    # Perl unlink won't delete dirs, so just fire away...
>    unless ($saveart{"$groupdir/$art"})
>    {
>      $veryverbose && print "\t\tunlink($art)\n";
>      unlink($art) unless $noaction;
>    }
>  }
>  $verbose && print "\tDone cleaning $inn::spool/$groupdir\n";
>  closedir(ARTICLES);
>}
>
>$verbose && print "Done cleaning up spool directory $inn::spool.\n";
>
>thanx i don't know muck about this INN crap except i hope all servers come
> up with something for the slow post probs. i have 3 servers their all screwed....


Re: Possible solution for keeping control.* clean
#19146
Author: Hugh Messenger
Date: Thu, 10 Jul 1997 00:00
39 lines
2068 bytes


Scott W. Gifford <sgifford@tir.com> wrote in article
<01bc8bce$75f8e160$f8298acd@sgifford.tir.com>...

>   And you're right about the stat; feel free to move it.  If anybody
wants
> a patched copy, email me and I'll keep you up-to-date.

Speaking of patches ...

I'm running your script, but it was blowing up on any groups with double ++
signs in them (like foo.bar.c++), during the grep (somewhere around line
70).  So I changed the @CLEANDIRS to be an associative array, and instead
of grepping in a scalar context, I just check for the existence of
$cleandirs{$grp}.  While I was at it, I moved the stat() as well.  :)

I can send you the new version if you want.  With these two small changes
it seems to be running well.  I'm currently also rm'ing the .overview from
cron at the same time, I'm probably going to move that in to the script.

My next hack on your script is going to be adding NOV "expiration", so I
can run the script over directories like misc.jobs.offered, without
screwing up the NOV file too badly.  NOV sanity would be a command line
option - no point in doing it to control.cancel, after all.

Anyway, thanks for the script.

OS is Digital UNIX (The Operating System Formerly Known As OSF) 4.0b.
Perl is 5.002 (I know, I know, I'll get round to it one of these days!!).
 
> -----Scott.

   -- hugh

 

Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads