[news.admin] considerbatch - news batching disk space limiter

karl@sugar.uu.net (Karl Lehenbauer) (01/29/89)

For sites running HoneyDanBer uucp that batch unique newsfeeds up for
other sites, considerbatch can be used in your news crontab instead
of sendbatch in order to limit the amount of queued-but-undelivered
data for a site.

Considerbatch simply refuses to run sendbatch on batched-but-not-queued
articles if the amount of stuff already queued for the site exeeds a limit,
500 blocks as distributed below.  Sunsequently, when enough pending stuff has 
been delivered, considerbatch will start batching articles again -- no pending 
articles should be lost in the process, unless your system begins expiring 
articles before it gets a chance to batch them to the sites it feeds.

This keeps your spool space from being eaten up if a site you're feeding 
doesn't manage to call in for a while.

Caveat user.  Edit to taste.

------------------------------ cut here ------------------------------
:
# considerbatch - consider whether or not to batch up pending articles
#  for a site and do so only if there's not a lot of stuff already
# queued that hasn't been picked up, v0.0a
#
# usage:
#	place "considerbatch sitename" lines in your news crontab
#	for each site you want considerbatch to do the batching
#	for
#
# if less than MAXBLOCKS are present in /usr/spool/uucp/sitename, does
# a 'sendbatch -c sitename' else sends mail to MAILWHOM saying it
# didn't send and why.
#
# Assumes HoneyDanBer uucp -- needs to be changed for old-style uucp
# Also, it has only tested on System V/386
#
MAILWHOM=news
PATH=$PATH:/usr/local/bin
SPOOLDIR=/usr/spool/uucp/$1
MAXBLOCKS=500
# if the spool directory exists then if du of that space
# is greater than some limit, doesn't do the batches else it does
if test -d $SPOOLDIR
then
# there's a tab in the substitute command in the sed on the next line
SPACEUSED=`cd $SPOOLDIR;du | sed -e 's/	.*//'`
 if test $SPACEUSED -gt $MAXBLOCKS
 then
  echo "I can't consider $1 for batching, there're $SPACEUSED blocks\nin its spool directory already." | mail -s "considerbatch: news batch limit exceeded for $1" $MAILWHOM
  exit 1
 fi
fi
 /usr/lib/news/sendbatch -c $1
exit 0
-- 
-- uunet!sugar!karl  | "We've been following your progress with considerable 
-- karl@sugar.uu.net |  interest, not to say contempt."  -- Zaphod Beeblebrox IV
-- Usenet BBS (713) 438-5018

eric@snark.uu.net (Eric S. Raymond) (01/31/89)

In article <3360@sugar.uu.net>, karl@sugar.uu.net (Karl Lehenbauer) writes:
> For sites running HoneyDanBer uucp that batch unique newsfeeds up for other
> sites, considerbatch can be used in your news crontab instead of sendbatch
> in order to limit the amount of queued-but-undelivered data for a site.

TMN-netnews has a 'Q' option to sendbatch that lets you set this check on
a per-feed basis, with (potentially) different minimum-free-block levels for
each feed.
-- 
      Eric S. Raymond                     (the mad mastermind of TMN-Netnews)
      Email: eric@snark.uu.net                       CompuServe: [72037,2306]
      Post: 22 S. Warren Avenue, Malvern, PA 19355      Phone: (215)-296-5718

dhesi@bsu-cs.UUCP (Rahul Dhesi) (02/01/89)

In article <3360@sugar.uu.net> karl@sugar.uu.net (Karl Lehenbauer) writes:
>Considerbatch simply refuses to run sendbatch on batched-but-not-queued
>articles if the amount of stuff already queued for the site exeeds a limit...

That was for HDB.  Here's my code for sendbatch under 4.3BSD.  At the
beginning of sendbatch define MAXPENDING to be the limit of the number
of bytes of pending output per site.  Modify code near the end of
sendbatch as follows:

       if test -n "$DOIHAVE" -a -s /usr/spool/batch/$rmt.ihave
       then
          ... something ...
       else
            pending=`uuq -l | fgrep ${rmt}: | awk '{print $4}'`
            if test "$pending" -gt $MAXPENDING
            then
               echo "sendbatch exiting -- too much uucp pending for $rmt"
               exit 1
            fi
            (eval $ECHO; eval $CMD $COMP $C7) |
            if test -s /usr/spool/batch/$rmt.cmd
            then
                 /usr/spool/batch/$rmt.cmd
            else
                 uux - -r -z -n -gd $rmt!$RNEWS
            fi
       fi
-- 
Rahul Dhesi         UUCP:  <backbones>!{iuvax,pur-ee}!bsu-cs!dhesi
                    ARPA:  bsu-cs!dhesi@iuvax.cs.indiana.edu