[rancid] How to ignore certain output?

Alan McKinnon alan.mckinnon at gmail.com
Wed Mar 4 13:52:12 UTC 2015


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


More information about the Rancid-discuss mailing list