[rancid] Re: show cdp neighbor
Christopher DeRemer
cderemer at phoebe.org
Wed Jan 13 18:57:57 UTC 2010
That would be great. I think the problem is going to be selecting the appropriate output. Here is an example:
Original Output:
Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge
S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone
Device ID Local Intrfce Holdtme Capability Platform Port ID
2950_trexler1 Gig 0/48 129 S I WS-C2950G Gig 0/1
3550_switchroom.phoebe.local
Gig 0/52 156 R S I WS-C3550- Gig 0/1
TrexlerSquare05.cisco.com
Gig 0/3 150 AIR-LAP11 Fas 0
TrexlerSquare06.cisco.com
Gig 0/7 122 AIR-LAP11 Fas 0
TrexlerSquare01.cisco.com
Gig 0/10 162 AIR-LAP11 Fas 0
TrexlerSquare03.cisco.com
Gig 0/1 145 AIR-LAP11 Fas 0
TrexlerSquare02.cisco.com
Gig 0/11 157 AIR-LAP11 Fas 0
AllenSquare03.cisco.com
Gig 0/6 149 AIR-LAP11 Fas 0
AllenSquare01.cisco.com
Gig 0/4 135 AIR-LAP11 Fas 0
GroundReceiving.cisco.com
Gig 0/8 176 AIR-LAP11 Fas 0
============
Desired output:
Device ID Local Intrfce Capability Platform Port ID
2950_trexler1 Gig 0/48 S I WS-C2950G Gig 0/1
3550_switchroom.phoebe.local Gig 0/52 R S I WS-C3550- Gig 0/1
TrexlerSquare05.cisco.com Gig 0/3 AIR-LAP11 Fas 0
TrexlerSquare06.cisco.com Gig 0/7 AIR-LAP11 Fas 0
TrexlerSquare01.cisco.com Gig 0/10 AIR-LAP11 Fas 0
TrexlerSquare03.cisco.com Gig 0/1 AIR-LAP11 Fas 0
TrexlerSquare02.cisco.com Gig 0/11 AIR-LAP11 Fas 0
AllenSquare03.cisco.com Gig 0/6 AIR-LAP11 Fas 0
AllenSquare01.cisco.com Gig 0/4 AIR-LAP11 Fas 0
GroundReceiving.cisco.com Gig 0/8 AIR-LAP11 Fas 0
====================
Obviously a couple things have taken place:
*got rid of the header info
*got rid of the holdown-time column
*respace the columns and place info on one line for names that casue to to run over to the next line
*this causes a lot of column shifting that I once was able to fix by changing the size of the terminal size option in the switch/router, but I'm not sure if that's possible inside rancid...
So far I have this as my subroutine:
# This is a TEST routine to parse "show cdp neighbors"
sub ShowCDPNeighbors {
print STDERR " In ShowCDPNeighbors: $_" if ($debug);
while (<INPUT>) {
tr/\015//d;
last if (/^$prompt/);
next if (/^(\s*|\s*$cmd\s*)$/);
return(1) if /^\s*\^\s*$/;
return(1) if /Line has invalid autocommand /;
return(1) if /(Invalid input detected|Type help or )/;
#return(1) if ($type =~ /^(3550|4500)$/);
#return(1) if ($type !~ /^(2900XL|3500XL|6000)$/);
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}//;
}
ProcessHistory("COMMENTS","keysort","IO","!CDP: $_");
}
ProcessHistory("COMMENTS","keysort","IO","!\n");
return(0);
}
Thanks for your help! The hard part is yet to come! I'm willing to test a script that you make, I can just create a small test group in my rancid config :)
Cheers,
Christopher DeRemer, CCENT
Network Administrator
Phoebe Services
484.619.2168 (Single # Reach)
-----Original Message-----
From: Deny IP Any Any [mailto:denyipanyany at gmail.com]
Sent: Wednesday, January 13, 2010 1:43 PM
To: Christopher DeRemer
Subject: Re: [rancid] Re: show cdp neighbor
I wouldn't mind having this as well; I'll try to hack in support to my
copy of rancid, and send a patch to you as well if you'd like.
2010/1/13 Christopher DeRemer <cderemer at phoebe.org>:
> I am looking to do a similar setup as an old thread here:
> http://www.shrubbery.net/pipermail/rancid-discuss/2006-November/001861.html
>
>
>
> I'm looking to add in "show cdp neighbors" as a part of our routine.
> Background on my reasoning: I have a bunch of Cisco AP's that are all joined
> to a controller, but the issue is that the Event Logging from the controller
> is a bit no descript and way to verbose. Instead I'd like to be notified if
> an AP "dies" by knowing that it's no longer seen in the particular switch's
> cdp neighbor list.
>
>
>
> Anyway an Andrew suggested that I need to add a 'ShowCdpDetail' subroutine
> that will parse the output. Unlike the original thread I don't want show
> cdp neighbor detail, just show cdp neighbor, which ends up looking like a
> simple table.
>
>
>
> Can someone help me make a parsing sub-routine? I have very very little
> experience in PHP/Shell scripting.
>
>
>
> This would be greatly appreciated, as well as might be a great addition to
> RANCID for others!
>
>
>
> Cheers,
>
>
>
> Christopher DeRemer, CCENT
> Network Administrator
> Phoebe Services
> 484.619.2168 (Single # Reach)
>
>
>
> ________________________________
> NOTICE: This confidential message/attachment contains information intended
> for a specific individual(s). Any inappropriate use, distribution or
> duplication is strictly prohibited. If received in error, notify the sender
> and immediately delete this transmission.
>
> _______________________________________________
> Rancid-discuss mailing list
> Rancid-discuss at shrubbery.net
> http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
>
--
deny ip any any (4393649193 matches)
NOTICE: This confidential message/attachment contains information intended for a specific individual(s). Any inappropriate use, distribution or duplication is strictly prohibited. If received in error, notify the sender and immediately delete this transmission.
More information about the Rancid-discuss
mailing list