Discussion:
[rancid] Need Help
Harsha S Aryan
2015-12-17 06:51:19 UTC
Permalink
hi,

below is my rancid config, i am unable to config files of my network device
as attachment in mail

can any one let me know how do i do.

cat /etc/rancid/
rancid.conf .rancid.conf.swp
***@Nagios:~# cat /etc/rancid/rancid.conf
# rancid 2.3.8
# This file sets up the environment used for rancid. see rancid.conf(5)
#
# This will be site specific
#
TERM=network;export TERM
#
# Collating locale
LC_COLLATE="POSIX"; export LC_COLLATE
#
# Create files w/o world read/write/exec permissions, but read/exec
permissions
# for group.
umask 027
#
# Under BASEDIR (i.e.: --localstatedir), there will be a "logs" directory
for
# the logs from rancid and a directory for each group of routers defined in
# LIST_OF_GROUPS (below). In addition to these, there will be a "CVS"
# directory which is the cvs (or Subversion) repository.
#
# Use a full path (no sym-links) for BASEDIR.
#
TMPDIR=/tmp; export TMPDIR
# Be careful changing this, it affects CVSROOT below. It should be a FQPN,
not
# relative.
BASEDIR=/var/lib/rancid; export BASEDIR
PATH=/usr/lib/rancid/bin:/usr/bin:/usr/sbin:/bin:/usr/local/bin:/usr/bin;
export
PATH
# Location of the CVS/SVN repository. Be careful changing this.
# If RCSSYS is svn, this can be:
# - an (absolute) path (a subdirectory of BASEDIR by default).
# - any URL that subversion understands, but beware that:
# - no attempt will be made to create the repository when running
rancid-cvs.
# - authentication credentials, if necessary, MUST be cached (see the SVN
# book, Ch. 3, Network Model, Caching credentials) before
non-interactive
# commands can run, e.g. by running rancid-cvs after installation.
CVSROOT=$BASEDIR/CVS; export CVSROOT
# Location of log files produced by rancid-run(1).
LOGDIR=$BASEDIR/logs; export LOGDIR
#
# Select which RCS system to use, "cvs" (default) or "svn". Do not change
# this after CVSROOT has been created with rancid-cvs. Changing between
these
# requires manual conversions.
RCSSYS=cvs; export RCSSYS
#
# if ACLSORT is NO, access-lists will NOT be sorted.
#ACLSORT=YES; export ACLSORT
#
# if NOPIPE is set, temp files will be used instead of a cmd pipe during
# collection from the router(s).
#NOPIPE=YES; export NOPIPE
#
# FILTER_PWDS determines which passwords are filtered from configs by the
# value set (NO | YES | ALL). see rancid.conf(5).
#FILTER_PWDS=YES; export FILTER_PWDS
#
# if NOCOMMSTR is set, snmp community strings will be stripped from the
configs
#NOCOMMSTR=YES; export NOCOMMSTR
#
# How many times failed collections are retried (for each run) before
# giving up. Minimum: 1
#MAX_ROUNDS=4; export MAX_ROUNDS
#
# How many hours should pass before complaining about routers that
# can not be reached. The value should be greater than the number
# of hours between your rancid-run cron job. Default: 24
#OLDTIME=4; export OLDTIME
#
# How many hours should pass before complaining that a group's collection
# (the age of it's lock file) is hung.
#LOCKTIME=4; export LOCKTIME
#
# The number of devices to collect simultaneously.
#PAR_COUNT=5; export PAR_COUNT
#
# list of rancid groups
#LIST_OF_GROUPS="sl joebobisp"; export LIST_OF_GROUPS
# more groups...
#LIST_OF_GROUPS="$LIST_OF_GROUPS noc billybobisp"; export LIST_OF_GROUPS

LIST_OF_GROUPS="switches"
LIST_OF_GROUPS="routers"

#
# For each group, define a list of people to receive the diffs.
# in sendmail's /etc/aliases.
# rancid-group: joe,***@foo
# rancid-admin-group: hostmaster
# be sure to read ../README regarding aliases.
#
# If your MTA configuration is broken or you want mail to be forwarded to a
# domain not the same as the local one, define that domain here. "@" must
be
# 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
#
# By default, rancid mail is marked with precedence "bulk". This may be
# changed by setting the MAILHEADERS variable; for example no header by
setting
# it to "" or adding X- style headers. Individual headers must be separated
# by a \n.
MAILHEADERS="Precedence: bulk"; export MAILHEADERS
#$SENDMAIL -t $MAILOPTS
--
Rehards,
Harsha
Brian Candler
2015-12-17 09:59:21 UTC
Permalink
Post by Harsha S Aryan
below is my rancid config, i am unable to config files of my network
device as attachment in mail
There is a tested series of steps for making rancid work under Ubuntu
14.04 here:
https://nsrc.org/workshops/2015/wacren-nmm/raw-attachment/wiki/Agenda/rancid-exercise.htm

If you follow those steps, it will work. Or if you get a problem, at
least you can point to exactly the step where it didn't work as expected.

One thing I see wrong in your config is this:

LIST_OF_GROUPS="switches"
LIST_OF_GROUPS="routers"

It's a single setting, so it should be:

LIST_OF_GROUPS="switches routers"

However that doesn't explain any permissions problems you might see. If
you get these you are probably running rancid as the wrong user, or
perhaps you ran rancid once as root, which will break all the
permissions required for it to be able to run as the rancid user
subsequently. If so you may be able to fix this using:

sudo chown -R rancid:rancid /var/lib/rancid

HTH,

Brian.
Harsha S Aryan
2015-12-17 10:04:08 UTC
Permalink
hi,

there is no issue with any permission


i need configuration backup which rancid taken should send me attachment
instead printing in body of the mail

is it possible to discussed with you or any one in skype so that i can
enplane you clearly
Post by Brian Candler
Post by Harsha S Aryan
below is my rancid config, i am unable to config files of my network
device as attachment in mail
There is a tested series of steps for making rancid work under Ubuntu
https://nsrc.org/workshops/2015/wacren-nmm/raw-attachment/wiki/Agenda/rancid-exercise.htm
If you follow those steps, it will work. Or if you get a problem, at least
you can point to exactly the step where it didn't work as expected.
LIST_OF_GROUPS="switches"
LIST_OF_GROUPS="routers"
LIST_OF_GROUPS="switches routers"
However that doesn't explain any permissions problems you might see. If
you get these you are probably running rancid as the wrong user, or perhaps
you ran rancid once as root, which will break all the permissions required
for it to be able to run as the rancid user subsequently. If so you may be
sudo chown -R rancid:rancid /var/lib/rancid
HTH,
Brian.
--
Rehards,
Harsha
Brian Candler
2015-12-17 10:10:04 UTC
Permalink
Post by Harsha S Aryan
i need configuration backup which rancid taken should send me
attachment instead printing in body of the mail
OK, then I can't help you - the code is open source, so find the bit
where it sends the mail, and modify it. You were already given the clue
for this: find where the code uses the SENDMAIL setting.

cd /path/to/rancid/source/code
grep -R SENDMAIL .

Regards,

Brian.
Brian Candler
2015-12-17 10:14:56 UTC
Permalink
Post by Brian Candler
cd /path/to/rancid/source/code
grep -R SENDMAIL .
Actually:

grep -R MAILHEADERS .

works better for me (looks like rancid 2.3.6 doesn't have a SENDMAIL
setting). This will get you to the following bit of code:

# Mail out the diffs (if there are any).
if [ -s $TMP.diff ] ; then
(
echo "To: $mailrcpt"
echo "Subject: $subject"
echo "$MAILHEADERS" | awk '{L = "";LN = $0;while (LN ~ /\\n/)
{ I = index(LN,"\\n");L = L substr(LN,0,I-1) "\n";LN =
substr(LN,I+2,length(LN)-I-1);}print L LN;}'
echo ""
if which diffstat >/dev/null; then
diffstat $TMP.diff
fi
cat $TMP.diff
) | sendmail -t
fi

Regards,

Brian.
heasley
2015-12-17 20:34:27 UTC
Permalink
Post by Brian Candler
Post by Harsha S Aryan
i need configuration backup which rancid taken should send me
attachment instead printing in body of the mail
OK, then I can't help you - the code is open source, so find the bit
where it sends the mail, and modify it. You were already given the clue
for this: find where the code uses the SENDMAIL setting.
cd /path/to/rancid/source/code
grep -R SENDMAIL .
if you use the alpha code, 3.2.99, you can set SENDMAIL in rancid.conf,
as i described in the previous message.

Loading...