[rancid] How to ignore certain output?

Matt Almgren malmgren at skyfire.com
Wed Mar 4 15:44:12 UTC 2015


Thanks Alan and Heasley!

 -- Matt

________________________________________
From: Rancid-discuss [rancid-discuss-bounces at shrubbery.net] On Behalf Of Alan McKinnon [alan.mckinnon at gmail.com]
Sent: Wednesday, March 04, 2015 5:52 AM
To: rancid-discuss at shrubbery.net
Subject: Re: [rancid] How to ignore certain output?

On Tue, 3 Mar 2015 20:33:07 -0800
Matt Almgren <malmgren at skyfire.com> wrote:

> I've seen this question pass through this list a couple times, but I
> wasn't paying attention.
>
> I have this output from our f5 that rancid sees and is checking in
> the changes.  The monitor state up and down is usually alternating
> (QA environment), so I'd like to ignore that line:
>
> Index: configs/sca-qa-lb001
> ===================================================================
> - -- configs/sca-qa-lb001       (revision 7756)
> @@ -398,13 +398,13 @@
>   #       }
>   #       10.102.72.122:4241 {
>   #          node type pool member t
> - #          monitor state down
> + #          monitor state up
>   #          enable
>   #          inband inst disable
>   #       }
>   #       10.102.72.122:4243 {
>   #          node type pool member t
> - #          monitor state down
> + #          monitor state up
>   #          enable
>   #          inband inst disable
>   #       }
> Index: configs/sca-qa-lb002
> ===================================================================
>
> How and where do I configure rancid to ignore the lines that have
> "monitor state" in them?

heasley gave the exact patch you need lower donw in the thread, but
I'll explain the general process, you need some basic understanding of
perl. This is for 2.3, I haven't gotten around to using 3.x yet, I
beleive the latest version is quite similar in this respect:

You have to edit the script that does the actual parsing of the output
from the device, and tell it there what to ignore.

In the case of Cisco IOS devices, that script is "rancid", for your
F5's it will be "f5rancid". In any event, look in rancid_fe to find
which script is called for which device type in router.db

Inside that script, you will usually find an array
"@command_table" [1], this maps commands run on the device to
subroutines in the script that deal with that command.

Now edit that subroutine to throw away the lines you are not interested
in. Taking heasley's example:

        /^\s+monitor state (\S+)/ && next;

which means "if this line matches the regex, then skip it and go onto
the next one".

If you need something slightly more complex (eg the stuff you want to
ignore is the first line plus a bunch more), then you must write
slightly more complex perl. But it's all very easy and obvious and the
code has hundreds of examples you can follow.


[1] not all parser scripts do it this way, the author is free to wite
their code any way they feel like. "rancid" is the original and first,
so most new parsers follow the same template. If you are using a parser
that doesn't, then you must read the code and figure it out.


--
alan dot mckinnon at gmail dot com
_______________________________________________
Rancid-discuss mailing list
Rancid-discuss at shrubbery.net
http://www.shrubbery.net/mailman/listinfo/rancid-discuss

This message is being sent by Skyfire Labs, Inc.  It is intended exclusively for the individuals and entities to which it is addressed.  This communication, including any attachments, may contain information that is proprietary, privileged, confidential, or otherwise subject to restrictions on disclosure pursuant to applicable law.  If you are not the named addressee, you are not authorized to read, print, retain copy or disseminate this message or any part of it.  If you have received this message in error, please notify the sender immediately by email and delete all copies of this message.  This message is protected by applicable legal privileges and is confidential.


More information about the Rancid-discuss mailing list