1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">
<erlref>
<header>
<copyright>
<year>1996</year><year>2016</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
</legalnotice>
<title>snmpa_local_db</title>
<prepared></prepared>
<responsible></responsible>
<docno></docno>
<approved></approved>
<checked></checked>
<date></date>
<rev></rev>
<file>snmpa_local_db.xml</file>
</header>
<module since="">snmpa_local_db</module>
<modulesummary>The SNMP built-in database</modulesummary>
<description>
<p>The module <c>snmpa_local_db</c> 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.
</p>
<p>There is a scaling problem with this database.
</p>
<list type="bulleted">
<item>Insertions and deletions are inefficient for large tables.
</item>
</list>
<p>This problem is best solved by using Mnesia instead.
</p>
<p>The following functions describe the interface to
<c>snmpa_local_db</c>. Each function has a Mnesia equivalent.
The argument <c>NameDb</c> is a tuple <c>{Name, Db}</c> where
<c>Name</c> is the symbolic name of the managed object (as defined
in the MIB), and <c>Db</c> is either <c>volatile</c> or
<c>persistent</c>. <c>mnesia</c> is not possible since all these
functions are <c>snmpa_local_db</c> specific.
</p>
</description>
<section>
<title>Common Data Types</title>
<p>In the functions defined below, the following types are
used:
</p>
<list type="bulleted">
<item>
<p><c>NameDb = {Name, Db}</c></p>
</item>
<item>
<p><c>Name = atom(), Db = volatile | persistent</c></p>
</item>
<item>
<p><c>RowIndex = [int()]</c></p>
</item>
<item>
<p><c>Cols = [Col] | [{Col, Value}], Col = int(), Value = term()</c></p>
</item>
</list>
<p>where <c>RowIndex</c> denotes the last part of the OID, that
specifies the index of the row in the table. <c>Cols</c> 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.
</p>
</section>
<funcs>
<func>
<name since="">dump() -> ok | {error, Reason}</name>
<fsummary>Dump the database to disk</fsummary>
<type>
<v>Reason = term()</v>
</type>
<desc>
<p>This function can be used to manually dump the database
to file.</p>
</desc>
</func>
<func>
<name since="">match(NameDb, Pattern)</name>
<fsummary>Perform a match on the table</fsummary>
<desc>
<p>Performs an ets/dets matching on the table.
See Stdlib documentation, module ets, for a description of
<c>Pattern</c> and the return values.</p>
</desc>
</func>
<func>
<name since="">print()</name>
<name since="">print(TableName)</name>
<name since="">print(TableName, Db)</name>
<fsummary>Print the database to screen</fsummary>
<type>
<v>TableName = atom()</v>
</type>
<desc>
<p>Prints the contents of the database on
screen. This is useful for debugging since the
<c>STANDARD-MIB</c> and <c>OTP-SNMPEA-MIB</c>
(and maybe your own MIBs) are stored in <c>snmpa_local_db</c>.
</p>
<p><c>TableName</c> is an atom for a table in the database.
When no name is supplied, the whole database is shown.</p>
</desc>
</func>
<func>
<name since="">table_create(NameDb) -> bool()</name>
<fsummary>Create a table</fsummary>
<desc>
<p>Creates a table. If the table already exist, the old copy
is destroyed.
</p>
<p>Returns <c>false</c> if the <c>NameDb</c> argument is
incorrectly specified, <c>true</c> otherwise.</p>
</desc>
</func>
<func>
<name since="">table_create_row(NameDb, RowIndex, Row) -> bool()</name>
<fsummary>Create a row in a table</fsummary>
<type>
<v>Row = {Val1, Val2, ..., ValN}</v>
<v>Val1 = Val2 = ... = ValN = term()</v>
</type>
<desc>
<p>Creates a row in a table. <c>Row</c> is a tuple with
values for all columns, including the index columns.</p>
</desc>
</func>
<func>
<name since="">table_delete(NameDb) -> void()</name>
<fsummary>Delete a table</fsummary>
<desc>
<p>Deletes a table.</p>
</desc>
</func>
<func>
<name since="">table_delete_row(NameDb, RowIndex) -> bool()</name>
<fsummary>Delete the row in the table</fsummary>
<desc>
<p>Deletes the row in the table.</p>
</desc>
</func>
<func>
<name since="">table_exists(NameDb) -> bool()</name>
<fsummary>Check if a table exists</fsummary>
<desc>
<p>Checks if a table exists.</p>
</desc>
</func>
<func>
<name since="">table_get_row(NameDb, RowIndex) -> Row | undefined</name>
<fsummary>Get a row from the table</fsummary>
<type>
<v>Row = {Val1, Val2, ..., ValN}</v>
<v>Val1 = Val2 = ... = ValN = term()</v>
</type>
<desc>
<p><c>Row</c> is a tuple with values for all columns,
including the index columns.</p>
</desc>
</func>
</funcs>
<section>
<title>See Also</title>
<p>ets(3), dets(3), snmp_generic(3)
</p>
</section>
</erlref>
|