19962009 Ericsson AB. All Rights Reserved. The contents of this file are subject to the Erlang Public License, Version 1.1, (the "License"); you may not use this file except in compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. snmpa_local_db snmpa_local_db.xml
snmpa_local_db 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 types are used:

NameDb = {Name, Db}

Name = atom(), Db = volatile | persistent

RowIndex = [int()]

Cols = [Col] | [{Col, Value}], Col = int(), Value = term()

where RowIndex denotes the last part of the OID, that specifies the index of the row in the table. Cols is a list of column numbers in case of a get operation, and a list of column numbers and values in case of a set operation.

dump() -> ok | {error, Reason} Dump the database to disk Reason = term()

This function can be used to manually dump the database to file.

match(NameDb, Pattern) Perform a match on the table

Performs an ets/dets matching on the table. See Stdlib documentation, module ets, for a description of Pattern and the return values.

print() print(TableName) print(TableName, Db) Print the database to screen TableName = atom()

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.

TableName is an atom for a table in the database. When no name is supplied, the whole database is shown.

table_create(NameDb) -> bool() Create a table

Creates a table. If the table already exist, the old copy is destroyed.

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

table_create_row(NameDb, RowIndex, Row) -> bool() Create a row in a table Row = {Val1, Val2, ..., ValN} Val1 = Val2 = ... = ValN = term()

Creates a row in a table. Row is a tuple with values for all columns, including the index columns.

table_delete(NameDb) -> void() Delete a table

Deletes a table.

table_delete_row(NameDb, RowIndex) -> bool() Delete the row in the table

Deletes the row in the table.

table_exists(NameDb) -> bool() Check if a table exists

Checks if a table exists.

table_get_row(NameDb, RowIndex) -> Row | undefined Get a row from the table Row = {Val1, Val2, ..., ValN} Val1 = Val2 = ... = ValN = term()

Row is a tuple with values for all columns, including the index columns.

See Also

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