Definition of Manager Configuration Files
View SourceConfiguration data may be included in configuration files that is located in the
configuration directory. The name of this directory is given in the config_dir
configuration parameter. These files are read at start-up.
The directory where the configuration files are found is given as a parameter to the manager.
The entry format in all files are Erlang terms, separated by a '.' and a newline. In the following sections, the formats of these terms are described. Comments may be specified as ordinary Erlang comments.
If syntax errors are discovered in these files they are reported with the
function config_err/2 of the error report module at
start-up.
Manager Information
The manager information should be stored in a file called manager.conf.
Each entry is a tuple of size two:
{Variable, Value}.
Variableis one of the following:transports- which defines the transport domains and their addresses for the manager. MandatoryValueis a list of{Domain, Addr}tuples orDomainatoms.Domainis one oftransportDomainUdpIpv4ortransportDomainUdpIpv6.Addris for the currently supported domains either anIpAddror an{IpAddr, IpPort}tuple.IpAddris either a regular Erlang/OTPip_address()or a traditional SNMP integer list andIpPortis an integer.When
Addrdoes not contain a port number, the value ofportis used.When a
Addris not specified i.e by using only aDomainatom, the host's name is resolved to find the IP address, and the value ofportis used.
port- which defines which UDP port the manager uses for communicating with agents. Mandatory iftransportsdoes not define a port number for every transport.engine_id- TheSnmpEngineIDas defined in SNMP-FRAMEWORK-MIB. Mandatory.max_message_size- ThesnmpEngineMaxMessageSizeas defined in SNMP-FRAMEWORK-MIB. Mandatory.
Valueis the value for the variable.
The legacy and intermediate variables address and domain are still supported
so old configurations will work.
The following example shows a manager.conf file:
{transports, [{transportDomainUdpIpv4, {{141,213,11,24}, 5000}},
{transportDomainUdpIpv6, {{0,0,0,0,0,0,0,1}, 5000}}]}.
{engine_id, "mgrEngine"}.
{max_message_size, 484}.The value of engine_id is a string, which should have a very specific
structure. See RFC 2271/2571 for details.
And this is a code (snippet) example of how to generate this file in runtime:
ManagerDir = "/tmp",
Port = 5000,
Addr4 = {141,213,11,24},
Addr6 = {0,0,0,0,0,0,0,1},
Transports = [{transportDomainUdpIpv4, {Addr4, Port}},
{transportDomainUdpIpv6, {Addr6, Port}}],
EngineID = "mgrEngine",
MMS = 484,
ManagerConfig = [snmpm_conf:manager_entry(transports, Transports),
snmpm_conf:manager_entry(engine_id, EngineID),
snmpm_conf:manager_entry(max_message_size, MMS)],
snmpm_conf:write_manager_config(ManagerDir, ManagerConfig),Users
For each manager user, the manager needs some information. This information is
either added in the users.conf config file or by calling the
register_user function in run-time.
Each row defines a manager user of the manager.
Each entry is a tuple of size four:
{UserId, UserMod, UserData, DefaultAgentConfig}.
UserIdis any term (used to uniquely identify the user).UserModis the user callback module (atom).UserDatais any term (passed on to the user when calling theUserMod.DefaultAgentConfigis a list of default agent config's. These values are used as default values when this user registers agents.
And this is a code (snippet) example of how to generate this file in runtime:
ManagerDir = "/tmp",
UserID = make_ref(),
UserMod = my_manager_callback_mod,
UserData = self(),
DefaultAgentConfig = [{version, v1}, {timeout, 2500}, {max_message_size, 484}],
UsersConfig = [snmpm_conf:users_entry(UserID, UserMod, UserData,
DefaultAgentConfig)],
snmpm_conf:write_users_config(ManagerDir, UsersConfig),Agents
The information needed to handle agents should be stored in a file called
agents.conf. It is also possible to add agents in run-time by calling the
register_agent.
Each entry is a tuple:
{UserId, TargetName, Comm, Domain, Addr, EngineID, Timeout, MaxMessageSize, Version, SecModel, SecName, SecLevel}.
UserIdis the identity of the manager user responsible for this agent (term).TargetNameis a unique non-empty string.Commis the community string (string).Domainis the transport domain, eithertransportDomainUdpIpv4ortransportDomainUdpIpv6.Addris the address in the transport domain, either an{IpAddr, IpPort}tuple or a traditional SNMP integer list containing port number.IpAddris either a regular Erlang/OTPip_address()or a traditional SNMP integer list not containing port number, andIpPortis an integer.EngineIDis the engine-id of the agent (string).Timeoutis re-transmission timeout (infinity| integer).MaxMessageSizeis the max message size for outgoing messages to this agent (integer).Versionis the version (v1 | v2 | v3).SecModelis the security model (any | v1 | v2c | usm).SecNameis the security name (string).SecLevelis security level (noAuthNoPriv | authNoPriv | authPriv).
Legacy configurations using tuples without Domain element, as well as with all
TDomain, Ip and Port elements still work.
And this is a code (snippet) example of how to generate this file in runtime:
ManagerDir = "/tmp",
UserID = ...
AgentsConfig = [snmpm_conf:agents_entry(UserID,
"target 1",
"FOOBAR",
transportDomainUdpIpv4, {{1,2,3,4},161},
"agent Engine 1"
1500,
484.
v1, v1, "sec name 1", noAuthNoPriv),
snmpm_conf:agents_entry(UserID,
"target 2",
"FOOBAR",
transportDomainUdpIpv4, {{5,6,7,8},161},
"agent Engine 2"
1500,
1000.
v1, v1, "sec name 2", noAuthNoPriv)],
snmpm_conf:write_agents_config(ManagerDir, UsersConfig),Security data for USM
The information about Security data for USM should be stored in a file called
usm.conf, which must be present if the manager wishes to use SNMPv3 when
communicating with agents. It is also possible to add usm data in run-time by
calling the register_usm_user.
The corresponding table is usmUserTable in the SNMP-USER-BASED-SM-MIB
(adjusted according to SNMP-USM-HMAC-SHA2-MIB).
Each entry is a term:
{EngineID, UserName, AuthP, AuthKey, PrivP, PrivKey}.{EngineID, UserName, SecName, AuthP, AuthKey, PrivP, PrivKey}.
The first case is when we have the identity-function (SecName = UserName).
EngineIDis a string.UserNameis a string.SecNameis a string.AuthPis ausmNoAuthProtocol,usmHMACMD5AuthProtocol,usmHMACSHAAuthProtocol,usmHMAC128SHA224AuthProtocol,usmHMAC192SH256AuthProtocol,usmHMAC256SHA384AuthProtocolorusmHMAC384SHA512AuthProtocol.AuthKeyis a list (of integer). This is the User's secret localized authentication key. It is not visible in the MIB. The length (number of octets) of this key needs to be:- 16 if
usmHMACMD5AuthProtocol. - 20 if
usmHMACSHAAuthProtocol. - 28 if
usmHMAC128SHA224AuthProtocol. - 32 if
usmHMAC192SHA256AuthProtocol. - 48 if
usmHMAC256SHA384AuthProtocol. - 64 if
usmHMAC384SHA512AuthProtocol.
- 16 if
PrivPis ausmNoPrivProtocol,usmDESPrivProtocolorusmAesCfb128Protocol.PrivKeyis a list (of integer). This is the User's secret localized encryption key. It is not visible in the MIB. The length of this key needs to be 16 ifusmDESPrivProtocolorusmAesCfb128Protocolis used.
ManagerDir = "/tmp",
UsmConfig = [snmpm_conf:usm_entry("engine",
"user 1",
usmNoAuthProtocol,
[],
usmNoPrivProtocol,
[])],
snmpm_conf:write_usm_config(ManagerDir, UsmConfig),