[rancid] Limit commands run for GSR

Peter Jackson peterjackson1610 at gmail.com
Thu Jun 20 14:36:02 UTC 2013


Yeah, sorry Alan I wasn't thinking.

I like the looks of 3.0 also but here is workaround for 2.3 that should
work for you if the hostnames of your GSRs are unique - able to be matched
by a regular expression.  I think the only way to do this is with the
hostname since no other information is passed to rancid.  If you can't
match your GSR hostnames by regexp, you could enter them all together.

--- rancid.20130620     2013-06-20 09:53:03.344845839 -0400
+++ rancid      2013-06-20 10:00:50.874896393 -0400
@@ -2333,6 +2333,18 @@
        {'write term'                   => 'WriteTerm'},
 );

+my @commandtable2;
+if ( $host =~ /gsr/ ){    #replace 'gsr' with GSR hostname regexp
+  foreach my $command ( @commandtable ) {
+    foreach my $key ( keys %$command ) {
+      unless ( $key =~ /running-config/ ){    #replace 'running-config'
with a pipe-separated list of commands/command regexps to NOT run
+        push ( @commandtable2 ,( { $key => $command->{$key} } ));
+      }
+    }
+  }
+  @commandtable = @commandtable2;
+}
+
 # Use an array to preserve the order of the commands and a hash for mapping
 # commands to the subroutine and track commands that have been completed.
 @commands = map(keys(%$_), @commandtable);



On Thu, Jun 20, 2013 at 3:28 AM, Alan McKinnon <alan.mckinnon at gmail.com>wrote:

> On 18/06/2013 03:42, Peter Jackson wrote:
> > Check out some of the other command sections that are skipped for
> > certain 'types'.  Figure out the type that rancid sets for the GSRs and
> > use the line below (formatted for the correct type) in the command
> > sections you don't want to run for them.
> >
> > I assume the following would skip 12006, 12010, 12404, 12410, etc.:
> >
> > return(1) if ($type !~ /^12[40]/);
>
>
>
> I think I missed replying to this one, sorry about that.
>
> I don't think that approach will work for me - I don't need to prevent
> rancid parsing the output, I need some commands to not be run on the
> device at all.
>
> That means I'd have to modify @commandtable based on chassis type so
> that clogin doesn't issue certain commands. But I don't know the chassis
> type until clogin has already run and minimally ShowVersion has already
> been parsed. By then it's too late.
>
> 3.0alpha looks like it might be moving in a direction that solves my
> problem quite nicely
>
>
> >
> >
> >
> >
> > On Mon, Jun 17, 2013 at 3:21 PM, Alan McKinnon <alan.mckinnon at gmail.com
> > <mailto:alan.mckinnon at gmail.com>> wrote:
> >
> >     Hi,
> >
> >     Our provider edge runs on GSR 12's and they carry a hefty config.
> NetOps
> >     complain that rancid noticeably spikes the cpu load [1] when it runs
> >     these 4 (essentially the same) commands.
> >
> >     {'more system:running-config'   => 'WriteTerm'},        # ASA/PIX
> >     { running-config view full'=> 'WriteTerm'},        # workaround for
> >     {'show running-config'          => 'WriteTerm'},
> >     {'write term'                   => 'WriteTerm'},
> >
> >     I got it under control easily by forking rancid to a gsrrancid script
> >     and removing the bits I don't want from @commandtable.
> >
> >     I'd rather not do it this way, I'd like to have this in the rancid
> >     parser. But I can't figure a way to modify @commandtable at runtime
> >     based on chassis/OS type.
> >
> >     Ideas?
> >
> >
> >     [1] It's a legit complaint, not a fiction of a NetOps engineer's
> >     imagination. On every other chassis I can ignore the effects rancid
> >     causes, but not these ones. We do things with the 12k most folks
> think
> >     should not be possible :-)
> >
> >     --
> >     Alan McKinnon
> >     alan.mckinnon at gmail.com <mailto:alan.mckinnon at gmail.com>
> >
> >     _______________________________________________
> >     Rancid-discuss mailing list
> >     Rancid-discuss at shrubbery.net <mailto:Rancid-discuss at shrubbery.net>
> >     http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
> >
> >
>
>
> --
> Alan McKinnon
> alan.mckinnon at gmail.com
>
> _______________________________________________
> Rancid-discuss mailing list
> Rancid-discuss at shrubbery.net
> http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.shrubbery.net/pipermail/rancid-discuss/attachments/20130620/451b0702/attachment.html>


More information about the Rancid-discuss mailing list