snmpa_local_db(3)

πŸ“¦
version 29.0.6 Β· 3 versions
, in ubuntu stonking

πŸ’– snmpa_local_db β€” the SNMP built-in database, but make it make sense πŸ’–

okay bestie, you're looking at snmpa_local_db(3), an Erlang module definition from the snmp crew. Let's get into it 🫢


✨ NAME ✨

snmpa_local_db β€” the SNMP built-in database. yes she's built-in, yes she's serving, no she's not perfect. we'll get there.


🌸 DESCRIPTION 🌸

so snmpa_local_db is the module holding all the functions you need to implement tables (and variables, don't forget the variables) using the SNMP built-in database. πŸ’…

this database exists in two instances, and you gotta pick your fighter:

  • one volatile, implemented with ets
  • one persistent, implemented with dets
⚠️ real talk: there is a scaling problem with this database.
  • Insertions and deletions are inefficient for large tables. 😭

and the fix? the glow-up? use Mnesia instead. that's the whole rec, no cap.

okay so the functions below describe the interface to snmpa_local_db, and every single one of them has a Mnesia equivalent. the argument NameDb is a tuple {Name, Db} where Name is the symbolic name of the managed object (as defined in the MIB), and Db is either volatile or persistent. and listen β€” mnesia is not possible here, because all of these functions are snmpa_local_db specific. periodt. πŸ™…

πŸŽ€ Common Data Types

in the functions defined below, the following limitation applies:

  • Db = volatile | persistent

πŸ‘€ See Also

ets(3), dets(3), snmp_generic(3)


πŸ”₯ FUNCTIONS πŸ”₯

dump() -> ok | {error, Reason} when Reason :: term().

use this one to manually dump the database to file. like you, doing it by hand, iconic. πŸ’…

match(Table, Pattern) -> [Match] when Table :: snmpa:name_db() | snmpa:name(), Pattern :: ets:match_pattern(), Match :: term().

performs an ets/dets matching on the table. ✨

for a description of Pattern and the return values, go peek at ets:match/2 β€” she explains it better than I ever could.

prints the contents of the database on screen. this one is so useful for debugging, fr fr, because the STANDARD-MIB and OTP-SNMPEA-MIB (and maybe your own MIBs too, main character energy) are stored in snmpa_local_db. πŸ‘‘

Table is an atom for a table in the database. when no name is supplied, the whole database is shown. the whole thing. she's showing everything. πŸ™ˆ

😭 okay important caveat: note that these functions do not actually print, using io:format/2 β€” instead they (just) return the information. if you execute it in a shell, the information will then be displayed (probably truncated) there. so like... the shell is doing the printing, not her. she's just handing you the goods.

a better use would be:

io:format("~p~n", [snmpa_local_db:print()]).

yes bestie, wrap her. πŸŽ€

table_create(Table) -> boolean() when Table :: snmpa:name_db() | snmpa:name().

creates a table. but heads up β€” if the table already exists, the old copy is destroyed. πŸ’€ gone. reduced to atoms.

returns false if the NameDb argument is incorrectly specified, true otherwise.

Database (only table name specified) defaults to volatile.

table_create_row(Table, RowIndex, Row) -> boolean() when Table :: snmpa:name_db() | snmpa:name(), RowIndex :: snmp:row_index(), Row :: tuple().

creates a row in a table. Row is a tuple with values for all columns, including the index columns. don't skip the index columns, I'm begging. πŸ₯Ί

Database (only table name specified) defaults to volatile.

table_delete(Table) -> true when Table :: snmpa:name_db() | snmpa:name().

deletes a table. that's it. that's the function. πŸ’…

Database (only table name specified) defaults to volatile.

table_delete_row(Table, RowIndex) -> boolean() when Table :: snmpa:name_db() | snmpa:name(), RowIndex :: snmp:row_index().

deletes the row in the table. bye bye row πŸ¦‹

Database (only table name specified) defaults to volatile.

table_exists(Table) -> boolean() when Table :: snmpa:name_db() | snmpa:name().

checks if a table exists. vibe check, but for tables. ⭐

Database (only table name specified) defaults to volatile.

table_get_element(Table, RowIndex, Col) -> {value, Value} | undefined when Table :: snmpa:name_db() | snmpa:name(), RowIndex :: snmp:row_index(), Col :: snmp:column(), Value :: term().

get a column value (element) from a row of the table. little grab, little snack. πŸ“

Database (only table name specified) defaults to volatile.

πŸ“ this function has existed for long time, but not had a proper since tag, so to simplify we set the since tag to when it was documented. (iykyk)

table_get_row(Table, RowIndex) -> Row | undefined when Table :: snmpa:name_db() | snmpa:name(), RowIndex :: snmp:row_index(), Row :: tuple().

Row is a tuple with values for all columns, including the index columns. yes, again, the index columns. they're always invited. πŸŽ€

Database (only table name specified) defaults to volatile.

table_set_elements(Table, RowIndex, Cols) -> boolean() when Table :: snmpa:name_db() | snmpa:name(), RowIndex :: snmp:row_index(), Cols :: [{Col, Value}], Col :: snmp:column(), Value :: term().

update the specified columnar objects of the row of this table. glow-up time ✨

Database (only table name specified) defaults to volatile.

πŸ“ this function has existed for long time, but not had a proper since tag, so to simplify we set the since tag to when it was documented. (yes, same note, she said it twice, we love consistency πŸ’œ)

🌈 that's the whole page bestie 🌈

no gatekeeping, no skipped options, every flag accounted for. you ate. πŸ’…

Ericsson AB wrote this one, it's from snmp 5.20.5, and the page is snmpa_local_db(3). mwah, sending you off with a kiss and a working ets table πŸ«ΆπŸ’–βœ¨

πŸ“¦ where this page comes from