Discussion:
[rancid] Re: Rancid Reports Changes in router.db when no changes have been made
Schmidt, Daniel
2009-11-05 22:16:42 UTC
Permalink
What is odd is that this only seems to do this when you rancid-run from
the command line when the previous run was from Cron. (or visa versa)
Relevant code doesn't seem like much:

182 cut -d: -f1,2 routers.db > routers.all.new

189 perl -F: -ane '{($F[0] =~ ***@A-***@a-z@,print "$F[0]:$F[1]\n")
190 if ($F[2] =~ /^up$/i);}' routers.db > routers.up.new

192 diff -u -4 routers.up routers.up.new > /dev/null 2>&1; RUP=$?

194 if [ $RALL -ne 0 -o $RDOWN -ne 0 -o $RUP -ne 0 ]
195 then
196 (
197 if [ $RUP -ne 0 ] ; then
198 if [ ! -s routers.up ] ; then
199 echo Routers changed to up:
200 sed -e 's/^/ /' routers.up.new
201 echo
202 else
203 WCUP=`comm -13 routers.up routers.up.new | wc -l | \
204 sed -e 's/^ *\([^ ]*\)/\1/'`
205 if [ $WCUP -gt 0 ] ; then
206 echo Routers changed to up:

Term is set to network in rancid.conf, so I'm stumped as to how RUP or
WCUP is nonzero on this.
john heasley
2009-11-09 22:26:21 UTC
Permalink
Post by Schmidt, Daniel
What is odd is that this only seems to do this when you rancid-run from
the command line when the previous run was from Cron. (or visa versa)
182 cut -d: -f1,2 routers.db > routers.all.new
190 if ($F[2] =~ /^up$/i);}' routers.db > routers.up.new
192 diff -u -4 routers.up routers.up.new > /dev/null 2>&1; RUP=$?
diff is the typical problem here. verify that the diff that you get
is one that supports these options expressed in this manner. everywhere
but linux, diffs accepts -u4.
Post by Schmidt, Daniel
194 if [ $RALL -ne 0 -o $RDOWN -ne 0 -o $RUP -ne 0 ]
195 then
196 (
197 if [ $RUP -ne 0 ] ; then
198 if [ ! -s routers.up ] ; then
200 sed -e 's/^/ /' routers.up.new
201 echo
202 else
203 WCUP=`comm -13 routers.up routers.up.new | wc -l | \
204 sed -e 's/^ *\([^ ]*\)/\1/'`
205 if [ $WCUP -gt 0 ] ; then
Term is set to network in rancid.conf, so I'm stumped as to how RUP or
WCUP is nonzero on this.
_______________________________________________
Rancid-discuss mailing list
http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
Schmidt, Daniel
2009-11-10 20:57:17 UTC
Permalink
On ubuntu, it should be diff -U 4, which it is. (lines below
accidentally from old control_rancid)

< diff -U 4 routers.up routers.up.new > /dev/null 2>&1; RUP=$?
---
Post by Schmidt, Daniel
diff -u -4 routers.up routers.up.new > /dev/null 2>&1; RUP=$?
***@che-rancid-001:~/var/Telco1$ diff -u -4
diff: `-4' option is obsolete; use `-U 4'
diff: Try `diff --help' for more information.

I can't seem to track this one down.

At the command line:
sed -e '/^#/d' -e 's/^ *//' -e 's/ *$//' -e 's/ *: */:/g' router.db |
sort -u > routers.db
perl -F: -ane '{($F[0] =~ ***@A-***@a-z@,print $_) if ($F[2] !~ /^up$/i);}'
routers.db

Gives me just one device:
FIX_DIFF_BUG:cisco:down

But the old routers.up has every device with the exception of
FIX_DIFF_BUG. Hence, diff spits out a bunch of erroneous garbage about
stuff going up and down. So, the question is, as my routers.all is the
former routers.all:

Why do we get a different routers.all.new depending when called from
command line as opposed to when it is called as a cron job? Is my logic
flawed?

302 mv -f routers.all.new routers.all

-----Original Message-----
From: john heasley [mailto:***@shrubbery.net]
Sent: Monday, November 09, 2009 3:26 PM
To: Schmidt, Daniel
Cc: rancid-***@shrubbery.net
Subject: Re: [rancid] Re: Rancid Reports Changes in router.db when
nochanges have been made
Post by Schmidt, Daniel
What is odd is that this only seems to do this when you rancid-run from
the command line when the previous run was from Cron. (or visa versa)
182 cut -d: -f1,2 routers.db > routers.all.new
190 if ($F[2] =~ /^up$/i);}' routers.db > routers.up.new
192 diff -u -4 routers.up routers.up.new > /dev/null 2>&1; RUP=$?
diff is the typical problem here. verify that the diff that you get
is one that supports these options expressed in this manner. everywhere
but linux, diffs accepts -u4.
Post by Schmidt, Daniel
194 if [ $RALL -ne 0 -o $RDOWN -ne 0 -o $RUP -ne 0 ]
195 then
196 (
197 if [ $RUP -ne 0 ] ; then
198 if [ ! -s routers.up ] ; then
200 sed -e 's/^/ /' routers.up.new
201 echo
202 else
203 WCUP=`comm -13 routers.up routers.up.new | wc -l | \
204 sed -e 's/^ *\([^ ]*\)/\1/'`
205 if [ $WCUP -gt 0 ] ; then
Term is set to network in rancid.conf, so I'm stumped as to how RUP or
WCUP is nonzero on this.
_______________________________________________
Rancid-discuss mailing list
http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
john heasley
2009-11-10 21:47:49 UTC
Permalink
Post by Schmidt, Daniel
On ubuntu, it should be diff -U 4, which it is. (lines below
accidentally from old control_rancid)
< diff -U 4 routers.up routers.up.new > /dev/null 2>&1; RUP=$?
---
Post by Schmidt, Daniel
diff -u -4 routers.up routers.up.new > /dev/null 2>&1; RUP=$?
diff: `-4' option is obsolete; use `-U 4'
diff: Try `diff --help' for more information.
I can't seem to track this one down.
sed -e '/^#/d' -e 's/^ *//' -e 's/ *$//' -e 's/ *: */:/g' router.db |
sort -u > routers.db
routers.db
FIX_DIFF_BUG:cisco:down
But the old routers.up has every device with the exception of
FIX_DIFF_BUG.
which it should, if no others are marked not 'up'
Post by Schmidt, Daniel
Hence, diff spits out a bunch of erroneous garbage about
stuff going up and down.
what?
Post by Schmidt, Daniel
So, the question is, as my routers.all is the
i presume this meant "is the same as".
Post by Schmidt, Daniel
Why do we get a different routers.all.new depending when called from
command line as opposed to when it is called as a cron job? Is my logic
flawed?
what exit code is diff returning in each case? are you getting the same
diff executable? is someone add an environment variable to sort or diff
thats affecting the output and you happen to have that environment
variable set for some completely different reason...or they changed the
manner in which either of those commands work and you now have to set an
environment variable to get the normal behavior?
Post by Schmidt, Daniel
302 mv -f routers.all.new routers.all
-----Original Message-----
Sent: Monday, November 09, 2009 3:26 PM
To: Schmidt, Daniel
Subject: Re: [rancid] Re: Rancid Reports Changes in router.db when
nochanges have been made
Post by Schmidt, Daniel
What is odd is that this only seems to do this when you rancid-run
from
Post by Schmidt, Daniel
the command line when the previous run was from Cron. (or visa versa)
182 cut -d: -f1,2 routers.db > routers.all.new
190 if ($F[2] =~ /^up$/i);}' routers.db > routers.up.new
192 diff -u -4 routers.up routers.up.new > /dev/null 2>&1; RUP=$?
diff is the typical problem here. verify that the diff that you get
is one that supports these options expressed in this manner. everywhere
but linux, diffs accepts -u4.
Post by Schmidt, Daniel
194 if [ $RALL -ne 0 -o $RDOWN -ne 0 -o $RUP -ne 0 ]
195 then
196 (
197 if [ $RUP -ne 0 ] ; then
198 if [ ! -s routers.up ] ; then
200 sed -e 's/^/ /' routers.up.new
201 echo
202 else
203 WCUP=`comm -13 routers.up routers.up.new | wc -l |
\
Post by Schmidt, Daniel
204 sed -e 's/^ *\([^ ]*\)/\1/'`
205 if [ $WCUP -gt 0 ] ; then
Term is set to network in rancid.conf, so I'm stumped as to how RUP or
WCUP is nonzero on this.
_______________________________________________
Rancid-discuss mailing list
http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
Schmidt, Daniel
2009-11-10 22:02:18 UTC
Permalink
Apologies, let's try that again.

The routers.up.new and the routers.up are the ones that strangely differ
depending on whether rancid-run was called via cron, or command line.

The problem does not appear to be with diff. Diff works fine, it
accurately reports there is a difference between routers.up &
routers.up.new. Running said command lines I get just one line:

$ sed -e '/^#/d' -e 's/^ *//' -e 's/ *$//' -e 's/ *: */:/g' router.db |
sort -u > routers.db
$ perl -F: -ane '{($F[0] =~ ***@A-***@a-z@,print $_) if ($F[2] !~
/^up$/i);}' routers.db
FIX_DIFF_BUG:cisco:down
$

However, my routers.up contains everything but FIX_DIFF_BUG for some odd
reason. Diff then accurately reports the files differ greatly.

diff -U 4 routers.up routers.up.new


-----Original Message-----
From: john heasley [mailto:***@shrubbery.net]
Sent: Tuesday, November 10, 2009 2:48 PM
To: Schmidt, Daniel
Cc: john heasley; rancid-***@shrubbery.net
Subject: Re: [rancid] Re: Rancid Reports Changes in router.db
whennochanges have been made
Post by Schmidt, Daniel
On ubuntu, it should be diff -U 4, which it is. (lines below
accidentally from old control_rancid)
< diff -U 4 routers.up routers.up.new > /dev/null 2>&1; RUP=$?
---
Post by Schmidt, Daniel
diff -u -4 routers.up routers.up.new > /dev/null 2>&1; RUP=$?
diff: `-4' option is obsolete; use `-U 4'
diff: Try `diff --help' for more information.
I can't seem to track this one down.
sed -e '/^#/d' -e 's/^ *//' -e 's/ *$//' -e 's/ *: */:/g' router.db |
sort -u > routers.db
/^up$/i);}'
Post by Schmidt, Daniel
routers.db
FIX_DIFF_BUG:cisco:down
But the old routers.up has every device with the exception of
FIX_DIFF_BUG.
which it should, if no others are marked not 'up'
Post by Schmidt, Daniel
Hence, diff spits out a bunch of erroneous garbage about
stuff going up and down.
what?
Post by Schmidt, Daniel
So, the question is, as my routers.all is the
i presume this meant "is the same as".
Post by Schmidt, Daniel
Why do we get a different routers.all.new depending when called from
command line as opposed to when it is called as a cron job? Is my logic
flawed?
what exit code is diff returning in each case? are you getting the same
diff executable? is someone add an environment variable to sort or diff
thats affecting the output and you happen to have that environment
variable set for some completely different reason...or they changed the
manner in which either of those commands work and you now have to set an
environment variable to get the normal behavior?
Post by Schmidt, Daniel
302 mv -f routers.all.new routers.all
-----Original Message-----
Sent: Monday, November 09, 2009 3:26 PM
To: Schmidt, Daniel
Subject: Re: [rancid] Re: Rancid Reports Changes in router.db when
nochanges have been made
Post by Schmidt, Daniel
What is odd is that this only seems to do this when you rancid-run
from
Post by Schmidt, Daniel
the command line when the previous run was from Cron. (or visa versa)
182 cut -d: -f1,2 routers.db > routers.all.new
190 if ($F[2] =~ /^up$/i);}' routers.db > routers.up.new
192 diff -u -4 routers.up routers.up.new > /dev/null 2>&1; RUP=$?
diff is the typical problem here. verify that the diff that you get
is one that supports these options expressed in this manner.
everywhere
Post by Schmidt, Daniel
but linux, diffs accepts -u4.
Post by Schmidt, Daniel
194 if [ $RALL -ne 0 -o $RDOWN -ne 0 -o $RUP -ne 0 ]
195 then
196 (
197 if [ $RUP -ne 0 ] ; then
198 if [ ! -s routers.up ] ; then
200 sed -e 's/^/ /' routers.up.new
201 echo
202 else
203 WCUP=`comm -13 routers.up routers.up.new | wc -l |
\
Post by Schmidt, Daniel
204 sed -e 's/^ *\([^ ]*\)/\1/'`
205 if [ $WCUP -gt 0 ] ; then
Term is set to network in rancid.conf, so I'm stumped as to how RUP or
WCUP is nonzero on this.
_______________________________________________
Rancid-discuss mailing list
http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
Schmidt, Daniel
2009-11-12 22:16:18 UTC
Permalink
For those experiencing this, it turned out to be a locale problem now
addressed in the FAQ. However, right or wrong, I choose to fix it as
such on line 197 of control_rancid:

- sort -u > routers.db
+ tr '[A-Z]' '[a-z]' | sort -u -d > routers.db

Which change will prompt one last change after which it no longer sends
spurious up/down messages.

-----Original Message-----
From: john heasley [mailto:***@shrubbery.net]
Sent: Tuesday, November 10, 2009 2:48 PM
To: Schmidt, Daniel
Cc: john heasley; rancid-***@shrubbery.net
Subject: Re: [rancid] Re: Rancid Reports Changes in router.db
whennochanges have been made
Post by Schmidt, Daniel
On ubuntu, it should be diff -U 4, which it is. (lines below
accidentally from old control_rancid)
< diff -U 4 routers.up routers.up.new > /dev/null 2>&1; RUP=$?
---
Post by Schmidt, Daniel
diff -u -4 routers.up routers.up.new > /dev/null 2>&1; RUP=$?
diff: `-4' option is obsolete; use `-U 4'
diff: Try `diff --help' for more information.
I can't seem to track this one down.
sed -e '/^#/d' -e 's/^ *//' -e 's/ *$//' -e 's/ *: */:/g' router.db |
sort -u > routers.db
/^up$/i);}'
Post by Schmidt, Daniel
routers.db
FIX_DIFF_BUG:cisco:down
But the old routers.up has every device with the exception of
FIX_DIFF_BUG.
which it should, if no others are marked not 'up'
Post by Schmidt, Daniel
Hence, diff spits out a bunch of erroneous garbage about
stuff going up and down.
what?
Post by Schmidt, Daniel
So, the question is, as my routers.all is the
i presume this meant "is the same as".
Post by Schmidt, Daniel
Why do we get a different routers.all.new depending when called from
command line as opposed to when it is called as a cron job? Is my logic
flawed?
what exit code is diff returning in each case? are you getting the same
diff executable? is someone add an environment variable to sort or diff
thats affecting the output and you happen to have that environment
variable set for some completely different reason...or they changed the
manner in which either of those commands work and you now have to set an
environment variable to get the normal behavior?
Post by Schmidt, Daniel
302 mv -f routers.all.new routers.all
-----Original Message-----
Sent: Monday, November 09, 2009 3:26 PM
To: Schmidt, Daniel
Subject: Re: [rancid] Re: Rancid Reports Changes in router.db when
nochanges have been made
Post by Schmidt, Daniel
What is odd is that this only seems to do this when you rancid-run
from
Post by Schmidt, Daniel
the command line when the previous run was from Cron. (or visa versa)
182 cut -d: -f1,2 routers.db > routers.all.new
190 if ($F[2] =~ /^up$/i);}' routers.db > routers.up.new
192 diff -u -4 routers.up routers.up.new > /dev/null 2>&1; RUP=$?
diff is the typical problem here. verify that the diff that you get
is one that supports these options expressed in this manner.
everywhere
Post by Schmidt, Daniel
but linux, diffs accepts -u4.
Post by Schmidt, Daniel
194 if [ $RALL -ne 0 -o $RDOWN -ne 0 -o $RUP -ne 0 ]
195 then
196 (
197 if [ $RUP -ne 0 ] ; then
198 if [ ! -s routers.up ] ; then
200 sed -e 's/^/ /' routers.up.new
201 echo
202 else
203 WCUP=`comm -13 routers.up routers.up.new | wc -l |
\
Post by Schmidt, Daniel
204 sed -e 's/^ *\([^ ]*\)/\1/'`
205 if [ $WCUP -gt 0 ] ; then
Term is set to network in rancid.conf, so I'm stumped as to how RUP or
WCUP is nonzero on this.
_______________________________________________
Rancid-discuss mailing list
http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
Loading...