rancid(3)

πŸ“¦
version 3.14 Β· 2 versions
, in alpine 3.24, debian trixie, fedora 43, fedora 44, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– 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 a rancid.types file. very demure, very "i don't need the receipts".

πŸŽ€ Output handling functions πŸŽ€

  • ProcessHistory([tag], [sort_function], [sort_function_argument], string) β€” okay so if the optional tag string and sort_function arguments are omitted, the string gets output immediately, no drama. otherwise, the strings are accumulated in a hash, keyed by the hash key sort_function_argument, every single time ProcessHistory() is called β€” and it keeps doing that until the tag or sort_function changes, at which point the queue gets flushed and the new string is handled. if sort_function had 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, XXX is 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 πŸ’œπŸ¦‹