<div dir="ltr">----<div><span style="font-family:arial,sans-serif;font-size:13px">It's an iterative process where you tweak your subs and regular</span><br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px">expressions until you get the output you want.</span><br style="font-family:arial,sans-serif;font-size:13px">
<br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px">Running rancid-run repeatedly puts strain on your routers though, so use</span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px">a short cut:</span><br style="font-family:arial,sans-serif;font-size:13px"><br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px">jrancid -d    gives the jlogin command to use</span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px">use that and save the output to a file</span><br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px">use the file as input to jrancid -f</span><br style="font-family:arial,sans-serif;font-size:13px">
<br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px">Now you can run it as many times as you like without hitting the network</span></div><div><font face="arial, sans-serif">----</font></div>
<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">That's what I was looking for, I glossed over that when reading around.</font></div><div><font face="arial, sans-serif"><br></font></div>
<div><font face="arial, sans-serif">Appreciate the time and insight Alan.<br></font><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Sep 18, 2013 at 1:12 AM, Alan McKinnon <span dir="ltr"><<a href="mailto:alan.mckinnon@gmail.com" target="_blank">alan.mckinnon@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">It's an iterative process where you tweak your subs and regular<br>

expressions until you get the output you want.<br>
<br>
Running rancid-run repeatedly puts strain on your routers though, so use<br>
a short cut:<br>
<br>
jrancid -d    gives the jlogin command to use<br>
use that and save the output to a file<br>
use the file as input to jrancid -f<br>
<br>
Now you can run it as many times as you like without hitting the network<br>
<br>
As for writing subs,<br>
<br>
add the command to @commandtable with the literal command as a key and a<br>
suitably named sub as the value. The subs all follow this pattern:<br>
<br>
 # This routine parses "show chassis environment"<br>
sub ShowChassisEnvironment {<br>
    print STDERR "    In ShowChassisEnvironment: $_" if ($debug);<br>
    s/^[a-z]+@//;<br>
    ProcessHistory("","","","# $_");<br>
    while (<INPUT>) {<br>
        tr/\015//d;<br>
        last if (/^$prompt/);<br>
                               <= regex magic goes here<br>
    }<br>
    return(0);<br>
}<br>
<br>
<br>
For me the hard part was figuring out how ProcessHistory() works -<br>
specifically what the arguments do. They just mark the output off in<br>
section and classify chunks of output that goes together. Change values<br>
around and runt he code to observe what they do. It's hard to express<br>
briefly in English so I'm not gonna try ;-)<br>
<div class="im"><br>
<br>
<br>
On 18/09/2013 02:36, Jason Biel wrote:<br>
> Understood, but even when in a dev environment, what is the best way to<br>
> test changes to file for added commands?  For example, I want to add new<br>
> commands to jrancid, but I am not 100% sure on the sub routine<br>
> configuration for parsing output. I suppose I can make the changes, use<br>
> rancid-run, and just keep tweaking until the output in the configs/<br>
> directory is what I want<br>
><br>
> I'm trying to mentally build out a process of adding commands for the<br>
> different devices we use without just shotgunning it.<br>
><br>
><br>
> On Tue, Sep 17, 2013 at 9:34 AM, Alan McKinnon <<a href="mailto:alan.mckinnon@gmail.com">alan.mckinnon@gmail.com</a><br>
</div><div class="im">> <mailto:<a href="mailto:alan.mckinnon@gmail.com">alan.mckinnon@gmail.com</a>>> wrote:<br>
><br>
>     On 17/09/2013 13:00, Jason Biel wrote:<br>
>     > While I understand the basics of adding additional commands to RANCID,<br>
>     > what is the ideal way to be testing new commands as I am debugging<br>
>     > them?  Are most people running a dev RANCID install for testing?<br>
><br>
>     Most definitely :-)<br>
><br>
>     In any kind of real-life scenario, your rancid data in configs/<br>
>     naturally evolves into a very critical data source. Almost nothing else<br>
>     out there is capable of documenting real life systems to the extent<br>
>     rancid can. This is great for your ego, but also means you can't fiddle<br>
>     with it so much.<br>
><br>
>     I keep 2 dev installs for different purposes and follow the classic<br>
>     dev/test/debug/deploy strategy.<br>
><br>
>     There's a second reason why this is a good idea - it is very common for<br>
>     sysadmins to maintain their own little patchset to customize rancid<br>
>     behaviour (mostly to account for quirks between device models) and then<br>
>     repatch new releases if your tweaks didn't make it into the codebase. A<br>
>     dev setup makes this process so much easier.<br>
><br>
><br>
>     --<br>
>     --<br>
>     Alan McKinnon<br>
</div>>     <a href="mailto:alan.mckinnon@gmail.com">alan.mckinnon@gmail.com</a> <mailto:<a href="mailto:alan.mckinnon@gmail.com">alan.mckinnon@gmail.com</a>><br>
><br>
>     _______________________________________________<br>
>     Rancid-discuss mailing list<br>
>     <a href="mailto:Rancid-discuss@shrubbery.net">Rancid-discuss@shrubbery.net</a> <mailto:<a href="mailto:Rancid-discuss@shrubbery.net">Rancid-discuss@shrubbery.net</a>><br>
<div class=""><div class="h5">>     <a href="http://www.shrubbery.net/mailman/listinfo/rancid-discuss" target="_blank">http://www.shrubbery.net/mailman/listinfo/rancid-discuss</a><br>
><br>
><br>
><br>
><br>
> --<br>
> Jason<br>
><br>
><br>
> _______________________________________________<br>
> Rancid-discuss mailing list<br>
> <a href="mailto:Rancid-discuss@shrubbery.net">Rancid-discuss@shrubbery.net</a><br>
> <a href="http://www.shrubbery.net/mailman/listinfo/rancid-discuss" target="_blank">http://www.shrubbery.net/mailman/listinfo/rancid-discuss</a><br>
><br>
<br>
<br>
--<br>
Alan McKinnon<br>
<a href="mailto:alan.mckinnon@gmail.com">alan.mckinnon@gmail.com</a><br>
<br>
_______________________________________________<br>
Rancid-discuss mailing list<br>
<a href="mailto:Rancid-discuss@shrubbery.net">Rancid-discuss@shrubbery.net</a><br>
<a href="http://www.shrubbery.net/mailman/listinfo/rancid-discuss" target="_blank">http://www.shrubbery.net/mailman/listinfo/rancid-discuss</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Jason<br>
</div></div></div>