[rancid] sorting output from custom commands...
john heasley
heas at shrubbery.net
Tue Sep 28 22:28:01 UTC 2010
Tue, Sep 28, 2010 at 06:06:30PM +0100, Jon Peatfield:
> I added a quick hack to our rancid (2.3.4) setup to record the output of
> running:
>
> show cdp neighbors detail
>
> to hrancid and rancid (we only have Cisco and HP procurve switches).
>
> On the newer versions of the HP porocurve firmware (all 2610-xx models)
> each (cisco 79xx) phone device shows up as two device-ids, and it appears
> that every time a handset is connected those devices appear in a random
> order.
>
> So at the moment we get spurious change messages swapping the order of
> the two entries (both on the same port).
>
> I'm not very familiar with how ProcessHistory works, so I don't know if
> there is a trick I can use to get it to do the sorting for me. I did
> already write a piece of code to store the data in a hash by device-id
> and only call ProcessHistory when we notice that the port in the output
> has changed, but I lost that by accidentally zapping the directory I was
> testing in (oops). I can re-do that work easily enough but since other
> stuff has to handle output in different orders I wonder if I'm wasting my
> time...
ProcessHistory(tag, command, command_arg, data)
data is added the buffer, by command with command_arg (if specified),
unless tag or command has changed since the last call, in which case
the buffer would be flushed before calling command.
a good example, where $aclsort = "ipsort" (the function)
# order access-lists
/^access-list\s+(\d\d?)\s+(\S+)\s+(\S+)/ &&
ProcessHistory("ACL $1 $2","$aclsort","$3","$_") && next;
More information about the Rancid-discuss
mailing list