snmpa_mib_data behaviour (snmp v5.20.1)

Copy Markdown View Source

Behaviour module for the SNMP agent mib-server data module.

This module defines the behaviour of the SNMP agent mib-server data module. A snmpa_mib_data compliant module must export the following functions:

The semantics of them and their exact signatures are explained below.

Note that the data extracted from the imported (loaded) mibs are stored partly by the mib-server and partly by the symbolic-store server. See the default mib-server data module, snmpa_mib_data_tttn for details.

Summary

Callbacks

Perform a backup of the mib-server data.

Close the mib-storage.

Perform a code-change (upgrade or downgrade).

Dump the mib-server data to stdio (Destination = io) or the specified file.

Retrieve misc info for the mib data.

Load the mib specified by the Filename argument into the mib-server. The MeOverride and TeOverride arguments specifies how the mib-server shall handle duplicate mib- and trap- entries.

Find the mib-entry corresponding to the Oid. If it is a variable, the Oid must be <Oid for var>.0 and if it is a table, Oid must be

Create a new mib-server data instance.

Finds the lexicographically next oid.

Register the subagent, process, handling part of the mib-tree.

Synchronize (write to disc, if possible) the mib-server data. This depends on the mib_storage option, and will only have an effect if the mib-storage option has an actual disc component (such as dets, or ets with a file).

Unload the mib specified by the Filename argument from the mib-server. The MeOverride and TeOverride arguments specifies how the mib-server shall handle duplicate mib- and trap- entries.

Unregister the subagent, handling part of the mib-tree, as specified by the oid() or pid/0 (PidOrOid).

Retrieve the mib file for the mib.

Retrieve the mib-file to which an given oid() belongs.

Retrieve all loaded mib-files.

Types

filename()

(not exported) (since OTP R16B01)
-type filename() :: file:filename().

mib_view()

(since OTP R16B01)
-type mib_view() :: [mib_view_elem()].

mib_view_elem()

(since OTP R16B01)
-type mib_view_elem() ::
          {SubTree :: snmp:oid(), Mask :: [non_neg_integer()], Inclusion :: mib_view_inclusion()}.

mib_view_inclusion()

(since OTP R16B01)
-type mib_view_inclusion() :: 1 | 2.

mib_view_mask()

(since OTP R16B01)
-type mib_view_mask() :: [non_neg_integer()].

Callbacks

backup(State :: term(), BackupDir :: string()) -> Result

(since OTP R16B01)

Types

Result = ok | {error, Reason :: term()}

Perform a backup of the mib-server data.

Note that its implementation dependent (and also dependent on mib-storage is used) if a backup is possible.

close(State :: term()) -> ok

(since OTP R16B01)

Close the mib-storage.

code_change(Direction, Vsn, Extra, State) -> NewState

(since OTP R16B01)

Types

Direction = up | down
Vsn = Extra = State = NewState = term()

Perform a code-change (upgrade or downgrade).

See gen_server for more info regarding the Vsn and Extra arguments.

dump(State, Destination) -> Result

(since OTP R16B01)

Types

State = term()
Destination = io | filename()
Result = ok | {error, Reason :: term()}

Dump the mib-server data to stdio (Destination = io) or the specified file.

info(State :: term()) -> list()

(since OTP R16B01)

Retrieve misc info for the mib data.

This is a utility function used to inspect, for instance, memory usage, in a simple way.

load_mib(State, FileName, MeOverride, TeOverride) -> Result

(since OTP R16B01)

Types

State = term()
FileName = filename()
MeOverride = TeOverride = boolean()
Result = {ok, NewState :: term()} | {error, Reason :: already_loaded | term()}

Load the mib specified by the Filename argument into the mib-server. The MeOverride and TeOverride arguments specifies how the mib-server shall handle duplicate mib- and trap- entries.

lookup(State, Oid) -> Result

(since OTP R16B01)

Types

State = term()
Oid = snmp:oid()
Result = {false, Reason :: term()} |
          {variable, MibEntry :: snmpa:me()} |
          {table_column, MibEntry :: snmpa:me(), TableEntryOid :: snmp:oid()} |
          {subagent, SubAgentPid :: pid(), SAOid :: snmp:oid()}

Find the mib-entry corresponding to the Oid. If it is a variable, the Oid must be <Oid for var>.0 and if it is a table, Oid must be

new(MibStorage :: snmpa:mib_storage()) -> State

(since OTP R16B01)

Types

State = term()

Create a new mib-server data instance.

next(State, Oid, MibView) -> Result

(since OTP R16B01)

Types

State = term()
Oid = snmp:oid()
MibView = mib_view()
Result = endOfView | false |
          {subagent, SubAgentPid :: pid(), SAOid :: snmp:oid()} |
          {variable, MibEntry :: snmpa:me(), VarOid :: snmp:oid()} |
          {table, TableOid :: snmp:oid(), TableRestOid :: snmp:oid(), MibEntry :: snmpa:me()}

Finds the lexicographically next oid.

register_subagent(State, Oid, Pid) -> Result

(since OTP R16B01)

Types

State = term()
Oid = snmp:oid()
Pid = pid()
Result = {ok, NewState :: term()} | {error, Reason :: term()}

Register the subagent, process, handling part of the mib-tree.

sync(State :: term()) -> ok

(since OTP R16B01)

Synchronize (write to disc, if possible) the mib-server data. This depends on the mib_storage option, and will only have an effect if the mib-storage option has an actual disc component (such as dets, or ets with a file).

unload_mib(State, Filename) -> Result

(since OTP R16B01) (optional)

Types

State = NewState = term()
Filename = filename()
Result = {ok, NewState} | {error, Reason}
Reason = not_loaded | term()

unload_mib(State, FileName, MeOverride, TeOverride) -> Result

(since OTP R16B01)

Types

State = term()
FileName = filename()
MeOverride = TeOverride = boolean()
Result = {ok, NewState :: term()} | {error, Reason :: not_loaded | term()}

Unload the mib specified by the Filename argument from the mib-server. The MeOverride and TeOverride arguments specifies how the mib-server shall handle duplicate mib- and trap- entries.

unregister_subagent(State, PidOrOid) -> Result

(since OTP R16B01)

Types

State = term()
PidOrOid = pid() | snmp:oid()
Result = {ok, NewState :: term()} | {ok, NewState :: term(), Pid :: pid()} | {error, Reason :: term()}

Unregister the subagent, handling part of the mib-tree, as specified by the oid() or pid/0 (PidOrOid).

When unregister the subagent using an oid(), the pid/0 of the process handling the sub-tree is also returned.

whereis_mib(State, MibName) -> Result

(since OTP R16B01)

Types

State = term()
MibName = atom()
Result = {ok, Filename :: filename()} | {error, Reason :: term()}

Retrieve the mib file for the mib.

which_mib(State, Oid) -> Result

(since OTP R16B01)

Types

State = term()
Oid = snmp:oid()
Result = {ok, Mib :: string()} | {error, Reason :: term()}

Retrieve the mib-file to which an given oid() belongs.

which_mibs(State :: term()) -> Result

(since OTP R16B01)

Types

Result = [{MibName :: atom(), Filename :: filename()}]

Retrieve all loaded mib-files.