Search documentation of snmp

# View Source snmp (snmp v5.16)

Interface functions to the SNMP toolkit

The module `snmp` contains interface functions to the SNMP toolkit.

## See Also

calendar(3)

# Summary

## Types

algorithm()
asn1_type()
atl_type()
bits()

The Erlang representation of the SNMP BITS (pseudo) data type.

column()
community()
context_name()
date_and_time_validator()

The input to the validator fun looks like this

date_and_time_validator_kind()
dir()

A string, that is a file path to a directory.

engine_id()
error_index()

`0` is used when error status is `noError` and when error status is an actual error; error index is `pos_integer/0`.

error_status()

We should really specify all of these, but they are so numerous... Also, normally all you need to know is that `'noError'` is ok and everything else is an error.

ivarbind()
log_size()

This is basically a copy of the dlog_size().

log_time()
me()
mib()
mib_name()
mms()
notification()
octet()
octet_string()
oid()

Represent an ASN.1 OBJECT IDENTIFIER.

pdu()
pdu_type()
rfc1903_date_and_time()

The data type DateAndTime, an OCTET STRING, as specified in RFC1903.

row_index()

Denotes the last part of the OID which specifies the index of the row in the table (see RFC1212, 4.1.6 for more information about INDEX).

row_pointer()

> #### Note

> "Represents a pointer to a conceptual row. The value is the name of the instance of the first accessible columnar object in the conceptual row."

sec_level()
sec_model()
sec_name()
snmp_timer()
table_info()
taddress()
tdomain()
time_interval()

> #### Note

> "A period of time, measured in units of 0.01 seconds."

trap()
trappdu()
usm_auth_key()
usm_auth_protocol()
usm_name()
usm_priv_key()
usm_priv_protocol()
varbind()
variable_info()
verbosity()

For the lowest verbosity `silence`, nothing is printed. The higher the verbosity, the more is printed.

version()
void()

The type is used when a functions return is to be ignored.

## Functions

bits_to_octet_string(B)

Utility function for converting a value of type `BITS` to `OCTET-STRING`, according to RFC1906, section 8.

change_log_size(LogName, NewSize)

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.

config()

A simple interactive configuration tool. Simple configuration files can be generated, but more complex configurations still have to be edited manually.

date_and_time()

Returns current date and time as the data type DateAndTime, as specified in RFC1903. This is an OCTET STRING.

date_and_time_to_string2(DAT)

Converts a DateAndTime list to a printable string, according to the DISPLAY-HINT definition in RFC2579, with the extension that it also allows the values "hours from UTC" = 14 together with "minutes from UTC" = 0.

date_and_time_to_string(DAT)

Equivalent to `date_and_time_to_string/2`.

date_and_time_to_string(DAT, Validate)

Converts a DateAndTime list to a printable string, according to the DISPLAY-HINT definition in RFC2579.

date_and_time_to_universal_time_dst(DAT)

Converts a DateAndTime list to a list of possible universal time(s). The universal time value on the same format as defined in calendar(3).

disable_trace()

Stop the tracer.

enable_trace()

Starts a dbg tracer that prints trace events to stdout (using plain io:format after a minor formatting).

local_time_to_date_and_time_dst(Local)

Converts a local time value to a list of possible DateAndTime list(s). The local time value on the same format as defined in calendar(3).

log_to_io(LogDir, Mibs, LogName, LogFile)

Equivalent to `log_to_io/7`.

log_to_io/5

Equivalent to `log_to_io/7`.

log_to_io/6

Equivalent to `log_to_io/7`.

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

Converts an Audit Trail Log to a readable format and prints it on stdio. See `log_to_txt/8` for more info.

log_to_txt(LogDir, Mibs, OutFile, LogName, LogFile)

Equivalent to `log_to_txt/8`.

log_to_txt/6

Equivalent to `log_to_txt/8`.

log_to_txt/7

Equivalent to `log_to_txt/8`.

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

Converts an Audit Trail Log to a readable text file, where each item has a trailing TAB character, and any TAB character in the body of an item has been replaced by ESC TAB.

octet_string_to_bits(S)

Utility function for converting a value of type `OCTET-STRING` to `BITS`, according to RFC1906, section 8.

passwd2localized_key(Algorithm, Passwd, EngineID)

Generates a key that can be used as an authentication or privacy key using MD5, SHA, SHA224, SHA256, SHA384 or SHA512. The key is localized for EngineID.

print_version_info()

Equivalent to `print_version_info/1`.

print_version_info(Prefix)

Utility function(s) to produce a formatted printout of the versions info generated by the `versions1` function

print_versions(Versions)

Equivalent to `print_versions/2`.

print_versions(Prefix, Versions)

Utility function to produce a formatted printout of the versions info generated by the `versions1` and `versions2` functions

read_mib(FileName)

Read a compiled mib.

reset_trace(Targets)

This function is used to reset (disable) trace for the given module(s).

set_trace(Targets)

This function is used to set up default trace on function(s) for the given module or modules. The scope of the trace will be all exported functions (both the call info and the return value). Timestamp info will also be included.

set_trace(Targets, TraceOpts)

This function is used to set up trace on function(s) for the given module or modules.

start()

Equivalent to `start/1`.

start(Type)

Starts the SNMP application.

start_agent()

Equivalent to `start_agent/1`.

start_agent(Type)

The SNMP application consists of several entities, of which the agent is one. This function starts the agent entity of the application.

start_manager()

Equivalent to `start_manager/1`.

start_manager(Type)

The SNMP application consists of several entities, of which the manager is one. This function starts the manager entity of the application.

stop()

Stops the SNMP application.

universal_time_to_date_and_time(UTC)

Converts a universal time value to a DateAndTime list. The universal time value on the same format as defined in calendar(3).

validate_date_and_time(DateAndTime)

Equivalent to `validate_date_and_time/2`.

validate_date_and_time(DateAndTime, Validate)

Checks if `DateAndTime` is a correct DateAndTime value, as specified in RFC2579. This function can be used in instrumentation functions to validate a DateAndTime value.

versions1()

Equivalent to `versions2/0`.

versions2()

Utility functions used to retrieve some system and application info.

# Types

Link to this type

# algorithm()

View Source (not exported)

    -type algorithm() :: md5 | sha | sha224 | sha256 | sha384 | sha512.

Link to this type

# asn1_type()

View Source

    -type asn1_type() ::
              #asn1_type{bertype :: term(),
                         lo :: term(),
                         hi :: term(),
                         assocList :: term(),
                         imported :: term(),
                         aliasname :: term(),
                         implied :: term(),
                         display_hint :: term()}.

Link to this type

# atl_type()

View Source

    -type atl_type() :: read | write | read_write.

Link to this type

# bits()

View Source

    -type bits() :: integer().

The Erlang representation of the SNMP BITS (pseudo) data type.

Link to this type

# column()

View Source

    -type column() :: pos_integer().

Link to this type

# community()

View Source

    -type community() :: snmp_community_mib:name().

Link to this type

# context_name()

View Source

    -type context_name() :: snmp_community_mib:context_name().

Link to this type

# date_and_time_validator()

View Source

    -type date_and_time_validator() ::
              fun((Kind :: date_and_time_validator_kind(), Data :: term()) -> boolean()).

The input to the validator fun looks like this:

    	  Kind             Data
    	  --------------   ----------------------
    	  year             {Year1, Year2}
    	  month            Month
    	  day              Day
    	  hour             Hour
    	  minute           Minute
    	  seconds          Seconds
    	  deci_seconds     DeciSeconds
    	  diff             [Sign, Hour, Minute]
    	  valid_date       {Year, Month, Day}

Link to this type

# date_and_time_validator_kind()

View Source

    -type date_and_time_validator_kind() ::
              year | month | day | hour | minute | seconds | deci_seconds | diff | valid_date.

Link to this type

# dir()

View Source

    -type dir() :: string().

A string, that is a file path to a directory.

Link to this type

# engine_id()

View Source

    -type engine_id() :: snmp_framework_mib:engine_id().

Link to this type

# error_index()

View Source

    -type error_index() :: non_neg_integer().

`0` is used when error status is `noError` and when error status is an actual error; error index is `pos_integer/0`.

Link to this type

# error_status()

View Source

    -type error_status() :: noError | atom().

We should really specify all of these, but they are so numerous... Also, normally all you need to know is that `'noError'` is ok and everything else is an error.

Link to this type

# ivarbind()

View Source

    -type ivarbind() :: #ivarbind{status :: term(), mibentry :: term(), varbind :: term()}.

Link to this type

# log_size()

View Source

    -type log_size() ::
              infinity | pos_integer() | {MaxNoBytes :: pos_integer(), MaxNoFiles :: pos_integer()}.

This is basically a copy of the dlog_size().

Link to this type

# log_time()

View Source

    -type log_time() ::
              calendar:datetime() |
              {local_time, calendar:datetime()} |
              {universal_time, calendar:datetime()}.

Link to this type

# me()

View Source

    -type me() ::
              #me{oid :: term(),
                  entrytype :: term(),
                  aliasname :: term(),
                  asn1_type :: term(),
                  access :: term(),
                  mfa :: term(),
                  imported :: term(),
                  assocList :: term(),
                  description :: term(),
                  units :: term()}.

Link to this type

# mib()

View Source

    -type mib() ::
              #mib{misc :: term(),
                   mib_format_version :: term(),
                   name :: term(),
                   module_identity :: term(),
                   mes :: term(),
                   asn1_types :: term(),
                   traps :: term(),
                   variable_infos :: term(),
                   table_infos :: term(),
                   imports :: term()}.

Link to this type

# mib_name()

View Source

    -type mib_name() :: string().

Link to this type

# mms()

View Source

    -type mms() :: snmp_framework_mib:max_message_size().

Link to this type

# notification()

View Source

    -type notification() ::
              #notification{trapname :: term(), oid :: term(), oidobjects :: term(), description :: term()}.

Link to this type

# octet()

View Source

    -type octet() :: 0..255.

Link to this type

# octet_string()

View Source

    -type octet_string() :: [octet()].

Link to this type

# oid()

View Source

    -type oid() :: [non_neg_integer()].

Represent an ASN.1 OBJECT IDENTIFIER.

Link to this type

# pdu()

View Source

    -type pdu() ::
              #pdu{type :: term(),
                   request_id :: term(),
                   error_status :: term(),
                   error_index :: term(),
                   varbinds :: term()}.

Link to this type

# pdu_type()

View Source

    -type pdu_type() :: snmp_pdus:pdu_type().

Link to this type

# rfc1903_date_and_time()

View Source

    -type rfc1903_date_and_time() :: octet_string().

The data type DateAndTime, an OCTET STRING, as specified in RFC1903.

Link to this type

# row_index()

View Source

    -type row_index() :: oid().

Denotes the last part of the OID which specifies the index of the row in the table (see RFC1212, 4.1.6 for more information about INDEX).

Link to this type

# row_pointer()

View Source

    -type row_pointer() :: oid().

> #### Note

> "Represents a pointer to a conceptual row. The value is the name of the instance of the first accessible columnar object in the conceptual row."

`OBJECT IDENTIFIER`

Defined by SNMPv2-TC.

Link to this type

# sec_level()

View Source

    -type sec_level() :: snmp_framework_mib:security_level().

Link to this type

# sec_model()

View Source

    -type sec_model() :: snmp_framework_mib:security_model().

Link to this type

# sec_name()

View Source

    -type sec_name() :: snmp_framework_mib:admin_string().

Link to this type

# snmp_timer()

View Source

    -type snmp_timer() ::
              #snmp_incr_timer{wait_for :: term(), factor :: term(), incr :: term(), max_retries :: term()}.

Link to this type

# table_info()

View Source

    -type table_info() ::
              #table_info{nbr_of_cols :: term(),
                          defvals :: term(),
                          status_col :: term(),
                          not_accessible :: term(),
                          index_types :: term(),
                          first_accessible :: term(),
                          first_own_index :: term()}.

Link to this type

# taddress()

View Source

    -type taddress() :: snmpa_conf:transportAddress().

Link to this type

# tdomain()

View Source

    -type tdomain() :: transportDomainUdpIpv4 | transportDomainUdpIpv6.

Link to this type

# time_interval()

View Source

    -type time_interval() :: 0..2147483647.

> #### Note

> "A period of time, measured in units of 0.01 seconds."

`INTEGER (0..2147483647)`

Defined by SNMPv2-TC.

Link to this type

# trap()

View Source

    -type trap() ::
              #trap{trapname :: term(),
                    enterpriseoid :: term(),
                    specificcode :: term(),
                    oidobjects :: term(),
                    description :: term()}.

Link to this type

# trappdu()

View Source

    -type trappdu() ::
              #trappdu{enterprise :: term(),
                       agent_addr :: term(),
                       generic_trap :: term(),
                       specific_trap :: term(),
                       time_stamp :: term(),
                       varbinds :: term()}.

Link to this type

# usm_auth_key()

View Source

    -type usm_auth_key() :: snmp_user_based_sm_mib:auth_key().

Link to this type

# usm_auth_protocol()

View Source

    -type usm_auth_protocol() :: snmp_user_based_sm_mib:auth_protocol().

Link to this type

# usm_name()

View Source

    -type usm_name() :: snmp_user_based_sm_mib:name().

Link to this type

# usm_priv_key()

View Source

    -type usm_priv_key() :: snmp_user_based_sm_mib:priv_key().

Link to this type

# usm_priv_protocol()

View Source

    -type usm_priv_protocol() :: snmp_user_based_sm_mib:priv_protocol().

Link to this type

# varbind()

View Source

    -type varbind() :: #varbind{oid :: term(), variabletype :: term(), value :: term(), org_index :: term()}.

Link to this type

# variable_info()

View Source

    -type variable_info() :: #variable_info{defval :: term()}.

Link to this type

# verbosity()

View Source

    -type verbosity() :: silence | info | log | debug | trace.

For the lowest verbosity `silence`, nothing is printed. The higher the verbosity, the more is printed.

Link to this type

# version()

View Source

    -type version() :: v1 | v2 | v3.

Link to this type

# void()

View Source

    -type void() :: term().

The type is used when a functions return is to be ignored.

# Functions

Link to this function

# bits_to_octet_string(B)

View Source

    -spec bits_to_octet_string(B) -> octet_string() when B :: bits().

Utility function for converting a value of type `BITS` to `OCTET-STRING`, according to RFC1906, section 8.

Link to this function

# change_log_size(LogName, NewSize)

View Source

    -spec change_log_size(LogName, NewSize) -> ok | {error, Reason}
                             when LogName :: string(), NewSize :: log_size(), 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.

Link to this function

# config()

View Source

    -spec config() -> ok | {error, Reason} when Reason :: term().

A simple interactive configuration tool. Simple configuration files can be generated, but more complex configurations still have to be edited manually.

The tool is a textual based tool that asks some questions and generates `sys.config` and `*.conf` files.

Note that if the application shall support version 3, then the crypto app must be started before running this function (password generation).

Note also that some of the configuration files for the agent and manager share the same names. This means that they have to be stored in different directories!

Link to this function

# date_and_time()

View Source

    -spec date_and_time() -> DateAndTime when DateAndTime :: rfc1903_date_and_time().

Returns current date and time as the data type DateAndTime, as specified in RFC1903. This is an OCTET STRING.

Link to this function

# date_and_time_to_string2(DAT)

View Source

    -spec date_and_time_to_string2(DAT) -> string() when DAT :: rfc1903_date_and_time().

Converts a DateAndTime list to a printable string, according to the DISPLAY-HINT definition in RFC2579, with the extension that it also allows the values "hours from UTC" = 14 together with "minutes from UTC" = 0.

Link to this function

# date_and_time_to_string(DAT)

View Source

    -spec date_and_time_to_string(DAT) -> string() when DAT :: rfc1903_date_and_time().

Equivalent to `date_and_time_to_string/2`.

Link to this function

# date_and_time_to_string(DAT, Validate)

View Source

    -spec date_and_time_to_string(DAT, Validate) -> string()
                                     when
                                         DAT :: rfc1903_date_and_time(),
                                         Validate :: date_and_time_validator().

Converts a DateAndTime list to a printable string, according to the DISPLAY-HINT definition in RFC2579.

The validation fun, `Validate`, allows for a more "flexible" validation of the `DateAndTime` argument. Whenever the data is found to not follow RFC2579, the fun is called to allow a more "lax" validation. See the `validate_date_and_time/2` function for more info on the `Validate` fun.

Link to this function

# date_and_time_to_universal_time_dst(DAT)

View Source

    -spec date_and_time_to_universal_time_dst(DAT) -> UTCs
                                                 when
                                                     DAT :: rfc1903_date_and_time(),
                                                     UTCs :: [calendar:datetime1970()].

Converts a DateAndTime list to a list of possible universal time(s). The universal time value on the same format as defined in calendar(3).

Link to this function

# disable_trace()

View Source

    -spec disable_trace() -> void().

Stop the tracer.

Link to this function

# enable_trace()

View Source

    -spec enable_trace() -> void().

Starts a dbg tracer that prints trace events to stdout (using plain io:format after a minor formatting).

Link to this function

# local_time_to_date_and_time_dst(Local)

View Source

    -spec local_time_to_date_and_time_dst(Local) -> DATs
                                             when
                                                 Local :: calendar:datetime1970(),
                                                 DATs :: [rfc1903_date_and_time()].

Converts a local time value to a list of possible DateAndTime list(s). The local time value on the same format as defined in calendar(3).

Link to this function

# log_to_io(LogDir, Mibs, LogName, LogFile)

View Source (since OTP R15B01)

    -spec log_to_io(LogDir, Mibs, LogName, LogFile) -> ok | {ok, Cnt} | {error, Reason}
                       when
                           LogDir :: string(),
                           Mibs :: [mib_name()],
                           LogName :: string(),
                           LogFile :: string(),
                           Cnt :: {NumOK, NumERR},
                           NumOK :: non_neg_integer(),
                           NumERR :: pos_integer(),
                           Reason :: term().

Equivalent to `log_to_io/7`.

Link to this function

# log_to_io/5

View Source (since OTP R15B01)

    -spec log_to_io(LogDir, Mibs, LogName, LogFile, Block) -> ok | {ok, Cnt} | {error, Reason}
                       when
                           LogDir :: string(),
                           Mibs :: [mib_name()],
                           LogName :: string(),
                           LogFile :: string(),
                           Block :: boolean(),
                           Cnt :: {NumOK, NumERR},
                           NumOK :: non_neg_integer(),
                           NumERR :: pos_integer(),
                           Reason :: term();
                   (LogDir, Mibs, LogName, LogFile, Start) -> ok | {ok, Cnt} | {error, Reason}
                       when
                           LogDir :: string(),
                           Mibs :: [mib_name()],
                           LogName :: string(),
                           LogFile :: string(),
                           Start :: null | log_time(),
                           Cnt :: {NumOK, NumERR},
                           NumOK :: non_neg_integer(),
                           NumERR :: pos_integer(),
                           Reason :: term().

Equivalent to `log_to_io/7`.

Link to this function

# log_to_io/6

View Source (since OTP R15B01)

    -spec log_to_io(LogDir, Mibs, LogName, LogFile, Block, Start) -> ok | {ok, Cnt} | {error, Reason}
                       when
                           LogDir :: string(),
                           Mibs :: [mib_name()],
                           LogName :: string(),
                           LogFile :: string(),
                           Block :: boolean(),
                           Start :: null | log_time(),
                           Cnt :: {NumOK, NumERR},
                           NumOK :: non_neg_integer(),
                           NumERR :: pos_integer(),
                           Reason :: term();
                   (LogDir, Mibs, LogName, LogFile, Start, Stop) -> ok | {ok, Cnt} | {error, Reason}
                       when
                           LogDir :: string(),
                           Mibs :: [mib_name()],
                           LogName :: string(),
                           LogFile :: string(),
                           Start :: null | log_time(),
                           Stop :: null | log_time(),
                           Cnt :: {NumOK, NumERR},
                           NumOK :: non_neg_integer(),
                           NumERR :: pos_integer(),
                           Reason :: term().

Equivalent to `log_to_io/7`.

Link to this function

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

View Source (since OTP R16B03)

    -spec log_to_io(LogDir, Mibs, LogName, LogFile, Block, Start, Stop) -> ok | {ok, Cnt} | {error, Reason}
                       when
                           LogDir :: string(),
                           Mibs :: [mib_name()],
                           LogName :: string(),
                           LogFile :: string(),
                           Block :: boolean(),
                           Start :: null | log_time(),
                           Stop :: null | log_time(),
                           Cnt :: {NumOK, NumERR},
                           NumOK :: non_neg_integer(),
                           NumERR :: pos_integer(),
                           Reason :: term().

Converts an Audit Trail Log to a readable format and prints it on stdio. See `log_to_txt/8` for more info.

Link to this function

# log_to_txt(LogDir, Mibs, OutFile, LogName, LogFile)

View Source

    -spec log_to_txt(LogDir, Mibs, OutFile, LogName, LogFile) -> ok | {ok, Cnt} | {error, Reason}
                        when
                            LogDir :: string(),
                            Mibs :: [mib_name()],
                            OutFile :: string(),
                            LogName :: string(),
                            LogFile :: string(),
                            Cnt :: {NumOK, NumERR},
                            NumOK :: non_neg_integer(),
                            NumERR :: pos_integer(),
                            Reason :: term().

Equivalent to `log_to_txt/8`.

Link to this function

# log_to_txt/6

View Source

    -spec log_to_txt(LogDir, Mibs, OutFile, LogName, LogFile, Block) -> ok | {ok, Cnt} | {error, Reason}
                        when
                            LogDir :: string(),
                            Mibs :: [mib_name()],
                            OutFile :: string(),
                            LogName :: string(),
                            LogFile :: string(),
                            Block :: boolean(),
                            Cnt :: {NumOK, NumERR},
                            NumOK :: non_neg_integer(),
                            NumERR :: pos_integer(),
                            Reason :: term();
                    (LogDir, Mibs, OutFile, LogName, LogFile, Start) -> ok | {ok, Cnt} | {error, Reason}
                        when
                            LogDir :: string(),
                            Mibs :: [mib_name()],
                            OutFile :: string(),
                            LogName :: string(),
                            LogFile :: string(),
                            Start :: null | log_time(),
                            Cnt :: {NumOK, NumERR},
                            NumOK :: non_neg_integer(),
                            NumERR :: pos_integer(),
                            Reason :: term().

Equivalent to `log_to_txt/8`.

Link to this function

# log_to_txt/7

View Source

    -spec log_to_txt(LogDir, Mibs, OutFile, LogName, LogFile, Block, Start) ->
                        ok | {ok, Cnt} | {error, Reason}
                        when
                            LogDir :: string(),
                            Mibs :: [mib_name()],
                            OutFile :: string(),
                            LogName :: string(),
                            LogFile :: string(),
                            Block :: boolean(),
                            Start :: null | log_time(),
                            Cnt :: {NumOK, NumERR},
                            NumOK :: non_neg_integer(),
                            NumERR :: pos_integer(),
                            Reason :: term();
                    (LogDir, Mibs, OutFile, LogName, LogFile, Start, Stop) ->
                        ok | {ok, Cnt} | {error, Reason}
                        when
                            LogDir :: string(),
                            Mibs :: [mib_name()],
                            OutFile :: string(),
                            LogName :: string(),
                            LogFile :: string(),
                            Start :: null | log_time(),
                            Stop :: null | log_time(),
                            Cnt :: {NumOK, NumERR},
                            NumOK :: non_neg_integer(),
                            NumERR :: pos_integer(),
                            Reason :: term().

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

    -spec log_to_txt(LogDir, Mibs, OutFile, LogName, LogFile, Block, Start, Stop) ->
                        ok | {ok, Cnt} | {error, Reason}
                        when
                            LogDir :: string(),
                            Mibs :: [mib_name()],
                            OutFile :: string(),
                            LogName :: string(),
                            LogFile :: string(),
                            Block :: boolean(),
                            Start :: null | log_time(),
                            Stop :: null | log_time(),
                            Cnt :: {NumOK, NumERR},
                            NumOK :: non_neg_integer(),
                            NumERR :: pos_integer(),
                            Reason :: term().

Converts an Audit Trail Log to a readable text file, where each item has a trailing TAB character, and any TAB character in the body of an item has been replaced by ESC TAB.

The function can be used on a running system, or by copying the entire log directory and calling this function. SNMP must be running in order to provide MIB information.

`LogDir` is the name of the directory where the audit trail log is stored. `Mibs` is a list of Mibs to be used. The function uses the information in the Mibs to convert for example object identifiers to their symbolic name. `OutFile` is the name of the generated text-file. `LogName` is the name of the log, `LogFile` is the name of the log file. `Start` is the start (first) date and time from which log events will be converted and `Stop` is the stop (last) date and time to which log events will be converted. The `Block` argument 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`.

The format of an audit trail log text item is as follows:

`Tag Addr - Community [TimeStamp] Vsn`
`PDU`

where `Tag` is `request`, `response`, `report`, `trap` or `inform`; Addr is `IP:Port` (or comma space separated list of such); `Community` is the community parameter (SNMP version v1 and v2), or `SecLevel:"AuthEngineID":"UserName"` (SNMP v3); `TimeStamp` is a date and time stamp, and `Vsn` is the SNMP version. `PDU` is a textual version of the protocol data unit. There is a new line between `Vsn` and `PDU`.

If the entire log is successfully converted, the function will return `ok`. If one of more entries fail to convert, the function will instead return `{ok, {NumOK, NumERR}}`, where the counters indicate how many valid and erroneous entries where found. If instead `{error, Reason}` is returned, the conversion encountered a fatal error and where either never done of aborted midway.

Link to this function

# octet_string_to_bits(S)

View Source

    -spec octet_string_to_bits(S) -> bits() when S :: octet_string().

Utility function for converting a value of type `OCTET-STRING` to `BITS`, according to RFC1906, section 8.

Link to this function

# passwd2localized_key(Algorithm, Passwd, EngineID)

View Source

    -spec passwd2localized_key(Algorithm, Passwd, EngineID) -> Key
                                  when
                                      Algorithm :: algorithm(),
                                      Passwd :: string(),
                                      EngineID :: string(),
                                      Key :: list().

Generates a key that can be used as an authentication or privacy key using MD5, SHA, SHA224, SHA256, SHA384 or SHA512. The key is localized for EngineID.

Link to this function

# print_version_info()

View Source

    -spec print_version_info() -> void().

Equivalent to `print_version_info/1`.

Link to this function

# print_version_info(Prefix)

View Source

    -spec print_version_info(Prefix) -> void() when Prefix :: string() | non_neg_integer().

Utility function(s) to produce a formatted printout of the versions info generated by the `versions1` function

This is the same as doing, e.g.:

               {ok, V} = snmp:versions1(),
               snmp:print_versions(V).

Link to this function

# print_versions(Versions)

View Source

    -spec print_versions(Versions) -> void() when Versions :: [VersionInfo], VersionInfo :: term().

Equivalent to `print_versions/2`.

Link to this function

# print_versions(Prefix, Versions)

View Source

    -spec print_versions(Prefix, Versions) -> void()
                            when
                                Prefix :: string() | non_neg_integer(),
                                Versions :: [VersionInfo],
                                VersionInfo :: term().

Utility function to produce a formatted printout of the versions info generated by the `versions1` and `versions2` functions

Example:

               {ok, V} = snmp:versions1(),
               snmp:print_versions(V).

Link to this function

# read_mib(FileName)

View Source

    -spec read_mib(FileName) -> {ok, Mib} | {error, Reason}
                      when FileName :: string(), Mib :: mib(), Reason :: term().

Read a compiled mib.

Link to this function

# reset_trace(Targets)

View Source

    -spec reset_trace(Targets) -> void() when Targets :: module() | [module()].

This function is used to reset (disable) trace for the given module(s).

Link to this function

# set_trace(Targets)

View Source

    -spec set_trace(Targets) -> void()
                       when
                           Targets :: module() | [module() | {module(), [TargetOpt]}],
                           TargetOpt :: {return_trace, boolean()} | {scope, Scope},
                           Scope ::
                               all_functions | exported_functions | FunctionName |
                               {FunctionName, FunctionArity},
                           FunctionName :: atom(),
                           FunctionArity :: non_neg_integer().

This function is used to set up default trace on function(s) for the given module or modules. The scope of the trace will be all exported functions (both the call info and the return value). Timestamp info will also be included.

Link to this function

# set_trace(Targets, TraceOpts)

View Source

    -spec set_trace(Targets, TraceOpts) -> void()
                       when
                           Targets :: module() | [module() | {module(), [TargetOpt]}],
                           TargetOpt :: {return_trace, boolean()} | {scope, Scope},
                           Scope ::
                               all_functions | exported_functions | FunctionName |
                               {FunctionName, FunctionArity},
                           FunctionName :: atom(),
                           FunctionArity :: non_neg_integer(),
                           TraceOpts :: disable | [TraceOpt],
                           TraceOpt :: {timestamp, boolean()} | TargetOpt.

This function is used to set up trace on function(s) for the given module or modules.

The example below sets up trace on the exported functions (default) of module `snmp_generic` and all functions of module `snmp_generic_mnesia`. With return values (which is default) and timestamps in both cases (which is also default):

    	  snmp:enable_trace(),
    	  snmp:set_trace([snmp_generic,
                              {snmp_generic_mnesia, [{scope, all_functions}]}]),
    	  .
    	  .
    	  .
              snmp:set_trace(snmp_generic, disable),
    	  .
    	  .
    	  .
    	  snmp:disable_trace(),

Link to this function

# start()

View Source

    -spec start() -> ok | {error, Reason} when Reason :: term().

Equivalent to `start/1`.

Link to this function

# start(Type)

View Source

    -spec start(Type) -> ok | {error, Reason}
                   when Type :: p | permanent | tr | transient | te | temporary, Reason :: term().

Starts the SNMP application.

See `application` for more info.

Link to this function

# start_agent()

View Source

    -spec start_agent() -> ok | {error, Reason} when Reason :: term().

Equivalent to `start_agent/1`.

Link to this function

# start_agent(Type)

View Source

    -spec start_agent(Type) -> ok | {error, Reason} when Type :: application:start_type(), Reason :: term().

The SNMP application consists of several entities, of which the agent is one. This function starts the agent entity of the application.

Note that the only way to actually start the agent in this way is to add the agent related config after starting the application (e.g it cannot be part of the normal application config; sys.config). This is done by calling: `application:set_env(snmp, agent, Conf)`.

The default value for `Type` is `normal`.

Link to this function

# start_manager()

View Source

    -spec start_manager() -> ok | {error, Reason} when Reason :: term().

Equivalent to `start_manager/1`.

Link to this function

# start_manager(Type)

View Source

    -spec start_manager(Type) -> ok | {error, Reason}
                           when Type :: application:start_type(), Reason :: term().

The SNMP application consists of several entities, of which the manager is one. This function starts the manager entity of the application.

Note that the only way to actually start the manager in this way is to add the manager related config after starting the application (e.g it cannot be part of the normal application config; sys.config). This is done by calling: `application:set_env(snmp, manager, Conf)`.

The default value for `Type` is `normal`.

Link to this function

# stop()

View Source (since OTP 27.0)

    -spec stop() -> ok | {error, Reason} when Reason :: term().

Stops the SNMP application.

See `application` for more info.

This function has existed for long time, but not had a proper since tag, so to simplify we set the since tag to when it was documented.

Link to this function

# universal_time_to_date_and_time(UTC)

View Source

    -spec universal_time_to_date_and_time(UTC) -> DateAndTime
                                             when
                                                 UTC :: calendar:datetime(),
                                                 DateAndTime :: rfc1903_date_and_time().

Converts a universal time value to a DateAndTime list. The universal time value on the same format as defined in calendar(3).

Link to this function

# validate_date_and_time(DateAndTime)

View Source

    -spec validate_date_and_time(DateAndTime) -> boolean() when DateAndTime :: rfc1903_date_and_time().

Equivalent to `validate_date_and_time/2`.

Link to this function

# validate_date_and_time(DateAndTime, Validate)

View Source

    -spec validate_date_and_time(DateAndTime, Validate) -> boolean()
                                    when
                                        DateAndTime :: rfc1903_date_and_time(),
                                        Validate :: date_and_time_validator().

Checks if `DateAndTime` is a correct DateAndTime value, as specified in RFC2579. This function can be used in instrumentation functions to validate a DateAndTime value.

The validation fun, `Validate`, allows for a more "flexible" validation of the `DateAndTime` argument. Whenever the data is found to not follow RFC2579, the fun is called to allow a more "lax" validation.

Link to this function

# versions1()

View Source

    -spec versions1() -> {ok, VersionsInfo} | {error, Reason}
                       when VersionsInfo :: [VersionInfo], VersionInfo :: term(), Reason :: term().

Equivalent to `versions2/0`.

Link to this function

# versions2()

View Source

    -spec versions2() -> {ok, VersionsInfo} | {error, Reason}
                       when VersionsInfo :: [VersionInfo], VersionInfo :: term(), Reason :: term().

Utility functions used to retrieve some system and application info.

The difference between the two functions is in how they get the modules to check. `versions1` uses the app-file and `versions2` uses the function `application:get_key`.