[news.admin] Limiting batch size

smith@ncoast.UUCP (Phil Smith) (05/01/87)

I know that the batchs can be limited to whatever size you choose.
My question is to whether the total size of all the batchs can be
limited. I seem to remember an older version of batching allowed
this, so only the amount that could be transmitted for sure in
a limited time frame would be batched. The remaining files to be
batched would be batched the following day/week. I can't seem to find
an option like this under 2.11 batching.
-- 
		      decvax!cwruecmp!ncoast!smith
		    ncoast is dead, long live ncoast!
			ncoast!smith@case.csnet 
		(ncoast!smith%case.csnet@csnet-relay.ARPA)

greg@ncr-sd.UUCP (05/07/87)

In article <2452@ncoast.UUCP> smith@ncoast.UUCP (Phil Smith) writes:
>My question is to whether the total size of all the batchs [sic] can be
>limited. I seem to remember an older version of batching allowed
>this ....

I suspect that you are refering to the "batcher" script that I wrote,
which will only generate ten batches at a time for a remote site and
then only if if the UUCP status of that site indicates that it is safe
to do so.  It was intended to limit the amount of space my UUCP spool
directories would take, so that my spool file system would not overflow.
(At that time, I only had a margin of five megabytes; if a single feed
went down for a day, I would quickly run out.)

The script was included in the "misc" subdirectory of the news 2.11
distribution; that version was actually for news 2.10.2, so it had
limited utility for 2.11 users.  Since then, I have revised it and
expanded its capabilities.  Since it is small, I will attach it below.

Enjoy!

-- Greg Noel, NCR Rancho Bernardo     Greg.Noel@SanDiego.NCR.COM

:	shar:	Shell Archiver
# Run this text with /bin/sh to create:
#	batcher
sed 's/^X//' <<'SHAR_EOF' >batcher; chmod 644 batcher
X: batcher to send news to remote sites.
X
X# This script looks in $BATCH for files of the form x.sitename and sends news
X# to sitename with options based upon the prefix ('x').  The major advantage of
X# this script is that all the decisions about delivery are located in the sys
X# file and not in cron scripts, making it much easier to add/delete sites or
X# to change from one form of service to another.  The current prefixes are:
X#	b - send batched news during non-backbone cycles
X#	B - send batched news during every cycle (not used)
X#	c - send batched/compressed news during non-backbone cycles
X#	C - send batched/compressed news every cycle
X#	a - send news created by the specification in $NEWS/cmds
X#	D - send batched/compressed news every cycle with UUCP reply requested
X#	i - send "ihave" info during non-backbone cycles (FUTURE)
X#	I - send "ihave" info every cycle (FUTURE)
X#	o - send old-format batched/compressed news during non-backbone cycles
X#	O - send old-format batched/compressed news during every cycle
X# This script is normally invoked hourly.  During the day, it is executed with
X# the parameter "BACKBONE" and only sends news to selected sites.  The rest of
X# the time, it is executed with no arguments and sends news to all sites.  The
X# script may also be executed with a list of sitenames as arguments; in that
X# case, news is sent only to the specified sites.  A sample crontab entry for
X# the news user under System V:
X# 56	8-16	*	*	1-5	exec sh /usr/lib/news/batcher BACKBONE
X# 56	17-23,0-7 *	*	1-5	. /usr/lib/news/batcher	# daily
X# 56	*	*	*	0,6	. /usr/lib/news/batcher	# weekends
X# This sends news to "backbone" sites every hour and to all sites at night and
X# all day on the weekends.  ("Backbone" sites are really those sites to which,
X# for various reasons, you want to send news all the time.  In our case, these
X# include not only major news feeds so as to keep the news flowing, but also
X# a number of sites that need the cycles during the day.)
X
Xeval `grep TZ= /etc/profile`
XNEWS=/usr/lib/news	BATCH=/usr/spool/batch
XPATH=$NEWS:/bin:/usr/bin export PATH
X
Xif test -d /usr/spool/uucp/.Status	# Is this HDB UUCP?
Xthen	SCHED="/usr/lib/uucp/uusched"
X	STATUS="/usr/spool/uucp/.Status/"
X	NAMELEN=..............
X	GRADE="-g T"
Xelse					# Assume SysV UUCP
X	SCHED="/usr/lib/uucp/uucico -r1"
X	STATUS="/usr/spool/uucp/STST."
X	NAMELEN=......
X	GRADE=""
Xfi
X# TODO  Add a case to handle UCB UUCP.
X
Xcase $# in
X0)	Files="-name [BCDIOabcio].*" ;;
X1)	case "$1" in
X	BACKBONE) Files="-name [BCDIO].*" ;;
X	*)	Files="-name [BCDIOabcio].$1*" ;;
X	esac ;;
X*)	Files="( -name [BCDIOabcio].$1*"
X	shift
X	for file do Files="$Files -o -name [BCDIOabcio].$file*"; done
X	Files="$Files )" ;;
Xesac
X
Xfor rmt in `find $BATCH -type f $Files -print`
Xdo	case $rmt in
X	*.cmd)	continue ;;
X	*.tmp)	continue ;;
X	*.work)	rmt=`expr $rmt : "\(.*\).work"`
X		if test -f $rmt; then continue; fi ;;
X	esac
X	site=`expr $rmt : ".*/[BCDIOabcio].\(.*\)"`
X	site=`expr $site : "\($NAMELEN\)" \| $site`
X	XMIT='' rnews=rnews
X	case $rmt in
X
X	*/a.*)	# For special cases -- look in NEWS/cmds for batching command
X		CMD=`sed -n "s/^$site://p" $NEWS/cmds`
X		case "$CMD" in "") echo "OOPS -- no command for $site"
X			CMD="batch $rmt 60000" ;;
X		esac ;;
X
X	*/[Bb].*) # Batching, but no compression, to rnews
X		CMD="batch $rmt 60000" ;;
X
X	*/[Cc].*) # Batching and compression to rnews
X		CMD="(echo '#! cunbatch'; batch $rmt 100000 | compress -q)" ;;
X
X	*/[Ii].*) # Future expansion for ihave/sendme
X		;;
X
X	# OLD -- Retrofit for news versions prior to 2.11
X	*/[Oo].*) # Batching and compression to cunbatch
X		CMD="batch $rmt 100000 | compress -q" rnews=cunbatch ;;
X
X	*/D.*)	# Debugging compressed feeds -- reply option set
X		CMD="(echo '#! cunbatch'; batch $rmt 100000 | compress -q)"
X		XMIT="uux - $GRADE -r $site!$rnews"
X		;;
X
X	*)	# This should never happen......
X		echo "OOPS -- matched illegal file type!"; continue ;;
X
X	esac
X	case "$XMIT" in "") XMIT=`sed -n "s/^$site>//p" $NEWS/cmds` ;; esac
X	case "$XMIT" in "") XMIT="uux - $GRADE -r -n $site!$rnews" ;; esac
X	CMD="$CMD | $XMIT"
X
X	if test -f $STATUS$site
X	then	if test ! -s $STATUS$site
X		then	continue	# Hmmmm....  Info file is null
X		fi
X		read <$STATUS$site status garbage
X		case $status in
X		0)	flag=yes ;;	# last call successfull
X		3)	flag=no ;;	# already talking
X		*)	continue ;;	# funny state -- don't queue up stuff
X		esac
X	else	flag=yes	# start conversation first time through
X	fi
X
X	# Send a maximum of ten batches to remote site
X	loops=x
X	while test -s $rmt -o -s $rmt.work
X	do	eval 2>/dev/null $CMD
X		if test $? -ne 0 -o $loops = xxxxxxxxxx; then break; fi
X		case $flag in yes) eval exec $SCHED & ;; esac
X		flag=no loops=x$loops
X	done
Xdone
SHAR_EOF
exit 0
-- 
-- Greg Noel, NCR Rancho Bernardo     Greg.Noel@SanDiego.NCR.COM