View Source snmpa (snmp v5.15)

Interface Functions to the SNMP toolkit agent

The module snmpa contains interface functions to the SNMP agent.

DATA TYPES

oid() = [byte()]
atl_type() = read | write | read_write
notification_delivery_info() = #snmpa_notification_delivery_info{}

The oid() type is used to represent an ASN.1 OBJECT IDENTIFIER.

The record snmpa_notification_delivery_info contains the following fields:

  • tag = term() - A user defined identity representing this notification send operation.

  • mod = module() - A module implementing the snmpa_notification_delivery_info_receiver behaviour. The info functions of this module will be called at various stages of delivery.

  • extra = term() - This is any extra info the user wants to have supplied when the functions in the callback module is called.

See Also

calendar(3), erlc(1)

Summary

Functions

add_agent_caps(SysORID, SysORDescr) -> SysORIndex

Equivalent to backup/2

backup(Agent, BackupDir) -> ok | {error, Reason}

change_log_size(NewSize) -> ok | {error, Reason}

convert_config(OldConfig) -> AgentConfig

current_request_id() -> {value, RequestId} | false

del_agent_caps(SysORIndex) -> void()

disable_mibs_cache(Agent) -> void()

disable_mibs_cache_autogc(Agent) -> void()

Equivalent to discovery/6

Equivalent to discovery/6

discovery(TargetName, Notification, ContextName, Varbinds, DiscoHandler, ExtraInfo) -> {ok, ManagerEngineID} | {error, Reason}

enable_mibs_cache(Agent) -> void()

enable_mibs_cache_autogc(Agent) -> void()

enum_to_int(Db, Name, Enum) -> {value, Int} | false

gc_mibs_cache(Agent, Age, GcLimit) -> {ok, NumElementsGCed} | {error, Reason}

Equivalent to get/3

get(Agent, Vars, Context) -> Values | {error, Reason}

get_agent_caps() -> [[SysORIndex, SysORID, SysORDescr, SysORUpTime]]

get_next(Agent, Vars, Context) -> Values | {error, Reason}

Equivalent to info/1

info(Agent) -> [{Key, Value}]

int_to_enum(Db, Name, Int) -> {value, Enum} | false

invalidate_mibs_cache(Agent) -> void()

Equivalent to load_mib/2

load_mib(Agent, Mib) -> ok | {error, Reason}

Equivalent to load_mibs/3

load_mibs(Agent, Mibs, Force) -> ok | {error, Reason}

Equivalent to log_to_io/7

Equivalent to log_to_io/7

Equivalent to log_to_io/7

Equivalent to log_to_io/7

Equivalent to log_to_io/7

log_to_io(LogDir, Mibs, LogName, LogFile, Block, Start, Stop) -> ok | {ok, Cnt} | {error, Reason}

Equivalent to log_to_txt/8

Equivalent to log_to_txt/8

Equivalent to log_to_txt/8

Equivalent to log_to_txt/8

Equivalent to log_to_txt/8

Equivalent to log_to_txt/8

log_to_txt(LogDir, Mibs, OutFile, LogName, LogFile, Block, Start, Stop) -> ok | {ok, Cnt} | {error, Reason}

Equivalent to me_of/2

me_of(Agent, Oid) -> {ok, Me} | {error, Reason}

Equivalent to mib_of/2

mib_of(Agent, Oid) -> {ok, MibName} | {error, Reason}

name_to_oid(Db, Name) -> {value, oid()} | false

oid_to_name(Db, OID) -> {value, Name} | false

print_mib_info() -> void()

print_mib_tables() -> void()

print_mib_variables() -> void()

register_notification_filter(Agent, Id, Mod, Data, Where) -> ok | {error, Reason}

register_subagent(Agent, SubTreeOid, Subagent) -> ok | {error, Reason}

restart_set_worker(Agent) -> void()

restart_worker(Agent) -> void()

send_notification2(Agent, Notification, SendOpts) -> void()

send_notification(Agent, Notification, Receiver, NotifyName, ContextName, Varbinds, LocalEngineID) -> void()

set_log_type(Agent, NewType) -> {ok, OldType} | {error, Reason}

set_request_limit(Agent, NewLimit) -> {ok, OldLimit} | {error, Reason}

unload_mib(Agent, Mib) -> ok | {error, Reason}

unload_mibs(Agent, Mibs, Force) -> ok | {error, Reason}

unregister_notification_filter(Agent, Id) -> ok | {error, Reason}

unregister_subagent(Agent, SubagentOidOrPid) -> ok | {ok, SubAgentPid} | {error, Reason}

update_mibs_cache_age(Agent, NewAge) -> ok | {error, Reason}

update_mibs_cache_gclimit(Agent, NewGCLimit) -> ok | {error, Reason}

verbosity(Ref,Verbosity) -> void()

whereis_mib(Agent, MibName) -> {ok, MibFile} | {error, Reason}

which_aliasnames() -> Result

Equivalent to which_mibs/1

which_mibs(Agent) -> Mibs

which_mibs_cache_size(Agent) -> void()

which_notification_filter(Agent) -> Filters

which_notifications() -> Result

which_tables() -> Result

which_transports() -> Result

which_variables() -> Result

Types

-type db() :: volatile | persistent | mnesia.
-type me() :: snmp:me().
-type mib_storage() :: [mib_storage_opt()].
-type mib_storage_module() :: atom().
-type mib_storage_opt() :: {module, mib_storage_module()} | {options, mib_storage_options()}.
-type mib_storage_options() :: list().
-type name() :: table_name() | variable_name().
-type name_db() :: {name(), db()}.
-type pdu_type() :: snmp:pdu_type().
-type table_name() :: atom().
-type variable_name() :: atom().

Functions

Link to this function

add_agent_caps(Oid, Descr)

View Source

add_agent_caps(SysORID, SysORDescr) -> SysORIndex

This function can be used to add an AGENT-CAPABILITY statement to the sysORTable in the agent. The table is defined in the SNMPv2-MIB.

Equivalent to backup/2

Link to this function

backup(Agent, BackupDir)

View Source

backup(Agent, BackupDir) -> ok | {error, Reason}

Backup persistent/permanent data handled by the agent (such as local-db, mib-data and vacm).

Data stored by mnesia is not handled.

BackupDir cannot be identical to DbDir.

Simultaneous backup calls are not allowed. That is, two different processes cannot simultaneously successfully call this function. One of them will be first, and succeed. The second will fail with the error reason backup_in_progress.

Link to this function

change_log_size(NewSize)

View Source

change_log_size(NewSize) -> ok | {error, Reason}

Changes the log size of the Audit Trail Log. The application must be configured to use the audit trail log function. Please refer to disk_log(3) in Kernel Reference Manual for a description of how to change the log size.

The change is permanent, as long as the log is not deleted. That means, the log size is remembered across reboots.

convert_config(OldConfig) -> AgentConfig

This off-line utility function can be used to convert the old snmp application config (pre snmp-4.0) to the new snmp agent config (as of snmp-4.0).

For information about the old config (OldConfig) see the OTP R9C documentation.

For information about the current agent config (AgentConfig), see the Configuring the application chapter of the SNMP user's guide.

Equivalent to current_request_id/0

Equivalent to current_request_id/0

Equivalent to current_request_id/0

current_request_id() -> {value, RequestId} | false

Get the request-id, context, community and address of the request currently being processed by the agent.

Note that these functions is intended to be called by the instrumentation functions and only if they are executed in the context of the agent process (e.g. it does not work if called from a spawned process).

del_agent_caps(SysORIndex) -> void()

This function can be used to delete an AGENT-CAPABILITY statement to the sysORTable in the agent. This table is defined in the SNMPv2-MIB.

Equivalent to disable_mibs_cache/1

Link to this function

disable_mibs_cache(Agent)

View Source

disable_mibs_cache(Agent) -> void()

Disable the mib server cache.

Link to this function

disable_mibs_cache_autogc()

View Source

Equivalent to disable_mibs_cache_autogc/1

Link to this function

disable_mibs_cache_autogc(Agent)

View Source

disable_mibs_cache_autogc(Agent) -> void()

Disable automatic gc of the mib server cache.

Link to this function

discovery(TargetName, Notification)

View Source

Equivalent to discovery/6

Equivalent to discovery/6

Equivalent to discovery/6

Link to this function

discovery(TargetName, Notification, ContextName, Varbinds, DiscoHandler)

View Source

Equivalent to discovery/6

Link to this function

discovery(TargetName, Notification, ContextName, Varbinds, DiscoHandler, ExtraInfo)

View Source

discovery(TargetName, Notification, ContextName, Varbinds, DiscoHandler, ExtraInfo) -> {ok, ManagerEngineID} | {error, Reason}

Initiate the discovery process with the manager identified by TargetName using the notification Notification.

This function is synchronous, which means that it will return when the discovery process has been completed or failed.

The DiscoHandler module is used during the discovery process. See discovery handler for more info.

The ExtraInfo argument is passed on to the callback functions of the DiscoHandler.

Note

If we are not at security-level noAuthNoPriv, this could be complicated, since the agent will then continue with stage 2, before which the usm-related updates must be done.

Note

The default discovery handler will require additional actions by the caller and the discovery will not work if the security-level is higher then noAuthNoPriv.

Equivalent to enable_mibs_cache/1

Link to this function

enable_mibs_cache(Agent)

View Source

enable_mibs_cache(Agent) -> void()

Enable the mib server cache.

Link to this function

enable_mibs_cache_autogc()

View Source

Equivalent to enable_mibs_cache_autogc/1

Link to this function

enable_mibs_cache_autogc(Agent)

View Source

enable_mibs_cache_autogc(Agent) -> void()

Enable automatic gc of the mib server cache.

Equivalent to enum_to_int/3

Link to this function

enum_to_int(Db, Name, Enum)

View Source

enum_to_int(Db, Name, Enum) -> {value, Int} | false

Converts the symbolic value Enum to the corresponding integer of the enumerated object or type Name in a MIB. The MIB must be loaded.

false is returned if the object or type is not defined in any loaded MIB, or if it does not define the symbolic value as enumerated.

Db is a reference to the symbolic store database (retrieved by a call to get_symbolic_store_db/0).

Equivalent to gc_mibs_cache/3

Equivalent to gc_mibs_cache/3

Equivalent to gc_mibs_cache/3

Link to this function

gc_mibs_cache(Agent, Age, GcLimit)

View Source

gc_mibs_cache(Agent, Age, GcLimit) -> {ok, NumElementsGCed} | {error, Reason}

Perform mib server cache gc.

Manually performs a mib server cache gc. This can be done regardless of the value of the autogc option. The NumElementsGCed value indicates how many elements where actually removed from the cache.

Equivalent to get/3

Link to this function

get(Agent, Vars, Context)

View Source

get(Agent, Vars, Context) -> Values | {error, Reason}

Performs a GET operation on the agent. All loaded MIB objects are visible in this operation. The agent calls the corresponding instrumentation functions just as if it was a GET request coming from a manager.

Note that the request specific parameters (such as current_request_id) are not accessible for the instrumentation functions if this function is used.

get_agent_caps() -> [[SysORIndex, SysORID, SysORDescr, SysORUpTime]]

Returns all AGENT-CAPABILITY statements in the sysORTable in the agent. This table is defined in the SNMPv2-MIB.

Equivalent to get_next/3

Link to this function

get_next(Agent, Vars, Context)

View Source

get_next(Agent, Vars, Context) -> Values | {error, Reason}

Performs a GET-NEXT operation on the agent. All loaded MIB objects are visible in this operation. The agent calls the corresponding instrumentation functions just as if it was a GET request coming from a manager.

Note that the request specific parameters (such as snmpa:current_request_id/0 are not accessible for the instrumentation functions if this function is used.

Equivalent to info/1

info(Agent) -> [{Key, Value}]

Returns a list (a dictionary) containing information about the agent. Information includes loaded MIBs, registered sub-agents, some information about the memory allocation.

Equivalent to int_to_enum/3

Link to this function

int_to_enum(Db, Name, Int)

View Source

int_to_enum(Db, Name, Int) -> {value, Enum} | false

Converts the integer Int to the corresponding symbolic value of the enumerated object or type Name in a MIB. The MIB must be loaded.

false is returned if the object or type is not defined in any loaded MIB, or if it does not define the symbolic value as enumerated.

Db is a reference to the symbolic store database (retrieved by a call to get_symbolic_store_db/0).

Equivalent to invalidate_mibs_cache/1

Link to this function

invalidate_mibs_cache(Agent)

View Source

invalidate_mibs_cache(Agent) -> void()

Invalidate the mib server cache.

The entire contents of the cache will be deleted.

Link to this function

load_mib(Mib)

View Source (since OTP R16B02)

Equivalent to load_mib/2

Link to this function

load_mib(Agent, Mib)

View Source (since OTP R16B02)
-spec load_mib(Agent :: pid() | atom(), Mib :: string()) ->
            ok | {error, Reason :: already_loaded | term()}.

load_mib(Agent, Mib) -> ok | {error, Reason}

Load a single Mib into an agent. The MibName is the name of the Mib, including the path to where the compiled mib is found. For example:

          Dir = code:priv_dir(my_app) ++ "/mibs/",
          snmpa:load_mib(snmp_master_agent, Dir ++ "MY-MIB").

Link to this function

load_mibs(Mibs)

View Source (since OTP R16B02)

Equivalent to load_mibs/3

Link to this function

load_mibs/2

View Source (since OTP R16B02)

Equivalent to load_mibs/3

Link to this function

load_mibs(Agent, Mibs, Force)

View Source (since OTP R16B02)
-spec load_mibs(Agent :: pid() | atom(), Mibs :: [MibName :: string()], Force :: boolean()) ->
             ok |
             {error,
              {'load aborted at', MibName :: string(), InternalReason :: already_loaded | term()}}.

load_mibs(Agent, Mibs, Force) -> ok | {error, Reason}

Load Mibs into an agent. If the agent cannot load all MIBs (the default value of the Force argument is false), it will indicate where loading was aborted. The MibName is the name of the Mib, including the path to where the compiled mib is found. For example,

          Dir = code:priv_dir(my_app) ++ "/mibs/",
          snmpa:load_mibs(snmp_master_agent, [Dir ++ "MY-MIB"]).

If Force = true then the agent will continue attempting to load each mib even after failing to load a previous mib. Use with care.

Link to this function

log_to_io(LogDir)

View Source (since OTP R15B01,OTP R16B03)

Equivalent to log_to_io/7

Link to this function

log_to_io/2

View Source (since OTP R15B01,OTP R16B03)

Equivalent to log_to_io/7

Link to this function

log_to_io/3

View Source (since OTP R15B01,OTP R16B03)

Equivalent to log_to_io/7

Link to this function

log_to_io/4

View Source (since OTP R15B01,OTP R16B03)

Equivalent to log_to_io/7

Link to this function

log_to_io/5

View Source (since OTP R15B01,OTP R16B03)

Equivalent to log_to_io/7

Link to this function

log_to_io/6

View Source (since OTP R15B01,OTP R16B03)

Equivalent to log_to_io/7

Link to this function

log_to_io(LogDir, Mibs, LogName, LogFile, Block, Start, Stop)

View Source (since OTP R15B01,OTP R16B03)

log_to_io(LogDir, Mibs, LogName, LogFile, Block, Start, Stop) -> ok | {ok, Cnt} | {error, Reason}

Converts an Audit Trail Log to a readable format and prints it on stdio. LogName defaults to "snmpa_log". LogFile defaults to "snmpa.log".

The Block option indicates if the log should be blocked during conversion. This could be useful when converting large logs (when otherwise the log could wrap during conversion). Defaults to true.

See snmp:log_to_io for more info.

Link to this function

log_to_txt(LogDir)

View Source (since OTP R15B01,OTP R16B03)
-spec log_to_txt(LogDir :: snmp:dir()) -> snmp:void().

Equivalent to log_to_txt/8

Link to this function

log_to_txt/2

View Source (since OTP R15B01,OTP R16B03)
-spec log_to_txt(LogDir :: snmp:dir(), Block :: boolean()) -> snmp:void();
          (LogDir :: snmp:dir(), Mibs :: [snmp:mib_name()]) -> snmp:void().

Equivalent to log_to_txt/8

Link to this function

log_to_txt/3

View Source (since OTP R15B01,OTP R16B03)
-spec log_to_txt(LogDir :: snmp:dir(), Mibs :: [snmp:mib_name()], Block :: boolean()) -> snmp:void();
          (LogDir :: snmp:dir(), Mibs :: [snmp:mib_name()], OutFile :: file:filename()) ->
              snmp:void().

Equivalent to log_to_txt/8

Link to this function

log_to_txt/4

View Source (since OTP R15B01,OTP R16B03)
-spec log_to_txt(LogDir :: snmp:dir(),
           Mibs :: [snmp:mib_name()],
           OutFile :: file:filename(),
           Block :: boolean()) ->
              snmp:void();
          (LogDir :: snmp:dir(),
           Mibs :: [snmp:mib_name()],
           OutFile :: file:filename(),
           LogName :: string()) ->
              snmp:void().

Equivalent to log_to_txt/8

Link to this function

log_to_txt/5

View Source (since OTP R15B01,OTP R16B03)
-spec log_to_txt(LogDir :: snmp:dir(),
           Mibs :: [snmp:mib_name()],
           OutFile :: file:filename(),
           LogName :: string(),
           Block :: boolean()) ->
              snmp:void();
          (LogDir :: snmp:dir(),
           Mibs :: [snmp:mib_name()],
           OutFile :: file:filename(),
           LogName :: string(),
           LogFile :: string()) ->
              snmp:void().

Equivalent to log_to_txt/8

Link to this function

log_to_txt/6

View Source (since OTP R15B01,OTP R16B03)
-spec log_to_txt(LogDir :: snmp:dir(),
           Mibs :: [snmp:mib_name()],
           OutFile :: file:filename(),
           LogName :: string(),
           LogFile :: string(),
           Block :: boolean()) ->
              snmp:void();
          (LogDir :: snmp:dir(),
           Mibs :: [snmp:mib_name()],
           OutFile :: file:filename(),
           LogName :: string(),
           LogFile :: string(),
           Start :: snmp_log:log_time()) ->
              snmp:void().

Equivalent to log_to_txt/8

Link to this function

log_to_txt/7

View Source (since OTP R15B01,OTP R16B03)
-spec log_to_txt(LogDir :: snmp:dir(),
           Mibs :: [snmp:mib_name()],
           OutFile :: file:filename(),
           LogName :: string(),
           LogFile :: string(),
           Block :: boolean(),
           Start :: snmp_log:log_time()) ->
              snmp:void();
          (LogDir :: snmp:dir(),
           Mibs :: [snmp:mib_name()],
           OutFile :: file:filename(),
           LogName :: string(),
           LogFile :: string(),
           Start :: snmp_log:log_time(),
           Stop :: snmp_log:log_time()) ->
              snmp:void().

Equivalent to log_to_txt/8

Link to this function

log_to_txt(LogDir, Mibs, OutFile, LogName, LogFile, Block, Start, Stop)

View Source (since OTP R15B01,OTP R16B03)
-spec log_to_txt(LogDir :: snmp:dir(),
           Mibs :: [snmp:mib_name()],
           OutFile :: file:filename(),
           LogName :: string(),
           LogFile :: string(),
           Block :: boolean(),
           Start :: snmp_log:log_time(),
           Stop :: snmp_log:log_time()) ->
              snmp:void().

log_to_txt(LogDir, Mibs, OutFile, LogName, LogFile, Block, Start, Stop) -> ok | {ok, Cnt} | {error, Reason}

Converts an Audit Trail Log to a readable text file. OutFile defaults to "./snmpa_log.txt". LogName defaults to "snmpa_log". LogFile defaults to "snmpa.log".

The Block option indicates if the log should be blocked during conversion. This could be useful when converting large logs (when otherwise the log could wrap during conversion). Defaults to true.

See snmp:log_to_txt for more info.

Equivalent to me_of/2

me_of(Agent, Oid) -> {ok, Me} | {error, Reason}

Finds 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 <table>.<entry>.<col>.<any>

Equivalent to mib_of/2

mib_of(Agent, Oid) -> {ok, MibName} | {error, Reason}

Finds the mib 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 <table>.<entry>.<col>.<any>

Equivalent to name_to_oid/2

name_to_oid(Db, Name) -> {value, oid()} | false

Looks up the OBJECT IDENTIFIER of a MIB object, given the symbolic name. Note, the OBJECT IDENTIFIER is given for the object, not for an instance.

false is returned if the object is not defined in any loaded MIB.

Db is a reference to the symbolic store database (retrieved by a call to get_symbolic_store_db/0).

Equivalent to oid_to_name/2

oid_to_name(Db, OID) -> {value, Name} | false

Looks up the symbolic name of a MIB object, given OBJECT IDENTIFIER.

false is returned if the object is not defined in any loaded MIB.

Db is a reference to the symbolic store database (retrieved by a call to get_symbolic_store_db/0).

Link to this function

register_notification_filter(Id, Mod, Data)

View Source

Equivalent to register_notification_filter/5

Link to this function

register_notification_filter/4

View Source

Equivalent to register_notification_filter/5

Link to this function

register_notification_filter(Agent, Id, Mod, Data, Where)

View Source

register_notification_filter(Agent, Id, Mod, Data, Where) -> ok | {error, Reason}

Registers a notification filter.

Mod is a module implementing the snmpa_notification_filter behaviour.

Data will be passed on to the filter when calling the functions of the behaviour.

Link to this function

register_subagent(Agent, SubTree, SubAgent)

View Source

register_subagent(Agent, SubTreeOid, Subagent) -> ok | {error, Reason}

Registers a sub-agent under a sub-tree of another agent.

It is easy to make mistakes when registering sub-agents and this activity should be done carefully. For example, a strange behaviour would result from the following configuration:

snmp_agent:register_subagent(MAPid,[1,2,3,4],SA1),
snmp_agent:register_subagent(SA1,[1,2,3], SA2).

SA2 will not get requests starting with object identifier [1,2,3] since SA1 does not.

Equivalent to restart_set_worker/1

Link to this function

restart_set_worker(Agent)

View Source

restart_set_worker(Agent) -> void()

Restart the set worker process of a multi-threaded agent.

This is a utility function, that can be useful when e.g. debugging instrumentation functions.

Equivalent to restart_worker/1

restart_worker(Agent) -> void()

Restart the worker process of a multi-threaded agent.

This is a utility function, that can be useful when e.g. debugging instrumentation functions.

Link to this function

send_notification2(Agent, Notification, SendOpts)

View Source (since OTP R14B03)

send_notification2(Agent, Notification, SendOpts) -> void()

Send the notification Notification to the management targets defined for notify-name (name) in the snmpNotifyTable in SNMP-NOTIFICATION-MIB from the specified context.

If no name is specified (or if it is ""), the notification is sent to all management targets.

If no context is specified, the default context, "", is used.

The send option receiver specifies where information about delivery of Inform-Requests should be sent. The agent sends Inform-Requests and waits for acknowledgments from the management targets. The receiver can have three values:

  • no_receiver - No information is delivered.

  • notification_delivery_info() - The information is delivered via a function call according to this data. See the DATA TYPES section above for details.

  • {tag(), tag_receiver()} - The information is delivered either via messages or via a function call according to the value of tag_receiver().

    Delivery is done differently depending on the value of tag_receiver():

    • pid() | registered_name() - The info will be delivered in the following messages:

      • {snmp_targets, tag(), Addresses}

        This informs the user which target addresses the notification was sent to.

      • {snmp_notification, tag(), {got_response, Address}}

        This informs the user that this target address acknowledged the notification.

      • {snmp_notification, tag(), {no_response, Address}}

        This informs the user that this target address did not acknowledge the notification.

      The notification is sent as an Inform-Request to each target address in Addresses and if there are no targets for which an Inform-Request is sent, Addresses is the empty list [].

      The tag_receiver() will first be sent the snmp_targets message, and then for each address in Addresses list, one of the two snmp_notification messages.

    • {Mod, Func, Args} - The info will be delivered via the function call:

      Mod:Func([Msg | Args])

      where Msg has the same content and purpose as the messages descrived above.

The 'process oid' "tag" that can be provided with the variable name / oids is intended to be used for oid post processing. The value 'keep', which is the default, leaves the oid as is. The value 'truncate', will cause the oid to be "truncated". That is, any trailing ".0" will be removed.

Note

There is a way to exclude a varbind from the notification. In the normal varbinds list, providing the special value '$ignore-oid' (instead of a normal value) will exclude this varbind from the notification.

A define for this has been added to the snmp_types.hrl include file, NOTIFICATION_IGNORE_VB_VALUE.

Note

The extra info is not normally interpreted by the agent, instead it is passed through to the net-if process. It is up to the implementor of that process to make use of this data.

The version of net-if provided by this application makes no use of this data, with one exception: Any tuple containing the atom snmpa_default_notification_extra_info may be used by the agent and is therefore reserved.

See the net-if incoming messages for sending a trap and notification for more info.

Link to this function

send_notification(Agent, Notification, Recv)

View Source (since OTP R14B)

Equivalent to send_notification/7

Link to this function

send_notification(Agent, Notification, Recv, Varbinds)

View Source (since OTP R14B)

Equivalent to send_notification/7

Link to this function

send_notification(Agent, Notification, Recv, NotifyName, Varbinds)

View Source (since OTP R14B)

Equivalent to send_notification/7

Link to this function

send_notification(Agent, Notification, Recv, NotifyName, ContextName, Varbinds)

View Source (since OTP R14B)

Equivalent to send_notification/7

Link to this function

send_notification(Agent, Notification, Recv, NotifyName, ContextName, Varbinds, LocalEngineID)

View Source (since OTP R14B)

send_notification(Agent, Notification, Receiver, NotifyName, ContextName, Varbinds, LocalEngineID) -> void()

Sends the notification Notification to the management targets defined for NotifyName in the snmpNotifyTable in SNMP-NOTIFICATION-MIB from the specified context.

If no NotifyName is specified (or if it is ""), the notification is sent to all management targets (Addresses below).

If no ContextName is specified, the default "" context is used.

The parameter Receiver specifies where information about delivery of Inform-Requests should be sent. The agent sends Inform-Requests and waits for acknowledgments from the managers. Receiver can have three values:

  • no_receiver - No information is delivered.
  • notification_delivery_info() - The information is delivered via a function call according to this data. See the DATA TYPES section above for details.
  • {Tag, Recv} - The information is delivered either via messages or via a function call according to the value of Recv.

If Receiver has the value {Tag, Recv}, the delivery is done according to Recv:

  • pid() | atom() - The info will be delivered in the following messages:

    • {snmp_targets, Tag, Addresses}

      This inform the user which target addresses the notification was sent to.

    • {snmp_notification, Tag, {got_response, Address}}

      This informs the user that this target address acknowledged the notification.

    • {snmp_notification, Tag, {no_response, Address}}

      This informs the user that this target address did not acknowledge notification.

    The notification is sent as an Inform-Request to each target address in Addresses and if there are no targets for which an Inform-Request is sent, Addresses is the empty list [].

    The receiver will first be sent the snmp_targets message, and then for each address in Addresses list, one of the two snmp_notification messages.

  • {Mod, Func, Args} - The info will be delivered via the function call:

    Mod:Func([Msg | Args])

    where Msg has the same content and purpose as the messages descrived above.

Address is a management target address and Addresses is a list of management target addresses. They are defined as followes:

        Addresses  = [address()]
        Address    = address()
        address()  = v1_address() | v3_address()
        v1_address() = {TDomain, TAddress}
        v3_address() = {{TDomain, TAddress}, V3MsgData}
        TDomain    = tdoamin()
        TAddress   = taddress()
        tdomain()  = The oid of snmpUDPDomain
                     This is the only supported transport domain.
        taddress() = [A1, A2, A3, A4, P1, P3]
                     The 4 first bytes makes up the IP-address and the last 2,
                     the UDP-port number.
        V3MsgData  = v3_msg_data()
        v3_msg_data() = term()

If Receiver is a notification_delivery_info() record, then the information about the notification delivery will be delivered to the receiver via the callback functions defined by the snmpa_notification_delivery_info_receiver behaviour according to the content of the notification_delivery_info() record.

The optional argument Varbinds defines values for the objects in the notification. If no value is given for an object, the Agent performs a get-operation to retrieve the value.

Varbinds is a list of Varbind, where each Varbind is one of:

  • {Variable, Value}, where Variable is the symbolic name of a scalar variable referred to in the notification specification.
  • {Column, RowIndex, Value}, where Column is the symbolic name of a column variable. RowIndex is a list of indices for the specified element. If this is the case, the OBJECT IDENTIFIER sent in the notification is the RowIndex appended to the OBJECT IDENTIFIER for the table column. This is the OBJECT IDENTIFIER which specifies the element.
  • {OID, Value}, where OID is the OBJECT IDENTIFIER for an instance of an object, scalar variable, or column variable.

For example, to specify that sysLocation should have the value "upstairs" in the notification, we could use one of:

  • {sysLocation, "upstairs"} or
  • {[1,3,6,1,2,1,1,6,0], "upstairs"} or
  • {?sysLocation_instance, "upstairs"} (provided that the generated .hrl file is included)

If a variable in the notification is a table element, the RowIndex for the element must be given in the Varbinds list. In this case, the OBJECT IDENTIFIER sent in the notification is the OBJECT IDENTIFIER that identifies this element. This OBJECT IDENTIFIER could be used in a get operation later.

This function is asynchronous, and does not return any information. If an error occurs, user_err/2 of the error report module is called and the notification is discarded.

Note

Note that the use of the LocalEngineID argument is only intended for special cases, if the agent is to "emulate" multiple EngineIDs! By default, the agent uses the value of SnmpEngineID (see SNMP-FRAMEWORK-MIB).

ExtraInfo is not normally used in any way by the agent. It is intended to be passed along to the net-if process, which is a component that a user can implement themself. The users own net-if may then make use of ExtraInfo. The net-if provided with this application does not process ExtraInfo.

There is one exception. Any tuple containing the atom snmpa_default_notification_extra_info will, in this context, be considered belonging to this application, and may be processed by the agent.

Equivalent to set_log_type/2

Link to this function

set_log_type(Agent, NewType)

View Source

set_log_type(Agent, NewType) -> {ok, OldType} | {error, Reason}

Changes the run-time Audit Trail log type.

Note that this has no effect on the application configuration as defined by configuration files, so a node restart will revert the config to whatever is in those files.

This function is primarily useful in testing/debugging scenarios.

Link to this function

set_request_limit(NewLimit)

View Source

Equivalent to set_request_limit/2

Link to this function

set_request_limit(Agent, NewLimit)

View Source

set_request_limit(Agent, NewLimit) -> {ok, OldLimit} | {error, Reason}

Changes the request limit.

Note that this has no effect on the application configuration as defined by configuration files, so a node restart will revert the config to whatever is in those files.

This function is primarily useful in load regulation scenarios.

Link to this function

unload_mib(Mib)

View Source (since OTP R16B02)

Equivalent to unload_mib/2

Link to this function

unload_mib(Agent, Mib)

View Source (since OTP R16B02)
-spec unload_mib(Agent :: pid() | atom(), Mib :: string()) ->
              ok | {error, Reason :: not_loaded | term()}.

unload_mib(Agent, Mib) -> ok | {error, Reason}

Unload a single Mib from an agent.

Link to this function

unload_mibs(Mibs)

View Source (since OTP R16B02)

Equivalent to unload_mibs/3

Link to this function

unload_mibs/2

View Source (since OTP R16B02)

Equivalent to unload_mibs/3

Link to this function

unload_mibs(Agent, Mibs, Force)

View Source (since OTP R16B02)
-spec unload_mibs(Agent :: pid() | atom(), Mibs :: [MibName :: string()], Force :: boolean()) ->
               ok |
               {error,
                {'unload aborted at', MibName :: string(), InternalReason :: not_loaded | term()}}.

unload_mibs(Agent, Mibs, Force) -> ok | {error, Reason}

Unload Mibs from an agent. If it cannot unload all MIBs (the default value of the Force argument is false), it will indicate where unloading was aborted.

If Force = true then the agent will continue attempting to unload each mib even after failing to unload a previous mib. Use with care.

Link to this function

unregister_notification_filter(Id)

View Source

Equivalent to unregister_notification_filter/2

Link to this function

unregister_notification_filter(Agent, Id)

View Source

unregister_notification_filter(Agent, Id) -> ok | {error, Reason}

Unregister a notification filter.

Link to this function

unregister_subagent(Agent, SubOidOrPid)

View Source

unregister_subagent(Agent, SubagentOidOrPid) -> ok | {ok, SubAgentPid} | {error, Reason}

Unregister a sub-agent. If the second argument is a pid, then that sub-agent will be unregistered from all trees in Agent.

Link to this function

update_mibs_cache_age(Age)

View Source

Equivalent to update_mibs_cache_age/2

Link to this function

update_mibs_cache_age(Agent, Age)

View Source

update_mibs_cache_age(Agent, NewAge) -> ok | {error, Reason}

Change the mib server cache age property.

Link to this function

update_mibs_cache_gclimit(GcLimit)

View Source

Equivalent to update_mibs_cache_gclimit/2

Link to this function

update_mibs_cache_gclimit(Agent, GcLimit)

View Source

update_mibs_cache_gclimit(Agent, NewGCLimit) -> ok | {error, Reason}

Change the mib server cache gclimit property.

verbosity(Ref,Verbosity) -> void()

Sets verbosity for the designated process. For the lowest verbosity silence, nothing is printed. The higher the verbosity, the more is printed.

Equivalent to whereis_mib/2

whereis_mib(Agent, MibName) -> {ok, MibFile} | {error, Reason}

Get the full path to the (compiled) mib-file.

which_aliasnames() -> Result

Retrieve all alias-names known to the agent.

Equivalent to which_mibs/1

which_mibs(Agent) -> Mibs

Retrieve the list of all the mibs loaded into this agent. Default is the master agent.

Link to this function

which_mibs_cache_size()

View Source (since OTP R14B)

Equivalent to which_mibs_cache_size/1

Link to this function

which_mibs_cache_size(Agent)

View Source (since OTP R14B)

which_mibs_cache_size(Agent) -> void()

Retrieve the size of the mib server cache.

Link to this function

which_notification_filter()

View Source

Equivalent to which_notification_filter/1

Link to this function

which_notification_filter(Agent)

View Source

which_notification_filter(Agent) -> Filters

List all notification filters in an agent.

which_notifications() -> Result

Retrieve all notifications (and traps) known to the agent.

which_tables() -> Result

Retrieve all tables known to the agent.

Link to this function

which_transports()

View Source (since OTP 23.3)

which_transports() -> Result

Retrieve all configured transports.

which_variables() -> Result

Retrieve all variables known to the agent.