<font><font face="courier new,monospace"><br>Dear Skye,<br><br>Thanks for sharing your code.<br><br></font></font><font face="Calibri, Verdana, Helvetica, Arial"><span style="font-size:11pt">It will be very help full to have explanation of </span></font><font face="Calibri, Verdana, Helvetica, Arial"><span style="font-size:11pt">ProcessHistory method. <br>
<br></span></font><font face="Calibri, Verdana, Helvetica, Arial"><span style="font-size:11pt"></span></font><font face="Calibri, Verdana, Helvetica, Arial"><span style="font-size:11pt">NOTE : I not sure this list is using top posting or bottom posting style.  I am top posting this because it seems previous mail using top posting style. <br>
<br>Thanks <br>Mohan L  <br> </span></font><font face="Calibri, Verdana, Helvetica, Arial"><span style="font-size:11pt"> </span></font><br><font><font face="courier new,monospace"><br><br></font></font><br><div class="gmail_quote">
On Thu, Feb 23, 2012 at 9:25 PM, Skye Hagen <span dir="ltr">&lt;<a href="mailto:skyeh@uidaho.edu">skyeh@uidaho.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




<div>
<font face="Calibri, Verdana, Helvetica, Arial"><span style="font-size:11pt">The code you have for adding the commands to the command table are correct. I added both CDP and LLDP information to RANCID, here is the code I used to handle ‘show cdp neighbor detail’. The top part is pretty standard for any parsing routine, to skip the junk, and exit if we have hit the end of what we are interested in. After than, I look for specific lines, looking for the DeviceID, platform and interface. For the first two, I just store the data. When I hit an interface line, I create a line in the RANCID output. When done, I add a blank comment line to separated the CDP section from the next part of the RANCID output. This produces lines like this...<br>

<br>
!CDP: Device: <a href="http://hub001D3.csrv.uidaho.edu" target="_blank">hub001D3.csrv.uidaho.edu</a> Platform: cisco WS-C2960G-48TC-L Interface: GigabitEthernet2/14<br>
!CDP: Device: <a href="http://lib6500.csrv.uidaho.edu" target="_blank">lib6500.csrv.uidaho.edu</a> Platform: cisco WS-C6509-E Interface: GigabitEthernet3/1<br>
<br>
Here is the code.<br>
<br>
# This routine parses &quot;show cdp neighbor detail&quot;<br>
sub ShowCDPDetail {<br>
    print STDERR &quot;    In ShowCDPDetail: $_&quot; if ($debug);<br>
<br>
    my($deviceID, $platform, $interface);<br>
    while (&lt;INPUT&gt;) {<br>
        tr/\015//d;<br>
        last if (/^$prompt/);<br>
        next if (/^(\s*|\s*$cmd\s*)$/);<br>
        return(1) if (/Line has invalid autocommand /);<br>
        return(1) if (/(Invalid (input|command) detected|Type help or )/i);<br>
        # the pager can not be disabled per-session on the PIX<br>
        if (/^(&lt;-+ More -+&gt;)/) {<br>
            my($len) = length($1);<br>
            s/^$1\s{$len}//;<br>
        }<br>
<br>
        if (/^Device ID: (.*)/) {<br>
            $deviceID = $1;<br>
            next;<br>
        }<br>
<br>
        if (/^Platform: ([^,]+)/) {<br>
            $platform = $1;<br>
            next;<br>
        }<br>
<br>
        /^Interface: (\S+),/ &amp;&amp;<br>
            ProcessHistory(&quot;CDP&quot;,&quot;keysort&quot;,&quot;$deviceID $1&quot;,<br>
                           &quot;!CDP: Device: $deviceID Platform: $platform Interface: $1\n&quot;) &amp;&amp; next;<br>
    }<br>
<br>
    ProcessHistory(&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;!\n&quot;);<br>
    return(0);<div><div class="h5"><br>
<br>
}<br>
<br>
<br>
<br>
On 2/22/12 9:44 PM, &quot;Mohan L&quot; &lt;<a href="http://l.mohanphy@gmail.com" target="_blank">l.mohanphy@gmail.com</a>&gt; wrote:<br>
<br>
</div></div></span></font><blockquote><span style="font-size:11pt"><div><div class="h5"><font face="Courier New">Dear All,<br>
<br>
Thanks for you time to maintain such a amazing tool rancid.<br>
<br>
I am trying to add two more command in rancid(bin/rancid) script to pull information in Cisco routers. <br>
<br>
I found cisco router is points to rancid(bin/rancid) script:<br>
<br>
%vendortable = (<br>
    <br>
    &#39;cisco&#39;             =&gt; &#39;rancid&#39;,<br>
<br>
)<br>
<br>
I want to add the below two commands in rancid script : <br>
1). show cdp interface<br>
2). show cdp neighbors<br>
<br>
Here I have added the method to pull the output of the above commands  <br>
@commandtable = (<br>
        {&#39;show cdp interface&#39;                 =&gt; &#39;ShowCdpInterface&#39;},<br>
        {&#39;show cdp neighbors&#39;    =&gt; &#39;ShowCdpNeighbors&#39;},<br>
   )<br>
<br>
sub ShowCdpInterface {<br>
<br>
}<br>
<br>
<br>
sub ShowCdpNeighbors {<br>
<br>
<br>
}<br>
<br>
I need some pointer/guide to write the above two method. I am Intermediate level Perl guy. I am able to fine tune if some one have already written the script.<br>
<br>
I will greatly appreciate any help on this.<br>
<br>
<br>
Thanks<br>
Mohan L  <br>
</font></div></div><font face="Calibri, Verdana, Helvetica, Arial"><br>
<hr align="CENTER" size="3" width="95%"></font></span><font><font face="Consolas, Courier New, Courier"><span style="font-size:10pt">_______________________________________________<br>
Rancid-discuss mailing list<br>
<a href="http://Rancid-discuss@shrubbery.net" target="_blank">Rancid-discuss@shrubbery.net</a><br>
<a href="http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss" target="_blank">http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss</a><br>
</span></font></font></blockquote>
</div>


</blockquote></div><br>