Monday, December 11, 2017

Rancid tutorial request - ignore minor differences

Hi /r/networking,

It's the end of calendar year and my company really slows down a lot this time a year, leaving me with documentation December... Yep, I'm bored.

I am a long time rancid user, even doing some minor scripting (and some not so minor F5 scripting). Something that has always bugged me is trying to get rancid to ignore differences that I don't really care about like temperature, etc.

I am comfortable tinkering but want to be sure I'm on the right track as there seems to be a few different ways to accomplish this.

Rancid details - v2.3.8 running on CentOS 6.5

Example request - Cisco 2960 records a daily difference in the config.text and private-config.text size (Rancid writes the config on exit) and the flash nvram bytes free.

Because this is a cisco device the file I want to be editing is bin/rancid.

Under the @commandtable section the commands I believe are displaying the changing info are 'ShowFlash' and 'DirSlotN' (dir /all nvram:), so I go to those sub's.

ShowFlash:

# This routine parses "show flash" 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; ProcessHistory("FLASH","","","!Flash: $_"); } ProcessHistory("","","","!\n"); return; } 

In this sub as an example I think I would want to add lines similar to below under the dhcp database filter

 # Filter private-config.text size change next if (/private-config.text/); # Filter config.text size change next if (/config.text/); 

Am I on the right track? Thoughts, comments, stinky socks, etc all welcome



No comments:

Post a Comment