The SNMP built-in database
The module snmpa_local_db contains functions for implementing tables (and
variables) using the SNMP built-in database. The database exists in two
instances, one volatile and one persistent. The volatile database is implemented
with ets. The persistent database is implemented with dets.
There is a scaling problem with this database.
- Insertions and deletions are inefficient for large tables.
This problem is best solved by using Mnesia instead.
The following functions describe the interface to snmpa_local_db. Each
function 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. mnesia is not possible since
all these functions are snmpa_local_db specific.
Common Data Types
In the functions defined below, the following limitation applies:
Db = volatile | persistent
See Also
ets(3), dets(3), snmp_generic(3)
Summary
Functions
This function can be used to manually dump the database to file.
Performs an ets/dets matching on the table.
Prints the contents of the database on screen. This is useful for debugging
since the STANDARD-MIB and OTP-SNMPEA-MIB (and maybe your own MIBs) are
stored in snmpa_local_db.
Creates a table. If the table already exist, the old copy is destroyed.
Creates a row in a table. Row is a tuple with values for all columns,
including the index columns.
Deletes a table.
Deletes the row in the table.
Checks if a table exists.
Get a column value (element) from a row of the table.
Row is a tuple with values for all columns, including the index columns.
Update the specified columnar objects of the row of this table.
Functions
This function can be used to manually dump the database to file.
Performs an ets/dets matching on the table.
See ets:match/2 for a description of Pattern and the return values.
print(Table :: snmpa:name(), Db :: volatile | persistent) -> term()
Prints the contents of the database on screen. This is useful for debugging
since the STANDARD-MIB and OTP-SNMPEA-MIB (and maybe your own MIBs) 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.
Note that these functions does not actually print, using io:format/2, instead they (just) return the information. If executed in a shell, the information will then be displayed (probably truncated) there.
A better use would be:
io:format("~p~n", [snmpa_local_db:print()]).
table_create(Table :: snmpa:name_db() | snmpa:name()) -> boolean()
Creates a table. If the table already exist, the old copy is destroyed.
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()
Creates a row in a table. Row is a tuple with values for all columns,
including the index columns.
Database (only table name specified) defaults to volatile.
table_delete(Table :: snmpa:name_db() | snmpa:name()) -> true
Deletes a table.
Database (only table name specified) defaults to volatile.
table_delete_row(Table, RowIndex) -> boolean()
Deletes the row in the table.
Database (only table name specified) defaults to volatile.
table_exists(Table :: snmpa:name_db() | snmpa:name()) -> boolean()
Checks if a table exists.
Database (only table name specified) defaults to volatile.
Types
Table = snmpa:name_db() | snmpa:name()
RowIndex = snmp:row_index()
Col = snmp:column()
Result = {value, Value} | undefined
Value = term()
Get a column value (element) from a row of the table.
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.
Row is a tuple with values for all columns, including the index columns.
Database (only table name specified) defaults to volatile.
Types
Table = snmpa:name_db() | snmpa:name()
RowIndex = snmp:row_index()
Cols = [{Col, Value}]
Value = term()
Col = snmp:column()
Update the specified columnar objects of the row of this table.
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.