rancid(3)
π rancid β the rancid(3) page, bestie edition π
okay so welcome to rancid(3), which lives in the Library Functions Manual section, and it's literally the whole vibe of the rancid Perl and Python modules. pull up a chair π
β¨ NAME β¨
rancid β the rancid Perl and Python modules. that's it, that's the name, short and iconic π
πΈ INTRODUCTION πΈ
so the rancid library is out here providing functions for handling rancid.types configuration files, loading modules, and it also brings the basic global variables, the variables you get from parsing rancid.types files, and the output handling functions that every single rancid device module has in common. and all of those are exported (in Perl terms, iykyk) for anyone who imports the module. specifically, the library is used by rancid(1), but honestly it could be used by any Perl program for site-specific handling or extra automata. the range? unmatched π
π§ Input handling functions π§
the rancidcontrib library has functions for similar purposes, but bestie, those are not part of the base rancid. please go read the text of the module itself for its documentation. no cap.
RunCommand(*INPUT, *OUTPUT, command)β parses a single command that returns no required info, and the output just gets dropped π. this one could be used as the processing function in a command definition in arancid.typesfile. very demure, very "i don't need the receipts".
π Output handling functions π
ProcessHistory([tag], [sort_function], [sort_function_argument], string)β okay so if the optionaltagstring andsort_functionarguments are omitted, thestringgets output immediately, no drama. otherwise, the strings are accumulated in a hash, keyed by the hash keysort_function_argument, every single timeProcessHistory()is called β and it keeps doing that until thetagorsort_functionchanges, at which point the queue gets flushed and the new string is handled. ifsort_functionhad been supplied, it gets called with the hash as its argument.
heads up bestie: if the hash key sort_function_argument already exists, the new strings is appended to the existing hash value. so it stacks, fr fr.
keysort(%hash)β a sort routine that will sort on the keys of a hash as if it were a normal array. for example:
ProcessHistory("TAG","keysort","B0","!\n");
ProcessHistory("TAG","keysort","D0","!\n");
and B0 and D0 are the sort keys. slay.
valsort(%hash)β a sort routine that will sort on the values</> of a hash as if it were a normal array. like:
ProcessHistory("TAG","valsort","","!B0\n");
ProcessHistory("TAG","valsort","","!D0\n");
numsort(%hash)β a numerical sort routine (ascending). numbers go up, it's giving organized β¨ipsort(IPv4 dotted-quad/v6 address)β a sort routine that will sort on the ip address when the IP address is anywhere in the strings. anywhere! it finds it π΅οΈββοΈ
ProcessHistory("TAG","ipsort","192.168.0.0","!B0\n");
ProcessHistory("TAG","ipsort","192.168.1.0","!D0\n");
sortbyipaddr(XXX)β a sort routine that will sort based upon IPv4/v6 addresses. yes,XXXis literally what the signature says, i don't make the rules π«Ά
please go look at the library code itself for the exported variables, because they're not listed here and i'm not about to make stuff up π
and for documentation on the rancid Python module, go read pydoc(1). it is equivalent to the Perl module, but in a Pythonic manner ππ
π SEE ALSO π
that's the whole page, bestie β you ate that π this little gem came from the rancid rancid(3) page dated 21 July 2021. go forth and sort some hashes ππ¦
π¦ where this page comes from
- alpine 3.24: rancid-doc 3.14-r0 Β· BSD-3-Clause-No-Nuclear-License-2014
- debian trixie: rancid 3.14-1 Β· BSD-3-Clause
- fedora 43: rancid 3.14-1.fc43 Β· BSD-3-Clause
- fedora 44: rancid 3.14-1.fc44 Β· BSD-3-Clause
- ubuntu questing: rancid 3.14-1
- ubuntu resolute: rancid 3.14-1build1 Β· BSD-3-Clause
- ubuntu stonking: rancid 3.14-1build1 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms