Discussion:
[rancid] excluding output from cisco routers and switches
allonon
2016-01-04 20:16:33 UTC
Permalink
I wanted to start a different topic as mine is not about flash or bootflash.

I have a similar issue with nexus output and want to prevent diff emails
but I want the data in the the saved config. One of switches will
constantly adjust output watts by a few points.


!Env: ------- ------------------- ---------- ---------- ----------
--------------
- !Env: 1 N9K-PAC-650W-B 67 W 649 W
Ok
- !Env: 2 N9K-PAC-650W-B 71 W 649 W
Ok
+ !Env: 1 N9K-PAC-650W-B 68 W 649 W
Ok
+ !Env: 2 N9K-PAC-650W-B 70 W 649 W
Ok


My scripting-fu is non-existent and am trying to learn this.

I figure I have 3 options.
Just have Rancid ignore the line. (not preferred as I want to see the
PS as OK or not)
Filter email output.
Filter the actual diff. (can the diff actually handle advanced
parsing? Everything I see shows how to ignore line based on simple match)

I found this snippet from another thread on how to filter email output but
I'm getting lost on what it is doing after the first grep
DIFF=`cat $TMP.diff | grep -v "^===" | grep -v "^diff " | grep -v
"^Index: " | grep -v "^retrieving revision" | grep -v "^$"`
if [ -n "$DIFF" ]; then
...email stuff here...
fi
How do I best adjust this so that it greps for the ENV or N9K-PAC line, and
ignore (not send diff email) it if the Ok is there.

Thanks
Nick Hilliard
2016-01-04 20:42:47 UTC
Permalink
Post by allonon
My scripting-fu is non-existent and am trying to learn this.
You don't need to learn this. Upgrade to Rancid 3.x and edit out the
relevant bit of /etc/rancid/rancid.types.base.

Nick
Brian Candler
2016-01-04 21:09:26 UTC
Permalink
Post by allonon
How do I best adjust this so that it greps for the ENV or N9K-PAC
line, and ignore (not send diff email) it if the Ok is there.
Maybe copy the code which blanks out passwords (look where it calls
ProcessHistory)
rdrake
2016-01-05 00:32:29 UTC
Permalink
Post by allonon
I wanted to start a different topic as mine is not about flash or bootflash.
I have a similar issue with nexus output and want to prevent diff
emails but I want the data in the the saved config. One of switches
will constantly adjust output watts by a few points.
!Env: ------- ------------------- ---------- ----------
---------- --------------
- !Env: 1 N9K-PAC-650W-B 67 W 649 W Ok
- !Env: 2 N9K-PAC-650W-B 71 W 649 W Ok
+ !Env: 1 N9K-PAC-650W-B 68 W 649 W Ok
+ !Env: 2 N9K-PAC-650W-B 70 W 649 W Ok
My scripting-fu is non-existent and am trying to learn this.
I figure I have 3 options.
Just have Rancid ignore the line. (not preferred as I want to see
the PS as OK or not)
Filter email output.
Filter the actual diff. (can the diff actually handle advanced
parsing? Everything I see shows how to ignore line based on simple match)
I found this snippet from another thread on how to filter email output
but I'm getting lost on what it is doing after the first grep
DIFF=`cat $TMP.diff | grep -v "^===" | grep -v "^diff " | grep -v
"^Index: " | grep -v "^retrieving revision" | grep -v "^$"`
if [ -n "$DIFF" ]; then
...email stuff here...
fi
How do I best adjust this so that it greps for the ENV or N9K-PAC
line, and ignore (not send diff email) it if the Ok is there.
Thanks
The multiple greps in that example are for different commands they want
to match and exclude. You can do something like this:

DIFF=`cat $TMP.diff | grep -Ev "[ +-] \!Env: [0-9]"`

You can test if your regex is working by making a fake diff and seeing
if the grep matches :
[***@test ~]$ cat test.in | grep -E "[ +-] \!Env: [0-9]"
- !Env: 1 N9K-PAC-650W-B 67 W 649 W Ok
- !Env: 2 N9K-PAC-650W-B 71 W 649 W Ok
+ !Env: 1 N9K-PAC-650W-B 68 W 649 W Ok
+ !Env: 2 N9K-PAC-650W-B 70 W 649 W Ok

[***@test ~]$ cat test.in | grep -Ev "[ +-] \!Env: [0-9]"
!Env: ------- ------------------- ---------- ----------
---------- --------------

(if you want to get rid of this line too you can use this)

[***@test ~]$ cat test.in | grep -Ev "[ +-] \!Env: [0-9-]"
[***@test ~]$
allonon
2016-01-06 05:23:20 UTC
Permalink
With further digging, I found out that part of this code to remove the
fluctuating wattage is in the nxos.pm module but the code is based on a
different output than what I am getting from our Nexus hardware.

So now to figure out how the existing code is actually stripping the
wattage and adjust it for my output
Post by rdrake
Post by allonon
I wanted to start a different topic as mine is not about flash or bootflash.
I have a similar issue with nexus output and want to prevent diff
emails but I want the data in the the saved config. One of switches
will constantly adjust output watts by a few points.
!Env: ------- ------------------- ---------- ----------
---------- --------------
- !Env: 1 N9K-PAC-650W-B 67 W 649 W Ok
- !Env: 2 N9K-PAC-650W-B 71 W 649 W Ok
+ !Env: 1 N9K-PAC-650W-B 68 W 649 W Ok
+ !Env: 2 N9K-PAC-650W-B 70 W 649 W Ok
The multiple greps in that example are for different commands they want
DIFF=`cat $TMP.diff | grep -Ev "[ +-] \!Env: [0-9]"`
You can test if your regex is working by making a fake diff and seeing
- !Env: 1 N9K-PAC-650W-B 67 W 649 W Ok
- !Env: 2 N9K-PAC-650W-B 71 W 649 W Ok
+ !Env: 1 N9K-PAC-650W-B 68 W 649 W Ok
+ !Env: 2 N9K-PAC-650W-B 70 W 649 W Ok
!Env: ------- ------------------- ---------- ----------
---------- --------------
(if you want to get rid of this line too you can use this)
_______________________________________________
Rancid-discuss mailing list
http://www.shrubbery.net/mailman/listinfo/rancid-discuss
Loading...