Erlang -- snmpa

User's Guide
Reference Manual
Release Notes
PDF
Top

Simple Network Management Protocol (SNMP)
Reference Manual
Version 4.19

Expand All
Contract All

Table of Contents

- snmp
  - Top of manual page
  - config/0
  - start/0
  - start/1
  - start_agent/0
  - start_agent/1
  - start_manager/0
  - start_manager/1
  - date_and_time/0
  - date_and_time_to_universal_time_dst/1
  - date_and_time_to_string/1
  - date_and_time_to_string/2
  - date_and_time_to_string2/1
  - local_time_to_date_and_time_dst/1
  - universal_time_to_date_and_time/1
  - validate_date_and_time/1
  - validate_date_and_time/2
  - passwd2localized_key/3
  - octet_string_to_bits/1
  - bits_to_octet_string/1
  - read_mib/1
  - log_to_txt/5
  - log_to_txt/6
  - log_to_txt/7
  - change_log_size/2
  - print_version_info/0
  - print_version_info/1
  - versions1/0
  - versions2/0
  - print_versions/1
  - print_versions/2
  - enable_trace/0
  - disable_trace/0
  - set_trace/1
  - reset_trace/1
  - set_trace/2
- snmp (App)
- snmpa
  - Top of manual page
  - add_agent_caps/2
  - del_agent_caps/1
  - get_agent_caps/0
  - get/2
  - get/3
  - get_next/2
  - get_next/3
  - backup/1
  - backup/2
  - info/0
  - info/1
  - old_info_format/1
  - load_mibs/1
  - load_mibs/2
  - unload_mibs/1
  - unload_mibs/2
  - which_mibs/0
  - which_mibs/1
  - whereis_mib/1
  - whereis_mib/2
  - current_request_id/0
  - current_context/0
  - current_community/0
  - current_address/0
  - enum_to_int/2
  - enum_to_int/3
  - int_to_enum/2
  - int_to_enum/3
  - name_to_oid/1
  - name_to_oid/2
  - oid_to_name/1
  - oid_to_name/2
  - which_aliasnames/0
  - which_tables/0
  - which_variables/0
  - which_notifications/0
  - log_to_txt/2
  - log_to_txt/3
  - log_to_txt/4
  - log_to_txt/5
  - log_to_txt/6
  - log_to_txt/7
  - change_log_size/1
  - set_log_type/1
  - set_log_type/2
  - mib_of/1
  - mib_of/2
  - me_of/1
  - me_of/2
  - invalidate_mibs_cache/0
  - invalidate_mibs_cache/1
  - enable_mibs_cache/0
  - enable_mibs_cache/1
  - disable_mibs_cache/0
  - disable_mibs_cache/1
  - which_mibs_cache_size/0
  - which_mibs_cache_size/1
  - gc_mibs_cache/0
  - gc_mibs_cache/1
  - gc_mibs_cache/1
  - gc_mibs_cache/2
  - gc_mibs_cache/2
  - gc_mibs_cache/3
  - enable_mibs_cache_autogc/0
  - enable_mibs_cache_autogc/1
  - disable_mibs_cache_autogc/0
  - disable_mibs_cache_autogc/1
  - update_mibs_cache_age/1
  - update_mibs_cache_age/2
  - update_mibs_cache_gclimit/1
  - update_mibs_cache_gclimit/2
  - register_notification_filter/3
  - register_notification_filter/4
  - register_notification_filter/4
  - register_notification_filter/5
  - unregister_notification_filter/1
  - unregister_notification_filter/2
  - which_notification_filter/0
  - which_notification_filter/1
  - set_request_limit/1
  - set_request_limit/2
  - register_subagent/3
  - unregister_subagent/2
  - send_notification/3
  - send_notification/4
  - send_notification/5
  - send_notification/6
  - send_notification/7
  - discovery/2
  - discovery/3
  - discovery/3
  - discovery/4
  - discovery/4
  - discovery/5
  - discovery/6
  - convert_config/1
  - restart_worker/0
  - restart_worker/1
  - restart_set_worker/0
  - restart_set_worker/1
  - print_mib_info/0
  - print_mib_tables/0
  - print_mib_variables/0
  - verbosity/2
- snmpa_conf
  - Top of manual page
  - agent_entry/2
  - write_agent_config/2
  - write_agent_config/3
  - append_agent_config/2
  - read_agent_config/1
  - standard_entry/2
  - write_standard_config/2
  - write_standard_config/3
  - append_standard_config/2
  - read_standard_config/1
  - context_entry/1
  - write_context_config/2
  - write_context_config/3
  - append_context_config/2
  - read_context_config/1
  - community_entry/1
  - community_entry/5
  - write_community_config/2
  - write_community_config/3
  - append_community_config/2
  - read_community_config/1
  - target_addr_entry/5
  - target_addr_entry/6
  - target_addr_entry/8
  - target_addr_entry/10
  - write_target_addr_config/2
  - write_target_addr_config/3
  - append_target_addr_config/2
  - read_target_addr_config/1
  - target_params_entry/2
  - target_params_entry/4
  - target_params_entry/5
  - write_target_params_config/2
  - write_target_params_config/3
  - append_target_params_config/2
  - read_target_params_config/1
  - vacm_s2g_entry/3
  - vacm_acc_entry/8
  - vacm_vtf_entry/2
  - vacm_vtf_entry/4
  - write_vacm_config/2
  - write_vacm_config/3
  - append_vacm_config/2
  - read_vacm_config/1
  - usm_entry/1
  - usm_entry/13
  - write_usm_config/2
  - write_usm_config/3
  - append_usm_config/2
  - read_usm_config/1
  - notify_entry/3
  - write_notify_config/2
  - write_notify_config/3
  - append_notify_config/2
  - read_notify_config/1
- snmpa_discovery_handler
  - Top of manual page
  - stage1_finish/3
- snmpa_error_report
  - Top of manual page
  - config_err/2
  - user_err/2
- snmpa_error
  - Top of manual page
  - config_err/2
  - user_err/2
- snmpa_error_io
  - Top of manual page
  - config_err/2
  - user_err/2
- snmpa_error_logger
  - Top of manual page
  - config_err/2
  - user_err/2
- snmpa_local_db
  - Top of manual page
  - dump/0
  - match/2
  - print/0
  - print/1
  - print/2
  - table_create/1
  - table_create_row/3
  - table_delete/1
  - table_delete_row/2
  - table_exists/1
  - table_get_row/2
- snmpa_mpd
  - Top of manual page
  - init/1
  - process_packet/6
  - process_packet/7
  - generate_response_msg/5
  - generate_response_msg/6
  - generate_msg/5
  - generate_msg/6
  - discarded_pdu/1
- snmpa_network_interface
  - Top of manual page
  - start_link/4
  - info/1
  - verbosity/2
  - get_log_type/1
  - set_log_type/2
- snmpa_network_interface_filter
  - Top of manual page
  - accept_recv/2
  - accept_send/2
  - accept_recv_pdu/3
  - accept_send_pdu/2
- snmpa_notification_delivery_info_receiver
  - Top of manual page
  - delivery_targets/3
  - delivery_info/4
- snmpa_notification_filter
  - Top of manual page
  - handle_notification/2
- snmpa_supervisor
  - Top of manual page
  - start_sub_sup/1
  - start_master_sup/1
  - start_sub_agent/3
  - stop_sub_agent/1
- snmp_community_mib
  - Top of manual page
  - configure/1
  - reconfigure/1
  - add_community/5
  - delete_community/1
- snmp_framework_mib
  - Top of manual page
  - configure/1
  - init/0
  - add_context/1
  - delete_context/1
- snmp_generic
  - Top of manual page
  - get_status_col/2
  - get_status_col/2
  - get_index_types/1
  - table_func/2
  - table_func/4
  - table_get_elements/3
  - table_next/2
  - table_row_exists/2
  - table_set_elements/3
  - variable_func/2
  - variable_func/3
  - variable_get/1
  - variable_set/2
- snmp_index
  - Top of manual page
  - delete/1
  - delete/2
  - get/2
  - get_last/1
  - get_next/2
  - insert/3
  - key_to_oid/2
  - new/1
- snmp_notification_mib
  - Top of manual page
  - configure/1
  - reconfigure/1
  - add_notify/3
  - delete_notify/1
- snmp_pdus
  - Top of manual page
  - dec_message/1
  - dec_message_only/1
  - dec_pdu/1
  - dec_scoped_pdu/1
  - dec_scoped_pdu_data/1
  - dec_usm_security_parameters/1
  - enc_encrypted_scoped_pdu/1
  - enc_message/1
  - enc_message_only/1
  - enc_pdu/1
  - enc_scoped_pdu/1
  - enc_usm_security_parameters/1
- snmp_standard_mib
  - Top of manual page
  - configure/1
  - inc/1
  - inc/2
  - reconfigure/1
  - reset/0
  - sys_up_time/0
- snmp_target_mib
  - Top of manual page
  - configure/1
  - reconfigure/1
  - set_target_engine_id/2
  - add_addr/10
  - delete_addr/1
  - add_params/5
  - delete_params/1
- snmp_user_based_sm_mib
  - Top of manual page
  - configure/1
  - reconfigure/1
  - add_user/13
  - delete_user/1
- snmp_view_based_acm_mib
  - Top of manual page
  - configure/1
  - reconfigure/1
  - add_sec2group/3
  - delete_sec2group/1
  - add_access/8
  - delete_access/1
  - add_view_tree_fam/4
  - delete_view_tree_fam/1
- snmpc
  - Top of manual page
  - compile/1
  - compile/2
  - is_consistent/1
  - mib_to_hrl/1
- snmpc(command)
- snmpm
  - Top of manual page
  - monitor/0
  - demonitor/1
  - notify_started/1
  - cancel_notify_started/1
  - register_user/3
  - register_user/4
  - register_user_monitor/3
  - register_user_monitor/4
  - unregister_user/1
  - which_users/0
  - register_agent/3
  - unregister_agent/2
  - agent_info/2
  - update_agent_info/4
  - which_agents/0
  - which_agents/1
  - register_usm_user/3
  - unregister_usm_user/2
  - usm_user_info/3
  - update_usm_user_info/4
  - which_usm_users/0
  - which_usm_users/1
  - sync_get/3
  - sync_get/4
  - sync_get/4
  - sync_get/5
  - sync_get/6
  - async_get/3
  - async_get/4
  - async_get/4
  - async_get/5
  - async_get/6
  - sync_get_next/3
  - sync_get_next/4
  - sync_get_next/4
  - sync_get_next/5
  - sync_get_next/6
  - async_get_next/3
  - async_get_next/4
  - async_get_next/4
  - async_get_next/5
  - async_get_next/6
  - sync_set/3
  - sync_set/4
  - sync_set/4
  - sync_set/5
  - sync_set/6
  - async_set/3
  - async_set/4
  - async_set/4
  - async_set/5
  - async_set/6
  - sync_get_bulk/5
  - sync_get_bulk/6
  - sync_get_bulk/6
  - sync_get_bulk/7
  - sync_get_bulk/8
  - async_get_bulk/5
  - async_get_bulk/6
  - async_get_bulk/6
  - async_get_bulk/7
  - async_get_bulk/8
  - cancel_async_request/2
  - log_to_txt/2
  - log_to_txt/3
  - log_to_txt/4
  - log_to_txt/5
  - log_to_txt/6
  - log_to_txt/7
  - change_log_size/1
  - set_log_type/1
  - load_mib/1
  - unload_mib/1
  - which_mibs/0
  - name_to_oid/1
  - oid_to_name/1
  - oid_to_type/1
  - backup/1
  - info/0
  - verbosity/2
  - format_reason/1
  - format_reason/2
- snmpm_conf
  - Top of manual page
  - manager_entry/2
  - write_manager_config/2
  - write_manager_config/3
  - append_manager_config/2
  - read_manager_config/1
  - users_entry/1
  - users_entry/2
  - users_entry/3
  - write_users_config/2
  - write_users_config/3
  - append_users_config/2
  - read_users_config/1
  - agents_entry/12
  - write_agents_config/2
  - write_agents_config/3
  - append_agents_config/2
  - read_agents_config/1
  - usm_entry/6
  - usm_entry/7
  - write_usm_config/2
  - write_usm_config/3
  - append_usm_config/2
  - read_usm_config/1
- snmpm_mpd
  - Top of manual page
  - init_mpd/1
  - process_msg/7
  - generate_msg/5
  - generate_response_msg/4
- snmpm_network_interface
  - Top of manual page
  - start_link/2
  - stop/1
  - send_pdu/7
  - inform_response/4
  - note_store/2
  - info/1
  - verbosity/2
  - get_log_type/1
  - set_log_type/2
- snmpm_user
  - Top of manual page
  - handle_error/3
  - handle_agent/5
  - handle_pdu/4
  - handle_trap/3
  - handle_inform/3
  - handle_report/3
- snmpm_network_interface_filter
  - Top of manual page
  - accept_recv/2
  - accept_send/2
  - accept_recv_pdu/3
  - accept_send_pdu/3

# snmpa

### MODULE

snmpa

### MODULE SUMMARY

Interface Functions to the SNMP toolkit agent

### DESCRIPTION

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.

### EXPORTS

add_agent_caps(SysORID, SysORDescr) -> SysORIndex

Types:

SysORID = oid()
SysORDescr = string()
SysORIndex = integer()

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.

del_agent_caps(SysORIndex) -> void()

Types:

SysORIndex = integer()

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.

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

Types:

SysORIndex = integer()
SysORId = oid()
SysORDescr = string()
SysORUpTime = integer()

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

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

Types:

Agent = pid() | atom()
Vars = [oid()]
Context = string()
Values = [term()]
Reason = {atom(), oid()}

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_next(Agent, Vars) -> Values | {error, Reason}
get_next(Agent, Vars, Context) -> Values | {error, Reason}

Types:

Agent = pid() | atom()
Vars = [oid()]
Context = string()
Values = [{oid(), term()}]
Reason = {atom(), oid()}

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.

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

Types:

BackupDir = string()
Agent = pid() | atom()

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.

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

Types:

Agent = pid() | atom()

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

As of version 4.4 the format of the info has been changed. To convert the info to the old format, call the old_info_format function.

old_info_format(NewInfo) -> OldInfo

Types:

OldInfo = NewInfo = [{Key, Value}]

As of version 4.4 the format of the info has been changed. This function is used to convert to the old (pre-4.4) info format.

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

Types:

Agent = pid() | atom()
Mibs = [MibName]
MibName = string()
Reason = term()

Loads Mibs into an agent. If the agent cannot load all MIBs, 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"]).

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

Types:

Agent = pid() | atom()
Mibs = [MibName]
MibName = string()

Unloads MIBs into an agent. If it cannot unload all MIBs, it will indicate where unloading was aborted.

which_mibs() -> Mibs
which_mibs(Agent) -> Mibs

Types:

Agent = pid() | atom()
Mibs = [{MibName, MibFile}]
MibName = atom()
MibFile = string()

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

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

Types:

Agent = pid() | atom()
MibName = atom()
MibFile = string()
Reason = term()

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

current_request_id() -> {value, RequestId} | false
current_context() -> {value, Context} | false
current_community() -> {value, Community} | false
current_address() -> {value, Address} | false

Types:

RequestId = integer()
Context = string()
Community = string()
Address = term()

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

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

Types:

Db = term()
Name = atom()
Enum = atom()
Int = int()

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

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

Types:

Db = term()
Name = atom()
Int = int()
Enum = atom()

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

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

Types:

Db = term()
Name = atom()

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

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

Types:

Db = term()
OID = oid()
Name = atom()

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

which_aliasnames() -> Result

Types:

Result = [atom()]

Retrieve all alias-names known to the agent.

which_tables() -> Result

Types:

Result = [atom()]

Retrieve all tables known to the agent.

which_variables() -> Result

Types:

Result = [atom()]

Retrieve all variables known to the agent.

which_notifications() -> Result

Types:

Result = [{Name, MibName, Info}]
Name = atom()
MibName = atom()
Info = term()

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

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

Types:

LogDir = string()
Mibs = [MibName]
MibName = string()
OutFile = string()
LogName = string()
LogFile = string()
Start = Stop = null | datetime() | {local_time,datetime()} | {universal_time,datetime()}
Reason = disk_log_open_error() | file_open_error() | term()
disk_log_open_error() = {LogName, term()}
file_open_error() = {OutFile, term()}

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". See snmp:log_to_txt for more info.

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

Types:

NewSize = {MaxBytes, MaxFiles}
MaxBytes = integer()
MaxFiles = integer()
Reason = term()

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.

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

Types:

NewType = OldType = atl_type()
Agent = pid() | atom()
Reason = term()

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.

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

Types:

Agent = pid() | atom()
Oid = oid()
MibName = atom()
Reason = term()

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>

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

Types:

Agent = pid() | atom()
Oid = oid()
Me = #me{}
Reason = term()

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>

invalidate_mibs_cache() -> void()
invalidate_mibs_cache(Agent) -> void()

Types:

Agent = pid() | atom()

Invalidate the mib server cache.

The entire contents of the cache will be deleted.

enable_mibs_cache() -> void()
enable_mibs_cache(Agent) -> void()

Types:

Agent = pid() | atom()

Enable the mib server cache.

disable_mibs_cache() -> void()
disable_mibs_cache(Agent) -> void()

Types:

Agent = pid() | atom()

Disable the mib server cache.

which_mibs_cache_size() -> void()
which_mibs_cache_size(Agent) -> void()

Types:

Agent = pid() | atom()

Retreive the size of the mib server cache.

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

Types:

Agent = pid() | atom()
Age = integer() > 0
GcLimit = integer() > 0 | infinity
NumElementsGCed = integer() >= 0
Reason = term()

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.

enable_mibs_cache_autogc() -> void()
enable_mibs_cache_autogc(Agent) -> void()

Types:

Agent = pid() | atom()

Enable automatic gc of the mib server cache.

disable_mibs_cache_autogc() -> void()
disable_mibs_cache_autogc(Agent) -> void()

Types:

Agent = pid() | atom()

Disable automatic gc of the mib server cache.

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

Types:

Agent = pid() | atom()
NewAge = integer() > 0
Reason = term()

Change the mib server cache age property.

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

Types:

Agent = pid() | atom()
NewGcLimit = integer() > 0 | infinity
Reason = term()

Change the mib server cache gclimit property.

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

Types:

Agent = pid() | atom()
Id = filter_id()
filter_id() = term()
Mod = atom()
Data = term()
Where = filter_position()
Reason = term()
filter_position() = first | last | {insert_before, filter_id()} | {insert_after, filter_id()}

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.

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

Types:

Agent = pid() | atom()
Id = filter_id()
filter_id() = term()

Unregister a notification filter.

which_notification_filter() -> Filters
which_notification_filter(Agent) -> Filters

Types:

Agent = pid() | atom()
Filters = [filter_id()]
filter_id() = term()

List all notification filters in an agent.

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

Types:

NewLimit = OldLimit = infinity | integer() >= 0
Agent = pid() | atom()
Reason = term()

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.

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

Types:

Agent = pid() | atom()
SubTreeOid = oid()
SubAgent = pid()

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.

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

Types:

Agent = pid() | atom()
SubTreeOidorPid = oid() | pid()

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

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

Types:

Agent = pid() | atom()
Notification = atom()
Receiver = no_receiver | {Tag, Recv} | notification_delivery_info()
Tag = term()
Recv = receiver()
receiver() = pid() | atom() | {Mod, Func, Args}
Mod = atom()
Func = atom()
Args = list()
NotifyName = string()
ContextName = string()
Varbinds = varbinds()
varbinds() = [varbind()]
varbind() = {Variable, Value} | {Column, RowIndex, Value} | {OID, Value}
Variable = atom()
Column = atom()
OID = oid()
Value = term()
RowIndex = [int()]
LocalEngineID = string()

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.

- {Tag, Recv} - The information is delivered either via messages or via a function call according to the value of Recv.

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

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

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

Types:

TargetName = string()
Notification = atom()
ContextName = string() (defaults to "")
Varbinds = varbinds()
varbinds() = [varbind()]
DiscoHandler = snmpa_discovery_handler()
ExtraInfo = term()
snmpa_discovery_handler() = Module implementing the snmpa_discovery_handler behaviour
ManagerEngineID = string()
varbind() = {Variable, Value} | {Column, RowIndex, Value} | {OID, Value}
Variable = atom()
Column = atom()
OID = oid()
Value = term()
RowIndex = [int()]
Reason = term()

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.

convert_config(OldConfig) -> AgentConfig

Types:

OldConfig = list()
AgentConfig = list()

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 either the SNMP application part of the reference manual or the Configuring the application chapter of the SNMP user's guide.

restart_worker() -> void()
restart_worker(Agent) -> void()

Types:

Agent = pid() | atom()

Restart the worker process of a multi-threaded agent.

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

restart_set_worker() -> void()
restart_set_worker(Agent) -> void()

Types:

Agent = pid() | atom()

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.

print_mib_info() -> void()

Prints the content of all the (snmp) tables and variables for all mibs handled by the snmp agent.

print_mib_tables() -> void()

Prints the content of all the (snmp) tables for all mibs handled by the snmp agent.

print_mib_variables() -> void()

Prints the content of all the (snmp) variables for all mibs handled by the snmp agent.

verbosity(Ref,Verbosity) -> void()

Types:

Ref = pid() | sub_agents | master_agent | net_if | mib_server | symbolic_store | note_store | local_db
Verbosity = verbosity() | {subagents, verbosity()}
verbosity() = silence | info | log | debug | trace

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

### See Also

calendar(3), erlc(1)