[rancid] Ignoring (Boot)Flash Changes (IOS and IOS XE) - Update!

Alan McKinnon alan.mckinnon at gmail.com
Wed Jul 23 15:50:24 UTC 2014


On 23/07/2014 17:29, Mark Tinka wrote:
> On Wednesday, July 23, 2014 05:15:35 PM Alan McKinnon wrote:
> 
>> I made patches to deal with that exact thing. But, I'm no
>> longer employed at the company across the hallway from
>> you so I can't look them up right now.
> 
> That's too bad :-(...
> 
>> I still have
>> friends there though and can call in a favour.
> 
> Always helps :-).
> 
>> While we wait, you can give it a bash ourself, it's real
>> easy. You edit the script "rancid", look up the sub
>> that's run for "show bootflash" and add a check for the
>> stuff to be ignored, something like:
>>
>> next if <some regex>
> 
> -----
> 
> This is what we have:
> 
> sub ShowFlash {
>     # skip if this is 7000, 7200, 7500, or 12000; else we end up with
>     # redundant data from dir /all slot0:
>     print STDERR "    In ShowFlash: $_" if ($debug);
> 
>     while (<INPUT>) {
>         tr/\015//d;
>         last if (/^$prompt/);
>         next if (/^(\s*|\s*$cmd\s*)$/);
>         return(1) if ($type =~ /^(12[40]|7)/);
>         return(1) if ($ios eq "XE");
>         return(1) if (/^\s*\^\s*$/);
>         return(1) if (/Line has invalid autocommand /);
>         return(1) if (/(Invalid (input|command) detected|Type help or )/i);
>         return(-1) if (/command authorization failed/i);
>         # the pager can not be disabled per-session on the PIX
>         if (/^(<-+ More -+>)/) {
>             my($len) = length($1);
>             s/^$1\s{$len}//;
>         }
> 
>         # Filter dhcp database
>         next if (/dhcp_[^. ]*\.txt/);
> 
> #       /\s+(multiple-fs|nv_hdr|vlan\.dat)$/ && next;
>         /\s+(config.text|private-config.text|multiple-fs|nv_hdr|vlan\.dat)$/ && next;
>         ProcessHistory("FLASH","","","!Flash: $_");
>     }
>     ProcessHistory("","","","!\n");
>     return;
> }
> 
> -----
> 
> I hacked it a little, changing:
> 
> 	/\s+(multiple-fs|nv_hdr|vlan\.dat)$/ && next;
> 
> ... to:
> 
> 	/\s+(config.text|private-config.text|multiple-fs|nv_hdr|vlan\.dat)$/ &&
> 
> But couldn't get it to work. That tip said to disable
> commands that run against checking of the file system,
> but that was a couple of RANCID's a go and the script
> has changed a great deal.
> 
> I can estimate what those commands would be for this tip,
> but I'd rather ask here to be sure.
> 
> Mark.
> 


You're on the right track, editing that regex is the way to do it.

Because the Show* subs are used for so many different commands they can
become cluttered if you are not careful. And being perl, there's always
429 ways to do the same thing, including all the varied syntaxes for
different versions of perl. The form

/<regex/ && next;

is I believe the most basic syntax that is sure to work in all perl-5
versions. Just add the file name you want to discard. I can't see why
your hack wouldn't work, unless the filenames are wrong or they aren't
at the very end of the line.

I worked out a more general solution a while back as our NetOps want to
see that the file exists and want to see huge changes in size. So I
converted filesizes to kilo-mega-giga byte form and diffed that. The
noise reduced cconsiderably. Check my postings for the last 3 months,
the subject starts with [PATCH]




-- 
Alan McKinnon
alan.mckinnon at gmail.com



More information about the Rancid-discuss mailing list