snmpa_local_db(3)
π 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.
print(Table, Db) -> term() when Table :: snmpa:name(), Db :: volatile | persistent.
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
- ubuntu stonking: erlang-doc 1:29.0.6+dfsg-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms