rancid: mail filenames only, set max rounds

Mordechai T. Abzug morty at sled.gsfc.nasa.gov
Thu Apr 21 01:06:33 UTC 2005


The attached patch:

- adds a "MAIL_FILENAME_ONLY" tunable to control whether entire diffs
  are mailed as per the default, or only the filename is mailed.

- adds a "MAX_ROUNDS" tunable to control the maximum number of
  rounds/passes.

This patch is relative to a clean 2.3.1.  It does not change default
behavior.

Thanks!

- Morty
-------------- next part --------------
diff -cr rancid-2.3.1/bin/control_rancid.in rancid-2.3.1-local-p1/bin/control_rancid.in
*** rancid-2.3.1/bin/control_rancid.in	Fri Mar 12 23:13:09 2004
--- rancid-2.3.1-local-p1/bin/control_rancid.in	Thu Apr 21 00:01:53 2005
***************
*** 308,315 ****
  
  # This section will generate a list of missed routers
  # and try to grab them again.  It will run through
! # $pass times.
! pass=4
  round=1
  if [ -f $DIR/routers.up.missed ]; then
      rm -f $DIR/routers.up.missed
--- 308,315 ----
  
  # This section will generate a list of missed routers
  # and try to grab them again.  It will run through
! # $pass times; tune with MAX_ROUNDS, default 4
! pass=${MAX_ROUNDS:=4}
  round=1
  if [ -f $DIR/routers.up.missed ]; then
      rm -f $DIR/routers.up.missed
***************
*** 369,376 ****
  # Diff the directory and then checkin.
  trap 'rm -fr $TMP $TMP.diff $DIR/routers.single;' 1 2 15
  cd $DIR
! cvs -f @DIFF_CMD@ | sed -e '/^RCS file: /d' -e '/^--- /d' \
! 	-e '/^+++ /d' -e 's/^\([-+ ]\)/\1 /' >$TMP.diff
  
  if [ $alt_mailrcpt -eq 1 ] ; then
      subject="router config diffs - courtesy of $mailrcpt"
--- 369,383 ----
  # Diff the directory and then checkin.
  trap 'rm -fr $TMP $TMP.diff $DIR/routers.single;' 1 2 15
  cd $DIR
! mail_filename_only=${MAIL_FILENAME_ONLY:=0}
! if [ "$mail_filename_only" = "0" ]; then
! 	cvs -f @DIFF_CMD@ | sed -e '/^RCS file: /d' -e '/^--- /d' \
! 		-e '/^+++ /d' -e 's/^\([-+ ]\)/\1 /' >$TMP.diff
! else 
! 	cvs -f @DIFF_CMD@ | grep "^Index" | \
! 		sed -e 's/^Index:/Changes found for:/' \
! 		>$TMP.diff
! fi
  
  if [ $alt_mailrcpt -eq 1 ] ; then
      subject="router config diffs - courtesy of $mailrcpt"
diff -cr rancid-2.3.1/etc/rancid.conf.sample.in rancid-2.3.1-local-p1/etc/rancid.conf.sample.in
*** rancid-2.3.1/etc/rancid.conf.sample.in	Sat Mar 13 00:17:50 2004
--- rancid-2.3.1-local-p1/etc/rancid.conf.sample.in	Thu Apr 21 00:01:29 2005
***************
*** 49,54 ****
--- 49,57 ----
  # The number of devices to collect simultaneously.
  #PAR_COUNT=5; export PAR_COUNT
  #
+ # How many times should we try to reach devices?  Minimum: one.
+ #MAX_ROUNDS=4; export MAX_ROUNDS
+ #
  # list of rancid groups
  #LIST_OF_GROUPS="sl joebobisp"
  # more groups...
***************
*** 65,67 ****
--- 68,74 ----
  # included, as this is simply appended to the usual recipients.  It is NOT
  # appended to recipients specified in rancid-run's -m option.
  #MAILDOMAIN="@example.com"; export MAILDOMAIN
+ #
+ # if you don't want to actually email the diffs, just the names of the files
+ # that changed, set the below to 1
+ #MAIL_FILENAME_ONLY=0; export MAIL_FILENAME_ONLY
diff -cr rancid-2.3.1/man/rancid.conf.5.in rancid-2.3.1-local-p1/man/rancid.conf.5.in
*** rancid-2.3.1/man/rancid.conf.5.in	Fri Mar 12 23:13:09 2004
--- rancid-2.3.1-local-p1/man/rancid.conf.5.in	Thu Apr 21 00:00:54 2005
***************
*** 115,120 ****
--- 115,126 ----
  Default: $BASEDIR/logs
  .\"
  .TP
+ .B MAIL_FILENAME_ONLY
+ Control whether diff bodies are mailed or filenames that have changed
+ are mailed.  The default, 0, is diff bodies.  Set to any other value for 
+ filenames only.
+ .\"
+ .TP
  .B MAILDOMAIN
  Define the domain part of addresses for administrative and diff e-mail.
  The value of this variable is simply appended to the normal mail addresses.
***************
*** 123,128 ****
--- 129,139 ----
  had been set to "@example.com".
  .\"
  .TP
+ .B MAX_ROUNDS
+ Defines how many times rancid should use to reach devices.  The minimum is 
+ 1.  The default is 4.
+ .\"
+ .TP
  .B NOCOMMSTR
  If set,
  .IR rancid (1)


More information about the Rancid-discuss mailing list