Utility functions for handling the agent config files.
The module snmpa_conf contains various utility functions to use for
manipulating (write/read/append) the config files of the SNMP agent.
Summary
Types
An opaque term that represents an entry in the 'agent' config.
An opaque term that represents an entry in the 'community' (agent) config.
An opaque term that represents an entry in the 'context' (agent) config.
An opaque term that represents an entry in the 'notify' (agent) config.
Port number 0 (zero) cannot be specified directly (it is used internally).
Instead the atom 'system' should be used.
Min < Max
An opaque term that represents an entry in the 'standard' (agent) config.
An opaque term that represents an entry in the 'target address' (agent) config.
An opaque term that represents an entry in the 'target parameters' (agent) config.
Because of limitations of the Erlang type language we cannot define this type in detail. Instead, we describe it here.
Because of limitations of the Erlang type language we cannot define this type in detail. Instead, we describe it here.
Because of limitations of the Erlang type language we cannot define this type in detail. Instead, we describe it here.
Because of limitations of the Erlang type language we cannot define this type in detail. Instead, we describe it here.
An opaque term that represents an entry in the 'user based sm' (agent) config.
An opaque term that represents an (access) entry in the 'vacm access' (agent) config.
An basically opaque term that represents an entry in the 'view based acm' (agent) config.
An opaque term that represents an (security to group) entry in the 'vacm security to group' (agent) config.
An opaque term that represents an (tree family) entry in the 'vacm tree family' (agent) config.
Functions
Create an entry for the agent config file, agent.conf.
Append the config to the current agent config file.
Append the community config to the current agent community config file.
Append the context config to the current agent context config file.
Append the notify config to the current agent notify config file.
Append the standard config to the current agent standard config file.
Append the target_addr config to the current agent target_addr config file.
Append the target_params config to the current agent target_params config file.
Append the usm config to the current agent usm config file.
Append the vacm config to the current agent vacm config file.
Create an entry for the agent community config file, community.conf.
Create an entry for the agent community config file, community.conf.
Create an entry for the agent context config file, context.conf.
Create an entry for the agent notify config file, notify.conf.
Read the current agent config file.
Read the current agent community config file.
Read the current agent context config file.
Read the current agent notify config file.
Read the current agent standard config file.
Read the current agent target_addr config file.
Read the current agent target_params config file.
Read the current agent usm config file.
Read the current agent vacm config file.
Create an entry for the agent standard config file, standard.conf.
Create an entry for the agent target_addr config file, target_addr.conf.
Create an entry for the agent target_addr config file, target_addr.conf.
Create an entry for the agent target_addr config file, target_addr.conf.
Create an entry for the agent target_addr config file, target_addr.conf.
Create an entry for the agent target_params config file, target_params.conf.
Create an entry for the agent target_params config file, target_params.conf.
Create an entry for the agent target_params config file, target_params.conf.
Create an entry for the agent usm config file, usm.conf.
Create an entry for the agent usm config file, usm.conf.
Create an (access) entry for the agent vacm config file, vacm.conf.
Create an (security to group) entry for the agent vacm config file, vacm.conf.
Create an (view tree family) entry for the agent vacm config file, vacm.conf.
Create an (view tree family) entry for the agent vacm config file, vacm.conf.
Write the agent config to the agent config file.
Write the agent community config to the agent community config file.
Write the agent context config to the agent context config file.
Write the agent notify config to the agent notify config file.
Write the agent standard config to the agent standard config file.
Write the agent target_addr config to the agent target_addr config file.
Write the agent target_params config to the agent target_params config file.
Write the agent usm config to the agent usm config file.
Write the agent vacm config to the agent vacm config file.
Types
-opaque agent_entry()
An opaque term that represents an entry in the 'agent' config.
-opaque community_entry()
An opaque term that represents an entry in the 'community' (agent) config.
-opaque context_entry()
An opaque term that represents an entry in the 'context' (agent) config.
-type extended_transport_address() :: {inet:ip_address(), port_info()}.
-type intAgentTransport() :: {transportDomain(), transport_address()} | {transportDomain(), extended_transport_address(), snmpa:transport_kind()} | {transportDomain(), extended_transport_address(), transport_opts()} | {transportDomain(), extended_transport_address(), snmpa:transport_kind(), transport_opts()}.
-type ip_address() :: inet:ip_address() | snmp_ip_address().
-opaque notify_entry()
An opaque term that represents an entry in the 'notify' (agent) config.
-type port_info() :: inet:port_number() | system | range() | ranges().
Port number 0 (zero) cannot be specified directly (it is used internally).
Instead the atom 'system' should be used.
-type range() :: {Min :: inet:port_number(), Max :: inet:port_number()}.
Min < Max
-type ranges() :: [inet:port_number() | range()].
-type snmp_ip_address() :: [non_neg_integer()].
-opaque standard_entry()
An opaque term that represents an entry in the 'standard' (agent) config.
-opaque target_addr_entry()
An opaque term that represents an entry in the 'target address' (agent) config.
-opaque target_params_entry()
An opaque term that represents an entry in the 'target parameters' (agent) config.
-type transport_address() :: {ip_address(), inet:port_number()} | ip_address().
-type transport_opts() :: list().
-type transportAddress() :: transportAddressIPv4() | transportAddressIPv6().
-type transportAddressIPv4() :: transportAddressIPv4WithPort() | transportAddressIPv4WithoutPort().
-type transportAddressIPv4WithoutPort() :: inet:ip4_address() | [byte()].
Because of limitations of the Erlang type language we cannot define this type in detail. Instead, we describe it here.
The list variant, 4 bytes for address:
[byte() x 4]
-type transportAddressIPv4WithPort() :: {transportAddressIPv4WithoutPort(), inet:port_number()} | [byte()].
Because of limitations of the Erlang type language we cannot define this type in detail. Instead, we describe it here.
The list variant, 4 bytes for address + 2 bytes for port:
[byte() x 4, byte() x 2]
-type transportAddressIPv6() :: transportAddressIPv6WithPort() | transportAddressIPv6WithoutPort().
-type transportAddressIPv6WithoutPort() :: inet:ip6_address() | [word()] | [byte()].
Because of limitations of the Erlang type language we cannot define this type in detail. Instead, we describe it here.
First list variant, 8 words for address:
[word() x 8]
Second list variant, 16 bytes for address:
[byte() x 16]
-type transportAddressIPv6WithPort() :: {transportAddressIPv6WithoutPort(), inet:port_number()} | [word() | inet:port_number()] | [word() | byte()] | [byte()].
Because of limitations of the Erlang type language we cannot define this type in detail. Instead, we describe it here.
First list variant, 8 words for address + 1 word for port:
[word() x 8, inet:port_number()]
Second list variant, 8 words for address + 2 bytes for port:
[word() x 8, byte() x 2]
Third list variant, 16 bytes for address + 2 bytes for port:
[byte() x 16, byte() x 2]
-type transportAddressMask() :: [] | transportAddressWithPort().
-type transportAddressWithoutPort() :: transportAddressIPv4WithoutPort() | transportAddressIPv6WithoutPort().
-type transportAddressWithPort() :: transportAddressIPv4WithPort() | transportAddressIPv6WithPort().
-type transportDomain() :: snmp:tdomain().
-opaque usm_entry()
An opaque term that represents an entry in the 'user based sm' (agent) config.
-opaque vacm_acc_entry()
An opaque term that represents an (access) entry in the 'vacm access' (agent) config.
-type vacm_entry() :: vacm_s2g_entry() | vacm_acc_entry() | vacm_vtf_entry().
An basically opaque term that represents an entry in the 'view based acm' (agent) config.
-opaque vacm_s2g_entry()
An opaque term that represents an (security to group) entry in the 'vacm security to group' (agent) config.
-opaque vacm_vtf_entry()
An opaque term that represents an (tree family) entry in the 'vacm tree family' (agent) config.
-type word() :: 0..65535.
Functions
Types
Tag = intAgentTransports | intAgentUDPPort | snmpEngineMaxMessageSize | snmpEngineID
Val = term()
AgentEntry = agent_entry()
Create an entry for the agent config file, agent.conf.
The type of Val depends on the value of Tag:
intAgentTransports: [snmpa_conf:intAgentTransport()]<mandatory>intAgentUDPPort:inet:port_number()<optional>snmpEngineMaxMessageSize:snmp_framework_mib:max_message_size()<mandatory>snmpEngineID:snmp_framework_mib:engine_id()<mandatory>
See Agent Information for more info.
append_agent_config(Dir :: snmp:dir(), Conf :: [agent_entry()]) -> 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.
append_community_config(Dir :: snmp:dir(), Conf :: [community_entry()]) -> 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.
append_context_config(Dir :: snmp:dir(), Conf :: [context_entry()]) -> 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.
append_notify_config(Dir :: snmp:dir(), Conf :: [notify_entry()]) -> 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.
append_standard_config(Dir :: snmp:dir(), Conf :: [standard_entry()]) -> 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.
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.
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.
Append the usm config to 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.
append_vacm_config(Dir :: snmp:dir(), Conf :: [vacm_entry()]) -> 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.
Create an entry for the agent community config file, community.conf.
CommunityIndex must be a non-empty string.
This function only accepts the following values of CommIndex:
"public"- Translates to the following call:community_entry(CommunityIndex, CommunityIndex, "initial", "", "")."all-rights"- Translates to the following call:community_entry(CommunityIndex, CommunityIndex, CommunityIndex, "", "").
See Community for more info.
Types
CommIndex = snmp_community_mib:index()
CommName = snmp_community_mib:name()
SecName = snmp_community_mib:security_name()
CtxName = snmp_community_mib:context_name()
TransportTag = snmp_community_mib:transport_tag()
CommunityEntry = community_entry()
Create an entry for the agent community config file, community.conf.
CommunityIndex must be a non-empty string.
See Community for more info.
context_entry(Ctx :: snmp_community_mib:context_name()) -> ContextEntry
Types
ContextEntry = context_entry()
Create an entry for the agent context config file, context.conf.
See Contexts for more info.
Types
Name = snmp_notification_mib:notify_name()
Tag = snmp_notification_mib:notify_tag()
Type = snmp_notification_mib:notify_type()
NotifyEntry = 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 :: snmp:dir()) -> Result
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.
read_community_config(Dir :: snmp:dir()) -> Result
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.
read_context_config(Dir :: snmp:dir()) -> Result
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 :: snmp:dir()) -> Result
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.
read_standard_config(Dir :: snmp:dir()) -> Result
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.
read_target_addr_config(Dir :: snmp:dir()) -> Result
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.
read_target_params_config(Dir :: snmp:dir()) -> Result
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 :: snmp:dir()) -> Result
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 :: snmp:dir()) -> Result
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.
Types
Tag = sysDescr | sysObjectID | sysContact | sysName | sysLocation | sysServices |
snmpEnableAuthenTraps
Val = term()
StandardEntry = standard_entry()
Create an entry for the agent standard config file, standard.conf.
The type of Val depends on the value of Tag:
sysDescr:string()<mandatory>-DisplayString (SIZE(0..255))sysObjectID:snmp:oid()<mandatory>-OBJECT IDENTIFIERsysContact:string()<mandatory>-DisplayString (SIZE(0..255))sysName:string()<mandatory>-DisplayString (SIZE(0..255))sysLocation:string()<mandatory>-DisplayString (SIZE(0..255))sysLocation:non_neg_integer()<mandatory>- "A value which indicates the set of services that this entity primarily offers."INTEGER (0..127)snmpEnableAuthenTraps:enabled | disabled<mandatory>-INTEGER { enabled(1), disabled(2) }
See System Information for more info.
-spec target_addr_entry(Name, Domain, Addr, TagList, ParamsName, EngineId) -> TargetAddrEntry when Name :: snmp_target_mib:name(), Domain :: transportDomain(), Addr :: transportAddress(), TagList :: snmp_target_mib:tag_list(), ParamsName :: snmp_target_mib:params(), EngineId :: snmp_framework_mib:engine_id(), TargetAddrEntry :: target_addr_entry(); (Name, IP, TagList, ParamsName, EngineId, TMask) -> TargetAddrEntry when Name :: snmp_target_mib:name(), IP :: inet:ip_address(), TagList :: snmp_target_mib:tag_list(), ParamsName :: snmp_target_mib:params(), EngineId :: snmp_framework_mib:engine_id(), TMask :: snmp_target_mib:tmask(), TargetAddrEntry :: 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 (1) translates to the following call:
target_addr_entry(Name, Domain, Addr, TagList, ParamsName, EngineId, []).
target_addr_entry/6 (2) translates to the following call (with Domain and Addr built from IP and the default port number):
target_addr_entry(Name, Domain, Addr, TagList, ParamsName, EngineId, TMask, 2048).
See Target Address Definitions for more info.
-spec target_addr_entry(Name, Domain, Addr, TagList, ParamsName, EngineId, TMask) -> TargetAddrEntry when Name :: snmp_target_mib:name(), Domain :: transportDomain(), Addr :: transportAddress(), TagList :: snmp_target_mib:tag_list(), ParamsName :: snmp_target_mib:params(), EngineId :: snmp_framework_mib:engine_id(), TMask :: snmp_target_mib:tmask(), TargetAddrEntry :: target_addr_entry(); (Name, IP, Port, TagList, ParamsName, EngineId, TMask) -> TargetAddrEntry when Name :: snmp_target_mib:name(), IP :: inet:ip_address(), Port :: inet:port_number(), TagList :: snmp_target_mib:tag_list(), ParamsName :: snmp_target_mib:params(), EngineId :: snmp_framework_mib:engine_id(), TMask :: snmp_target_mib:tmask(), TargetAddrEntry :: 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/7 (1) translates to the following call:
target_addr_entry(Name, Domain, Addr, TagList, ParamsName, EngineId, TMask, 2048).
target_addr_entry/7 (2) translates to the following call (with Domain and Addr built from IP and Port):
target_addr_entry(Name, Domain, Addr, TagList, ParamsName, EngineId, TMask, 2048).
See Target Address Definitions for more info.
-spec target_addr_entry(Name, Domain, Addr, TagList, ParamsName, EngineId, TMask, MaxMessageSize) -> TargetAddrEntry when Name :: snmp_target_mib:name(), Domain :: transportDomain(), Addr :: transportAddress(), TagList :: snmp_target_mib:tag_list(), ParamsName :: snmp_target_mib:params(), EngineId :: snmp_framework_mib:engine_id(), TMask :: snmp_target_mib:tmask(), MaxMessageSize :: snmp_target_mib:mms(), TargetAddrEntry :: target_addr_entry(); (Name, IP, Port, TagList, ParamsName, EngineId, TMask, MaxMessageSize) -> TargetAddrEntry when Name :: snmp_target_mib:name(), IP :: inet:ip_address(), Port :: inet:port_number(), TagList :: snmp_target_mib:tag_list(), ParamsName :: snmp_target_mib:params(), EngineId :: snmp_framework_mib:engine_id(), TMask :: snmp_target_mib:tmask(), MaxMessageSize :: snmp_target_mib:mms(), TargetAddrEntry :: 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/8 (1) translates to the following call:
target_addr_entry(Name, Domain, Addr, 1500, 3, TagList, ParamsName, EngineId, TMask, MaxMessageSize).
target_addr_entry/8 (2) translates to the following call (with Domain and Addr built from IP and Port):
target_addr_entry(Name, Domain, Addr, 1500, 3, TagList, ParamsName, EngineId, TMask, MaxMessageSize).
See Target Address Definitions for more info.
Types
Name = snmp_target_mib:name()
Domain = transportDomain()
Addr = transportAddress()
Timeout = snmp:time_interval()
RetryCount = snmp_target_mib:retry_count()
TagList = snmp_target_mib:tag_list()
ParamsName = snmp_framework_mib:admin_string()
EngineId = snmp_framework_mib:engine_id()
TMask = snmp_target_mib:tmask()
MaxMessageSize = snmp_target_mib:mms()
TargetAddrEntry = target_addr_entry()
Create an entry for the agent target_addr config file, target_addr.conf.
Name must be a non-empty string.
See Target Address Definitions for more info.
Create an entry for the agent target_params config file, target_params.conf.
Name must be a non-empty string.
target_params_entry/2 translates to the following
call:
target_params_entry(Name, Vsn, "initial", noAuthNoPriv)See Target Parameters Definitions for more info.
Types
Name = snmp_target_mib:name()
Vsn = snmp:version()
SecName = snmp_framework_mib:admin_string()
SecLevel = snmp_framework_mib:security_level()
TargetParamsEntry = 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:
Vsn = v1 => MPModel = v1, SecModel = v1
Vsn = v2 => MPModel = v2c, SecModel = v2c
Vsn = v3 => MPModel = v3, SecModel = usmtarget_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.
Types
Name = snmp_target_mib:name()
MPModel = snmp_framework_mib:message_processing_model()
SecModel = snmp_framework_mib:security_model()
SecName = snmp_framework_mib:admin_string()
SecLevel = snmp_framework_mib:security_level()
TargetParamsEntry = target_params_entry()
Create an entry for the agent target_params config file, target_params.conf.
Name must be a non-empty string.
See Target Parameters Definitions for more info.
usm_entry(EngineID :: snmp_framework_mib:engine_id()) -> UsmEntry
Types
UsmEntry = usm_entry()
Create an entry for the agent usm config file, usm.conf.
usm_entry/1 translates to the following call:
usm_entry(EngineID,
"initial", "initial", zeroDotZero,
usmNoAuthProtocol, "", "",
usmNoPrivProtocol, "", "",
"", "", "").See Security data for USM for more info.
Types
EngineID = snmp_framework_mib:engine_id()
UserName = snmp_user_based_sm_mib:name()
SecName = snmp_framework_mib:admin_string()
Clone = snmp_user_based_sm_mib:clone_from()
AuthP = snmp_user_based_sm_mib:auth_protocol()
AuthKeyC = OwnAuthKeyC = PrivKeyC = OwnPrivKeyC = snmp_user_based_sm_mib:key_change()
PrivP = snmp_user_based_sm_mib:priv_protocol()
Public = snmp_user_based_sm_mib:public()
AuthKey = snmp_user_based_sm_mib:auth_key()
PrivKey = snmp_user_based_sm_mib:priv_key()
UsmEntry = usm_entry()
Create an entry for the agent usm config file, usm.conf.
See Security data for USM for more info.
Types
GroupName = RV = WV = NV = snmp_framework_mib:admin_string()
Prefix = snmp_view_based_acm_mib:context_prefix()
SecModel = snmp_framework_mib:security_model()
SecLevel = snmp_framework_mib:security_level()
Match = snmp_view_based_acm_mib:context_match()
VacmAccEntry = vacm_acc_entry()
Create an (access) entry for the agent vacm config file, vacm.conf.
See MIB Views for VACM for more info.
Types
SecModel = snmp_framework_mib:security_model()
SecName = snmp_view_based_acm_mib:security_name()
GroupName = snmp_framework_mib:admin_string()
VacmS2GEntry = vacm_s2g_entry()
Create an (security to group) entry for the agent vacm config file, vacm.conf.
See MIB Views for VACM for more info.
Types
ViewName = snmp_framework_mib:admin_string()
ViewSubtree = snmp:oid()
VacmVtfEntry = VacmVtfEntry
Create an (view tree family) 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.
Types
ViewName = snmp_framework_mib:admin_string()
ViewSubtree = snmp:oid()
ViewType = snmp_view_based_acm_mib:view_type()
ViewMask = null | snmp_view_based_acm_mib:view_mask()
VacmVtfEntry = VacmVtfEntry
Create an (view tree family) entry for the agent vacm config file, vacm.conf.
See MIB Views for VACM for more info.
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.
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.
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.
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.
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.
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.
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.
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.
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.