View Source snmpa_conf (snmp v5.15)

Utility functions for handling the agent config files.

The module snmpa_conf contains various utility functions to used for manipulating (write/append/read) the config files of the SNMP agent.

DATA TYPES

transportDomain() = transportDomainUdpIpv4 | transportDomainUdpIpv6

transportAddress() =
    transportAddressIPv4() | transportAddressIPv6()

transportAddressWithPort() =
    transportAddressIPv4WithPort() | transportAddressIPv6WithPort()

transportAddressWithoutPort() =
    transportAddressIPv4WithoutPort() | transportAddressIPv6WithoutPort()

transportAddressIPv4() =
    transportAddressIPv4WithPort() | transportAddressIPv4WithoutPort()
transportAddressIPv4WithPort =
    {transportAddressIPv4WithoutPort(), inet:port_number()} |
    [byte() x 4, byte() x 2]
transportAddressIPv4WithoutPort =
    inet:ip4_address() | [byte() x 4]

transportAddressIPv6() =
    transportAddressIPv6WithPort() | transportAddressIPv6WithoutPort()
transportAddressIPv6WithPort =
    {transportAddressIPv6WithoutPort(), inet:port_number()} |
    [word() x 8, inet:port_number()] |
    [word() x 8, byte() x 2] |
    {byte() x 16, byte() x 2]
transportAddressIPv6WithoutPort =
    inet:ip6_address() | [word() x 8] | [byte() x 16]

transportAddressMask() =
    [] | transportAddressWithPort()

byte() = 0..255
word() = 0..65535

For inet:ip4_address(), inet:ip6_address() and inet:port_number(), see also inet:ip_address/0

Summary

Functions

agent_entry(Tag, Val) -> agent_entry()

append_agent_config(Dir, Conf) -> ok

append_community_config(Dir, Conf) -> ok

append_context_config(Dir, Conf) -> ok

append_notify_config(Dir, Conf) -> ok

append_standard_config(Dir, Conf) -> ok

append_target_addr_config(Dir, Conf) -> ok

append_target_params_config(Dir, Conf) -> ok

append_usm_config(Dir, Conf) -> ok

append_vacm_config(Dir, Conf) -> ok

community_entry(CommunityIndex, CommunityName, SecName, ContextName, TransportTag) -> community_entry()

context_entry(Context) -> context_entry()

notify_entry(Name, Tag, Type) -> notify_entry()

read_agent_config(Dir) -> Conf

read_community_config(Dir) -> Conf

read_context_config(Dir) -> Conf

read_notify_config(Dir) -> Conf

read_standard_config(Dir) -> Conf

read_target_addr_config(Dir) -> Conf

read_target_params_config(Dir) -> Conf

read_usm_config(Dir) -> Conf

read_vacm_config(Dir) -> Conf

standard_entry(Tag, Val) -> standard_entry()

target_addr_entry(Name, Domain, Addr, Timeout, RetryCount, TagList, ParamsName, EngineId, TMask, MaxMessageSize) -> target_addr_entry()

target_params_entry(Name, MPModel, SecModel, SecName, SecLevel) -> target_params_entry()

usm_entry(EngineID, UserName, SecName, Clone, AuthP, AuthKeyC, OwnAuthKeyC, PrivP, PrivKeyC, OwnPrivKeyC, Public, AuthKey, PrivKey) -> usm_entry()

vacm_vtf_entry(ViewIndex, ViewSubtree, ViewStatus, ViewMask) -> vacm_vtf_entry()

write_agent_config(Dir, Hdr, Conf) -> ok

write_community_config(Dir, Hdr, Conf) -> ok

write_context_config(Dir, Hdr, Conf) -> ok

write_notify_config(Dir, Hdr, Conf) -> ok

write_standard_config(Dir, Hdr, Conf) -> ok

write_target_addr_config(Dir, Hdr, Conf) -> ok

write_target_params_config(Dir, Hdr, Conf) -> ok

write_usm_config(Dir, Hdr, Conf) -> ok

write_vacm_config(Dir, Hdr, Conf) -> ok

Types

-type transportAddress() :: transportAddressIPv4() | transportAddressIPv6().
Link to this type

transportAddressIPv4()

View Source (not exported)
-type transportAddressIPv4() :: transportAddressIPv4WithPort() | transportAddressIPv4WithoutPort().
Link to this type

transportAddressIPv4WithoutPort()

View Source (not exported)
-type transportAddressIPv4WithoutPort() ::
    inet:ip4_address() | [IPA :: byte() | (IPB :: byte() | (IPC :: byte() | (IPD :: byte())))].
Link to this type

transportAddressIPv4WithPort()

View Source (not exported)
-type transportAddressIPv4WithPort() ::
    {transportAddressIPv4WithoutPort(), inet:port_number()} |
    [IPA ::
         byte() |
         (IPB ::
              byte() | (IPC :: byte() | (IPD :: byte() | (PortA :: byte() | (PortB :: byte())))))].
Link to this type

transportAddressIPv6()

View Source (not exported)
-type transportAddressIPv6() :: transportAddressIPv6WithPort() | transportAddressIPv6WithoutPort().
Link to this type

transportAddressIPv6WithoutPort()

View Source (not exported)
-type transportAddressIPv6WithoutPort() ::
    inet:ip6_address() |
    [IPA ::
         word() |
         (IPB ::
              word() |
              (IPC ::
                   word() |
                   (IPD ::
                        word() |
                        (IPE :: word() | (IPF :: word() | (IPG :: word() | (IPH :: word())))))))] |
    [IPA ::
         byte() |
         (IPB ::
              byte() |
              (IPC ::
                   byte() |
                   (IPD ::
                        byte() |
                        (IPE ::
                             byte() |
                             (IPF ::
                                  byte() |
                                  (IPG ::
                                       byte() |
                                       (IPH ::
                                            byte() |
                                            (IPI ::
                                                 byte() |
                                                 (IPJ ::
                                                      byte() |
                                                      (IPK ::
                                                           byte() |
                                                           (IPL ::
                                                                byte() |
                                                                (IPM ::
                                                                     byte() |
                                                                     (IPN ::
                                                                          byte() |
                                                                          (IPO ::
                                                                               byte() |
                                                                               (IPP :: byte())))))))))))))))].
Link to this type

transportAddressIPv6WithPort()

View Source (not exported)
-type transportAddressIPv6WithPort() ::
    {transportAddressIPv6WithoutPort(), inet:port_number()} |
    [IPA ::
         word() |
         (IPB ::
              word() |
              (IPC ::
                   word() |
                   (IPD ::
                        word() |
                        (IPE ::
                             word() |
                             (IPF ::
                                  word() | (IPG :: word() | (IPH :: word() | inet:port_number())))))))] |
    [IPA ::
         word() |
         (IPB ::
              word() |
              (IPC ::
                   word() |
                   (IPD ::
                        word() |
                        (IPE ::
                             word() |
                             (IPF ::
                                  word() |
                                  (IPG ::
                                       word() |
                                       (IPH :: word() | (PortA :: byte() | (PortB :: byte())))))))))] |
    {IPA :: byte(),
     IPB :: byte(),
     IPC :: byte(),
     IPD :: byte(),
     IPE :: byte(),
     IPF :: byte(),
     IPG :: byte(),
     IPH :: byte(),
     IPI :: byte(),
     IPJ :: byte(),
     IPK :: byte(),
     IPL :: byte(),
     IPM :: byte(),
     IPN :: byte(),
     IPO :: byte(),
     IPP :: byte(),
     PortA :: byte(),
     PortB :: byte()}.
Link to this type

transportAddressMask()

View Source
-type transportAddressMask() :: [] | transportAddressWithPort().
Link to this type

transportAddressWithoutPort()

View Source
-type transportAddressWithoutPort() ::
    transportAddressIPv4WithoutPort() | transportAddressIPv6WithoutPort().
Link to this type

transportAddressWithPort()

View Source
-type transportAddressWithPort() :: transportAddressIPv4WithPort() | transportAddressIPv6WithPort().
-type transportDomain() :: snmp:tdomain().
-type usm_entry() ::
    {EngineID :: string(),
     UserName :: string(),
     SecName :: string(),
     Clone :: zeroDotZero | [non_neg_integer()],
     AuthP ::
         usmNoAuthProtocol | usmHMACMD5AuthProtocol | usmHMACSHAAuthProtocol |
         usmHMAC128SHA224AuthProtocol | usmHMAC192SHA256AuthProtocol |
         usmHMAC256SHA384AuthProtocol | usmHMAC384SHA512AuthProtocol,
     AuthKeyC :: string(),
     OwnAuthKeyC :: string(),
     PrivP :: usmNoPrivProtocol | usmDESPrivProtocol | usmAesCfb128Protocol,
     PrivKeyC :: string(),
     OwnPrivKeyC :: string(),
     Public :: string(),
     AuthKey :: [non_neg_integer()],
     PrivKey :: [non_neg_integer()]}.
-type word() :: 0..65535.

Functions

agent_entry(Tag, Val) -> agent_entry()

Create an entry for the agent config file, agent.conf.

The type of Val depends on the value of Tag, see Agent Information for more info.

Link to this function

append_agent_config(Dir, Conf)

View Source

append_agent_config(Dir, Conf) -> ok

Append the config to the current agent config file.

Dir is the path to the directory where to store the config file.

See Agent Information for more info.

Link to this function

append_community_config(Dir, Conf)

View Source

append_community_config(Dir, Conf) -> ok

Append the community config to the current agent community config file.

Dir is the path to the directory where to store the config file.

See Community for more info.

Link to this function

append_context_config(Dir, Conf)

View Source

append_context_config(Dir, Conf) -> ok

Append the context config to the current agent context config file.

Dir is the path to the directory where to store the config file.

See Contexts for more info.

Link to this function

append_notify_config(Dir, Conf)

View Source

append_notify_config(Dir, Conf) -> ok

Append the notify config to the current agent notify config file.

Dir is the path to the directory where to store the config file.

See Notify Definitions for more info.

Link to this function

append_standard_config(Dir, Conf)

View Source

append_standard_config(Dir, Conf) -> ok

Append the standard config to the current agent standard config file.

Dir is the path to the directory where to store the config file.

See System Information for more info.

Link to this function

append_target_addr_config(Dir, Conf)

View Source

append_target_addr_config(Dir, Conf) -> ok

Append the target_addr config to the current agent target_addr config file.

Dir is the path to the directory where to store the config file.

See Target Address Definitions for more info.

Link to this function

append_target_params_config(Dir, Conf)

View Source

append_target_params_config(Dir, Conf) -> ok

Append the target_params config to the current agent target_params config file.

Dir is the path to the directory where to store the config file.

See Target Parameters Definitions for more info.

Link to this function

append_usm_config(Dir, Conf)

View Source

append_usm_config(Dir, Conf) -> ok

Append the usm config to the current agent vacm config file.

Dir is the path to the directory where to store the config file.

See Security data for USM for more info.

Link to this function

append_vacm_config(Dir, Conf)

View Source

append_vacm_config(Dir, Conf) -> ok

Append the vacm config to the current agent vacm config file.

Dir is the path to the directory where to store the config file.

See MIB Views for VACM for more info.

Equivalent to community_entry/5

Link to this function

community_entry(CommIndex, CommName, SecName, CtxName, TransportTag)

View Source

community_entry(CommunityIndex, CommunityName, SecName, ContextName, TransportTag) -> community_entry()

Create an entry for the agent community config file, community.conf.

CommunityIndex must be a non-empty string.

community_entry("public") translates to the following call: community_entry(CommunityIndex, CommunityIndex, "initial", "", "").

community_entry("all-rights") translates to the following call: community_entry(CommunityIndex, CommunityIndex, CommunityIndex, "", "").

See Community for more info.

context_entry(Context) -> context_entry()

Create an entry for the agent context config file, context.conf.

See Contexts for more info.

Link to this function

notify_entry(Name, Tag, Type)

View Source

notify_entry(Name, Tag, Type) -> notify_entry()

Create an entry for the agent notify config file, notify.conf.

Name must be a non-empty string.

See Notify Definitions for more info.

read_agent_config(Dir) -> Conf

Read the current agent config file.

Dir is the path to the directory where to store the config file.

See Agent Information for more info.

Link to this function

read_community_config(Dir)

View Source

read_community_config(Dir) -> Conf

Read the current agent community config file.

Dir is the path to the directory where to store the config file.

See Communities for more info.

Link to this function

read_context_config(Dir)

View Source

read_context_config(Dir) -> Conf

Read the current agent context config file.

Dir is the path to the directory where to store the config file.

See Contexts for more info.

read_notify_config(Dir) -> Conf

Read the current agent notify config file.

Dir is the path to the directory where to store the config file.

See Notify Definitions for more info.

Link to this function

read_standard_config(Dir)

View Source

read_standard_config(Dir) -> Conf

Read the current agent standard config file.

Dir is the path to the directory where to store the config file.

See System Information for more info.

Link to this function

read_target_addr_config(Dir)

View Source

read_target_addr_config(Dir) -> Conf

Read the current agent target_addr config file.

Dir is the path to the directory where to store the config file.

See Target Address Definitions for more info.

Link to this function

read_target_params_config(Dir)

View Source

read_target_params_config(Dir) -> Conf

Read the current agent target_params config file.

Dir is the path to the directory where to store the config file.

See Target Parameters Definitions for more info.

read_usm_config(Dir) -> Conf

Read the current agent usm config file.

Dir is the path to the directory where to store the config file.

See Security data for USM for more info.

read_vacm_config(Dir) -> Conf

Read the current agent vacm config file.

Dir is the path to the directory where to store the config file.

See MIB Views for VACM for more info.

Link to this function

standard_entry(Tag, Val)

View Source

standard_entry(Tag, Val) -> standard_entry()

Create an entry for the agent standard config file, standard.conf.

The type of Val depends on the value of Tag, see System Information for more info.

Link to this function

target_addr_entry/6

View Source (since OTP 17.3)

Equivalent to target_addr_entry/10

Link to this function

target_addr_entry(Name, Domain_or_Ip, Addr_or_Port, TagList, ParamsName, EngineId, TMask)

View Source (since OTP 17.3)

Equivalent to target_addr_entry/10

Link to this function

target_addr_entry(Name, Domain_or_Ip, Addr_or_Port, TagList, ParamsName, EngineId, TMask, MaxMessageSize)

View Source (since OTP 17.3)

Equivalent to target_addr_entry/10

Link to this function

target_addr_entry(Name, Domain_or_Ip, Addr_or_Port, Timeout, RetryCount, TagList, ParamsName, EngineId, TMask, MaxMessageSize)

View Source (since OTP 17.3)

target_addr_entry(Name, Domain, Addr, Timeout, RetryCount, TagList, ParamsName, EngineId, TMask, MaxMessageSize) -> target_addr_entry()

Create an entry for the agent target_addr config file, target_addr.conf.

Name must be a non-empty string.

target_addr_entry/6 translates to the following call: target_addr_entry(Name, Domain, Addr, TagList, ParamsName, EngineId, []).

target_addr_entry/7 translates to the following call: target_addr_entry(Name, Domain, Addr, TagList, ParamsName, EngineId, TMask, 2048).

target_addr_entry/8 translates to the following call: target_addr_entry(Name, Domain, Addr, 1500, 3, TagList, ParamsName, EngineId, TMask, MaxMessageSize).

See Target Address Definitions for more info.

Link to this function

target_params_entry(Name, Vsn)

View Source

Equivalent to target_params_entry/5

Link to this function

target_params_entry(Name, Vsn, SecName, SecLevel)

View Source

Equivalent to target_params_entry/5

Link to this function

target_params_entry(Name, MPModel, SecModel, SecName, SecLevel)

View Source

target_params_entry(Name, MPModel, SecModel, SecName, SecLevel) -> target_params_entry()

Create an entry for the agent target_params config file, target_params.conf.

Name must be a non-empty string.

Vsn translates into MPModel and SecModel as follows:

\011  Vsn = v1 => MPModel = v1,  SecModel = v1
\011  Vsn = v2 => MPModel = v2c, SecModel = v2c
\011  Vsn = v3 => MPModel = v3,  SecModel = usm

target_params_entry/2 translates to the following call: target_params_entry(Name, Vsn, "initial", noAuthNoPriv).

target_params_entry/4 translates to the following call: target_params_entry(Name, MPModel, SecModel, SecName, SecLevel) where MPModel and SecModel is mapped from Vsn, see above.

See Target Parameters Definitions for more info.

Equivalent to usm_entry/13

Link to this function

usm_entry(EngineID, UserName, SecName, Clone, AuthP, AuthKeyC, OwnAuthKeyC, PrivP, PrivKeyC, OwnPrivKeyC, Public, AuthKey, PrivKey)

View Source

usm_entry(EngineID, UserName, SecName, Clone, AuthP, AuthKeyC, OwnAuthKeyC, PrivP, PrivKeyC, OwnPrivKeyC, Public, AuthKey, PrivKey) -> usm_entry()

Create an entry for the agent vacm config file, vacm.conf.

usm_entry/1 translates to the following call: usm_entry("initial", "initial", zeroDotZero, usmNoAuthProtocol, "", "", usmNoPrivProtocol, "", "", "", "", "").

See Security data for USM for more info.

Link to this function

vacm_acc_entry(GroupName, Prefix, SecModel, SecLevel, Match, RV, WV, NV)

View Source

Equivalent to vacm_vtf_entry/4

Link to this function

vacm_s2g_entry(SecModel, SecName, GroupName)

View Source

Equivalent to vacm_vtf_entry/4

Link to this function

vacm_vtf_entry(ViewIndex, ViewSubtree)

View Source

Equivalent to vacm_vtf_entry/4

Link to this function

vacm_vtf_entry(ViewIndex, ViewSubtree, ViewStatus, ViewMask)

View Source

vacm_vtf_entry(ViewIndex, ViewSubtree, ViewStatus, ViewMask) -> vacm_vtf_entry()

Create an entry for the agent vacm config file, vacm.conf.

vacm_vtf_entry/2 translates to the following call: vacm_vtf_entry(ViewIndex, ViewSubtree, included, null).

See MIB Views for VACM for more info.

Link to this function

write_agent_config(Dir, Conf)

View Source

Equivalent to write_agent_config/3

Link to this function

write_agent_config(Dir, Hdr, Conf)

View Source

write_agent_config(Dir, Hdr, Conf) -> ok

Write the agent config to the agent config file.

Dir is the path to the directory where to store the config file.

Hdr is an optional file header (note that this text is written to the file as is).

See Agent Information for more info.

Link to this function

write_community_config(Dir, Conf)

View Source

Equivalent to write_community_config/3

Link to this function

write_community_config(Dir, Hdr, Conf)

View Source

write_community_config(Dir, Hdr, Conf) -> ok

Write the agent community config to the agent community config file.

Dir is the path to the directory where to store the config file.

Hdr is an optional file header (note that this text is written to the file as is).

See Community for more info.

Link to this function

write_context_config(Dir, Conf)

View Source

Equivalent to write_context_config/3

Link to this function

write_context_config(Dir, Hdr, Conf)

View Source

write_context_config(Dir, Hdr, Conf) -> ok

Write the agent context config to the agent context config file.

Dir is the path to the directory where to store the config file.

Hdr is an optional file header (note that this text is written to the file as is).

See Contexts for more info.

Link to this function

write_notify_config(Dir, Conf)

View Source

Equivalent to write_notify_config/3

Link to this function

write_notify_config(Dir, Hdr, Conf)

View Source

write_notify_config(Dir, Hdr, Conf) -> ok

Write the agent notify config to the agent notify config file.

Dir is the path to the directory where to store the config file.

Hdr is an optional file header (note that this text is written to the file as is).

See Notify Definitions for more info.

Link to this function

write_standard_config(Dir, Conf)

View Source

Equivalent to write_standard_config/3

Link to this function

write_standard_config(Dir, Hdr, Conf)

View Source

write_standard_config(Dir, Hdr, Conf) -> ok

Write the agent standard config to the agent standard config file.

Dir is the path to the directory where to store the config file.

Hdr is an optional file header (note that this text is written to the file as is).

See System Information for more info.

Link to this function

write_target_addr_config(Dir, Conf)

View Source

Equivalent to write_target_addr_config/3

Link to this function

write_target_addr_config(Dir, Hdr, Conf)

View Source

write_target_addr_config(Dir, Hdr, Conf) -> ok

Write the agent target_addr config to the agent target_addr config file.

Dir is the path to the directory where to store the config file.

Hdr is an optional file header (note that this text is written to the file as is).

See Target Address Definitions for more info.

Link to this function

write_target_params_config(Dir, Conf)

View Source

Equivalent to write_target_params_config/3

Link to this function

write_target_params_config(Dir, Hdr, Conf)

View Source

write_target_params_config(Dir, Hdr, Conf) -> ok

Write the agent target_params config to the agent target_params config file.

Dir is the path to the directory where to store the config file.

Hdr is an optional file header (note that this text is written to the file as is).

See Target Parameters Definitions for more info.

Link to this function

write_usm_config(Dir, Conf)

View Source

Equivalent to write_usm_config/3

Link to this function

write_usm_config(Dir, Hdr, Conf)

View Source

write_usm_config(Dir, Hdr, Conf) -> ok

Write the agent usm config to the agent usm config file.

Dir is the path to the directory where to store the config file.

Hdr is an optional file header (note that this text is written to the file as is).

See Security data for USM for more info.

Link to this function

write_vacm_config(Dir, Conf)

View Source

Equivalent to write_vacm_config/3

Link to this function

write_vacm_config(Dir, Hdr, Conf)

View Source

write_vacm_config(Dir, Hdr, Conf) -> ok

Write the agent vacm config to the agent vacm config file.

Dir is the path to the directory where to store the config file.

Hdr is an optional file header (note that this text is written to the file as is).

See MIB Views for VACM for more info.