Hello!<div><br></div><div>Rancid is great, but there are some situations, when some hosts make too much noise and we can't do anything with that. For example, some Cisco device update their flash too frequent, or some scripts make changes to some ACLs several times a hour. It's too annoying to receive that changes every hour, even if that information has no value. The solution could be simple: just avoid some commands or replace them. I've decided to make a patch for that.</div>
<div><br></div><div>First, we should add some parameters in rancid.conf file:</div><div><div>HOST_REPLACE_CMD=""; export HOST_REPLACE_CMD</div><div>HOST_REPLACE_CMD="$HOST_REPLACE_CMD 10.1.1.1, 'show flash', 'show flash | exclude bootflash',"; export HOST_REPLACE_CMD</div>
<div>HOST_REPLACE_CMD="$HOST_REPLACE_CMD 10.2.2.2, 'show flash', 'show flash | exclude bootflash',"; export HOST_REPLACE_CMD</div><div>HOST_REPLACE_CMD="$HOST_REPLACE_CMD 10.3.3.3, 'more system:running-config', 'more system:running-config | section exclude standard ist$',"; export HOST_REPLACE_CMD</div>
</div><div><br></div><div>That parameters are telling script to replace 'show flash' command for hosts 10.1.1.1 and 10.2.2.2 with 'show flash | exclude bootflash' to scrub bootflash info completely, and replace 'more system:running-config' for host 10.3.3.3 with 'more system:running-config | section exclude standard ist$' to exclude standard access-list with name ist from the resulting file. You should use that replacements with <span class="Apple-style-span" style="font-family: Arial, sans-serif; font-size: 13px; border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "><i style="font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-style: normal; display: inline !important; ">certainty that you will not lose some valuable information.</i></span></div>
<div><span class="Apple-style-span" style="font-family: Arial, sans-serif; font-size: 13px; border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "><i style="font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-style: normal; display: inline !important; "><br>
</i></span></div><div><span class="Apple-style-span" style="font-family: Arial, sans-serif; font-size: 13px; border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "><i style="font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-style: normal; display: inline !important; ">Number of replacements is not limited, just be sure not to skip a comma after last quote in each line (do not place comma after a double quote!).</i></span></div>
<div><span class="Apple-style-span" style="font-family: Arial, sans-serif; font-size: 13px; border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "><i style="font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-style: normal; display: inline !important; "><br>
</i></span></div><div><span class="Apple-style-span" style="font-family: Arial, sans-serif; font-size: 13px; border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "><i style="font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-style: normal; display: inline !important; ">Next, we should apply a patch to rancid file with the name, ahem, 'rancid':</i></span></div>
<div><font class="Apple-style-span" face="Arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">patch</span></font><span class="Apple-style-span" style="font-family: Arial, sans-serif; border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">patch</span><span class="Apple-style-span" style="font-family: Arial, sans-serif; border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">patch</span><span class="Apple-style-span" style="font-family: Arial, sans-serif; border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">patch</span><span class="Apple-style-span" style="font-family: Arial, sans-serif; border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">patch</span><span class="Apple-style-span" style="font-family: Arial, sans-serif; border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">patch</span><span class="Apple-style-span" style="font-family: Arial, sans-serif; border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">patch</span><span class="Apple-style-span" style="font-family: Arial, sans-serif; border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">patch</span><span class="Apple-style-span" style="font-family: Arial, sans-serif; border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">patch</span><span class="Apple-style-span" style="font-family: Arial, sans-serif; border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">patch</span></div>
<div><span class="Apple-style-span" style="font-family: Arial, sans-serif; border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "><br></span></div><div><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; display: inline !important; "><div>
<font class="Apple-style-span" face="Arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">--- rancid.orig<span class="Apple-tab-span" style="white-space: pre; ">        </span>2010-08-05 11:17:24.000000000 +0600</span></font></div>
<div><font class="Apple-style-span" face="Arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">+++ rancid<span class="Apple-tab-span" style="white-space:pre">        </span>2010-09-20 12:50:18.000000000 +0600</span></font></div>
<div><font class="Apple-style-span" face="Arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">@@ -1929,6 +1929,22 @@</span></font></div>
<div><font class="Apple-style-span" face="Arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"> <span class="Apple-tab-span" style="white-space:pre">        </span>{'show running-config'<span class="Apple-tab-span" style="white-space:pre">                </span>=> 'WriteTerm'},</span></font></div>
<div><font class="Apple-style-span" face="Arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"> <span class="Apple-tab-span" style="white-space:pre">        </span>{'write term'<span class="Apple-tab-span" style="white-space:pre">                        </span>=> 'WriteTerm'},</span></font></div>
<div><font class="Apple-style-span" face="Arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"> );</span></font></div>
<div><font class="Apple-style-span" face="Arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">+# Replace commands if host matches</span></font></div>
<div><font class="Apple-style-span" face="Arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">+$host_replace_cmd = $ENV{HOST_REPLACE_CMD};</span></font></div>
<div><font class="Apple-style-span" face="Arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">+@commandreplace = ();</span></font></div>
<div><font class="Apple-style-span" face="Arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">+push(@commandreplace, $+) while $host_replace_cmd =~ m{'(.*?)'|(\S+),\s*}g;</span></font></div>
<div><font class="Apple-style-span" face="Arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">+$cr_length = $#commandreplace;</span></font></div>
<div><font class="Apple-style-span" face="Arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">+for($i = 0; $i <= $cr_length; $i = $i + 3) {</span></font></div>
<div><font class="Apple-style-span" face="Arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">+<span class="Apple-tab-span" style="white-space:pre">        </span>my $cr_host = $commandreplace[$i];</span></font></div>
<div><font class="Apple-style-span" face="Arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">+<span class="Apple-tab-span" style="white-space:pre">        </span>if ($host eq $cr_host) {</span></font></div>
<div><font class="Apple-style-span" face="Arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">+<span class="Apple-tab-span" style="white-space:pre">                </span>my $cr_cmdsearch = $commandreplace[$i + 1];</span></font></div>
<div><font class="Apple-style-span" face="Arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">+<span class="Apple-tab-span" style="white-space:pre">                </span>my $cr_cmdreplace = $commandreplace[$i + 2];</span></font></div>
<div><font class="Apple-style-span" face="Arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">+<span class="Apple-tab-span" style="white-space:pre">                </span>my ($index) = grep { defined $commandtable[$_]{$cr_cmdsearch} } 0..$#commandtable;</span></font></div>
<div><font class="Apple-style-span" face="Arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">+<span class="Apple-tab-span" style="white-space:pre">                </span>my $cr_function = $commandtable[$index]{$cr_cmdsearch};</span></font></div>
<div><font class="Apple-style-span" face="Arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">+<span class="Apple-tab-span" style="white-space:pre">                </span>splice(@commandtable, $index, 1, {$cr_cmdreplace => $cr_function});</span></font></div>
<div><font class="Apple-style-span" face="Arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">+<span class="Apple-tab-span" style="white-space:pre">        </span>}</span></font></div>
<div><font class="Apple-style-span" face="Arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">+}</span></font></div>
<div><font class="Apple-style-span" face="Arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">+</span></font></div>
<div><font class="Apple-style-span" face="Arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"> # Use an array to preserve the order of the commands and a hash for mapping</span></font></div>
<div><font class="Apple-style-span" face="Arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"> # commands to the subroutine and track commands that have been completed.</span></font></div>
<div><font class="Apple-style-span" face="Arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"> @commands = map(keys(%$_), @commandtable);</span></font></div>
<div style="border-collapse: collapse; font-family: Arial, sans-serif; font-size: 13px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-style: italic; "><br></div><div style="border-collapse: collapse; font-family: Arial, sans-serif; font-size: 13px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-style: italic; ">
<span class="Apple-style-span" style="border-collapse: separate; font-family: arial; font-style: normal; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; font-size: small; "><font class="Apple-style-span" face="Arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">patch</span></font><span class="Apple-style-span" style="font-family: Arial, sans-serif; border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">patch</span><span class="Apple-style-span" style="font-family: Arial, sans-serif; border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">patch</span><span class="Apple-style-span" style="font-family: Arial, sans-serif; border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">patch</span><span class="Apple-style-span" style="font-family: Arial, sans-serif; border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">patch</span><span class="Apple-style-span" style="font-family: Arial, sans-serif; border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">patch</span><span class="Apple-style-span" style="font-family: Arial, sans-serif; border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">patch</span><span class="Apple-style-span" style="font-family: Arial, sans-serif; border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">patch</span><span class="Apple-style-span" style="font-family: Arial, sans-serif; border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">patch</span><span class="Apple-style-span" style="font-family: Arial, sans-serif; border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">patch</span></span></div>
<div style="border-collapse: collapse; font-family: Arial, sans-serif; font-size: 13px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-style: italic; "><span class="Apple-style-span" style="border-collapse: separate; font-family: arial; font-style: normal; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; font-size: small; "><span class="Apple-style-span" style="font-family: Arial, sans-serif; border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "><br>
</span></span></div><div style="border-collapse: collapse; font-family: Arial, sans-serif; font-size: 13px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-style: italic; "><span class="Apple-style-span" style="border-collapse: separate; font-family: arial; font-style: normal; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; font-size: small; "><span class="Apple-style-span" style="font-family: Arial, sans-serif; border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">Check that everything's working fine by running "rancid -d hostname" and checking it's output. I would be glad if this patch or some similar logic will be in the next release of rancid.</span></span></div>
</span></div>