View Source snmpa_mib_data behaviour (snmp v5.16)

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

Link to this type

filename()

View Source (not exported) (since OTP R16B01)
-type filename() :: file:filename().
Link to this type

mib_view()

View Source (since OTP R16B01)
-type mib_view() :: [mib_view_elem()].
Link to this type

mib_view_elem()

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

mib_view_inclusion()

View Source (since OTP R16B01)
-type mib_view_inclusion() :: 1 | 2.
Link to this type

mib_view_mask()

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

Callbacks

Link to this callback

backup(State, BackupDir)

View Source (since OTP R16B01)
-callback backup(State :: term(), BackupDir :: string()) -> 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.

Link to this callback

close(State)

View Source (since OTP R16B01)
-callback close(State :: term()) -> ok.

Close the mib-storage.

Link to this callback

code_change(Direction, Vsn, Extra, State)

View Source (since OTP R16B01)
-callback code_change(Direction :: up | down, Vsn :: term(), Extra :: term(), State :: term()) ->
                         NewState :: term().

Perform a code-change (upgrade or downgrade).

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

Link to this callback

dump(State, Destination)

View Source (since OTP R16B01)
-callback dump(State :: term(), Destination :: io | filename()) -> ok | {error, Reason :: term()}.

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

Link to this callback

info(State)

View Source (since OTP R16B01)
-callback info(State :: term()) -> list().

Retrieve misc info for the mib data.

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

Link to this callback

load_mib(State, FileName, MeOverride, TeOverride)

View Source (since OTP R16B01)
-callback load_mib(State :: term(),
                   FileName :: filename(),
                   MeOverride :: boolean(),
                   TeOverride :: boolean()) ->
                      {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.

Link to this callback

lookup(State, Oid)

View Source (since OTP R16B01)
-callback lookup(State :: term(), Oid :: snmp:oid()) ->
                    {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

Link to this callback

new(MibStorage)

View Source (since OTP R16B01)
-callback new(MibStorage :: snmpa:mib_storage()) -> State :: term().

Create a new mib-server data instance.

Link to this callback

next(State, Oid, MibView)

View Source (since OTP R16B01)
-callback next(State :: term(), Oid :: snmp:oid(), MibView :: mib_view()) ->
                  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.

Link to this callback

register_subagent(State, Oid, Pid)

View Source (since OTP R16B01)
-callback register_subagent(State :: term(), Oid :: snmp:oid(), Pid :: pid()) ->
                               {ok, NewState :: term()} | {error, Reason :: term()}.

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

Link to this callback

sync(State)

View Source (since OTP R16B01)
-callback sync(State :: term()) -> ok.

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).

Link to this callback

unload_mib(State, Filename)

View Source (optional) (since OTP R16B01)
-callback unload_mib(State, Filename) -> {ok, NewState} | {error, Reason}
                        when
                            State :: term(),
                            Filename :: filename(),
                            NewState :: term(),
                            Reason :: not_loaded | term().
Link to this callback

unload_mib(State, FileName, MeOverride, TeOverride)

View Source (since OTP R16B01)
-callback unload_mib(State :: term(),
                     FileName :: filename(),
                     MeOverride :: boolean(),
                     TeOverride :: boolean()) ->
                        {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.

Link to this callback

unregister_subagent(State, PidOrOid)

View Source (since OTP R16B01)
-callback unregister_subagent(State :: term(), PidOrOid :: pid() | snmp:oid()) ->
                                 {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.

Link to this callback

whereis_mib(State, MibName)

View Source (since OTP R16B01)
-callback whereis_mib(State :: term(), MibName :: atom()) ->
                         {ok, Filename :: filename()} | {error, Reason :: term()}.

Retrieve the mib file for the mib.

Link to this callback

which_mib(State, Oid)

View Source (since OTP R16B01)
-callback which_mib(State :: term(), Oid :: snmp:oid()) -> {ok, Mib :: string()} | {error, Reason :: term()}.

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

Link to this callback

which_mibs(State)

View Source (since OTP R16B01)
-callback which_mibs(State :: term()) -> [{MibName :: atom(), Filename :: filename()}].

Retrieve all loaded mib-files.