[rancid] sorting output from custom commands...
Jon Peatfield
J.S.Peatfield at damtp.cam.ac.uk
Wed Sep 29 19:35:26 UTC 2010
On Wed, 29 Sep 2010, john heasley wrote:
> Wed, Sep 29, 2010 at 01:45:45AM +0100, Jon Peatfield:
>> CDP neighbors information
>>
>> Port : 1
>> Device ID : SEP001FCA369E19
>> Address Type : IP
>> Address : 172.18.18.179
>> Platform : SIP11.8-5-3SCisco IP Phone 7911
>> Capability :
>> Device Port : Port 1
>> Version : SIP11.8-5-3SCisco IP Phone 7911
>>
>> ------------------------------------------------------------------------------
>>
>> Port : 1
>> Device ID : 01 ac 12 12 b3
>> Address Type : IP
>> Address : 172.18.18.179
>> Platform : Cisco IP Phone 7911G,V5, SIP11.8-5-3S
>> Capability : Switch
>> Device Port : 001FCA369E19:P1
>> Version : Cisco IP Phone 7911G,V5, SIP11.8-5-3S
>
> though this looks legitimate; some of the phones have two device. i'd
> keep track of the port's seen (or just last port) and skip duplicates.
>
>> if (/^\s*Port\s*:\s*(.*)/) {
>> my $newport=$1;
> if port == lastport
> read until ^$
> else
> read, processhistory, until ^$
I may be misunderstanding you, but that sounds like you are suggesting
skipping all but the first device-id for each port.
Since the multiple device-ids on a port are listed in an apparently random
order (but the order stays until the device is unplugged or reset), just
reporting the first device on a port will cause reporting flaps (just like
I was getting by not sorting them).
The current code I'm testing seems to give the answers I want though it
does assume that all devices for port P will be consecutive in the
output...
There is another thing I do plan to fix which is that for a few seconds
after a handset is plugged in we get a 3rd device-id reported - apparently
a fixed device-id for all handsets. Presumably this is a quirk of the
data that these Cisco handsets send in their first cdp frame, or the HP
not understanding something.
I plan to simply filter those out since the information isn't useful to me
and we only see them if rancid happens to poll the switch right after a
handset is connected.
I'll be happy to contribute what I end up with if anyone else wants this.
-- Jon
More information about the Rancid-discuss
mailing list