[rancid] sorting output from custom commands...

john heasley heas at shrubbery.net
Wed Sep 29 21:58:49 UTC 2010


Wed, Sep 29, 2010 at 08:35:26PM +0100, Jon Peatfield:
> 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.

yes

> 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).

missed that.  what you had is appropriate, or use

  processhistory("cdp", "keysort", "port $port $capability", data)
or
  processhistory("cdp", "keysort", "port $port $deviceid", data)

and let keysort sort the entries.


More information about the Rancid-discuss mailing list