SNMP
SNMP
(SNMP)
Copyright 1997-2014 Ericsson AB. All Rights Reserved.
Simple Network Management Protocol (SNMP) 5.1.1
December 9, 2014
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 1
1.1SNMP Introduction
1.1SNMP Introduction
The SNMP development toolkit contains the following parts:
An Extensible multi-lingual SNMP agent, which understands SNMPv1 (RFC1157), SNMPv2c (RFC1901,
1905, 1906 and 1907), SNMPv3 (RFC2271, 2272, 2273, 2274 and 2275), or any combination of these
protocols.
A multi-lingual SNMP manager.
A MIB compiler, which understands SMIv1 (RFC1155, 1212, and 1215) and SMIv2 (RFC1902, 1903, and
1904).
The SNMP development tool provides an environment for rapid agent/manager prototyping and construction. With
the following information provided, this tool is used to set up a running multi-lingual SNMP agent/manager:
a description of a Management Information Base (MIB) in Abstract Syntax Notation One (ASN.1)
instrumentation functions for the managed objects in the MIB, written in Erlang.
The advantage of using an extensible (agent/manager) toolkit is to remove details such as type-checking, access rights,
Protocol Data Unit (PDU), encoding, decoding, and trap distribution from the programmer, who only has to write
the instrumentation functions, which implement the MIBs. The get-next function only has to be implemented for
tables, and not for every variable in the global naming tree. This information can be deduced from the ASN.1 file.
1.1.2 Prerequisites
The following prerequisites is required for understanding the material in the SNMP User's Guide:
1.1.3 Definitions
The following definitions are used in the SNMP User's Guide.
2 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
1.1SNMP Introduction
MIB
The conceptual repository for management information is called the Management Information Base (MIB).
It does not hold any data, merely a definition of what data can be accessed. A definition of an MIB is a
description of a collection of managed objects.
SMI
The MIB is specified in an adapted subset of the Abstract Syntax Notation One (ASN.1) language. This
adapted subset is called the Structure of Management Information (SMI).
ASN.1
ASN.1 is used in two different ways in SNMP. The SMI is based on ASN.1, and the messages in the protocol
are defined by using ASN.1.
Managed object
A resource to be managed is represented by a managed object, which resides in the MIB. In an SNMP MIB, the
managed objects are either:
scalar variables, which have only one instance per context. They have single values, not multiple values
like vectors or structures.
tables, which can grow dynamically.
a table element, which is a special type of scalar variable.
Operations
SNMP relies on the three basic operations: get (object), set (object, value) and get-next (object).
Instrumentation function
An instrumentation function is associated with each managed object. This is the function, which actually
implements the operations and will be called by the agent when it receives a request from the management
station.
Manager
A manager generates commands and receives notifications from agents. There usually are only a few managers
in a system.
Agent
An agent responds to commands from the manager, and sends notification to the manager. There are potentially
many agents in a system.
Chapter 2: "Functional Description" describes the features and operation of the SNMP development toolkit. It
includes topics on Sub-agents and MIB loading, Internal MIBs, and Traps.
Chapter 3: "The MIB Compiler" describes the features and the operation of the MIB compiler.
Chapter 4: "Running the application" describes how to start and configure the application. Topics on how to
debug the application are also included.
Chapter 5: "Definition of Agent Configuration Files" is a reference chapter, which contains more detailed
information about the agent configuration files.
Chapter 6: "Definition of Manager Configuration Files" is a reference chapter, which contains more detailed
information about the manager configuration files.
Chapter 7: "Agent Implementation Example" describes how an MIB can be implemented with the SNMP
Development Toolkit. Implementation examples are included.
Chapter 8: "Instrumentation Functions" describes how instrumentation functions should be defined in Erlang for
the different operations.
Chapter 9: "Definition of Instrumentation Functions" is a reference chapter which contains more detailed
information about the instrumentation functions.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 3
Chapter 10: "Definition of Agent Net if" is a reference chapter, which describes the Agent Net if function in
detail.
Chapter 11: "Definition of Manager Net if" is a reference chapter, which describes the Manager Net if function
in detail.
Chapter 12: "Advanced Agent Topics" describes sub-agents, agent semantics, audit trail logging, and the
consideration of distributed tables.
Appendix A describes the conversion of SNMPv2 to SNMPv1 error messages.
Appendix B contains the RFC1903 text on RowStatus.
Marshall T. Rose (1991), "The Simple Book - An Introduction to Internet Management", Prentice-Hall
Evan McGinnis and David Perkins (1997), "Understanding SNMP MIBs", Prentice-Hall
RFC1155, 1157, 1212 and 1215 (SNMPv1)
RFC1901-1907 (SNMPv2c)
RFC1908, 2089 (coexistence between SNMPv1 and SNMPv2)
RFC2271, RFC2273 (SNMP std MIBs)
the Mnesia User's Guide
the Erlang 4.4 Extensions User's Guide
the Reference Manual
the Erlang Embedded Systems User's Guide
the System Architecture Support Libraries (SASL) User's Guide
the Installation Guide
the Asn1 User's Guide
Concurrent Programming in Erlang, 2nd Edition (1996), Prentice-Hall, ISBN 0-13-508301-X.
1.2.1 Features
To implement an agent, the programmer writes instrumentation functions for the variables and the tables in the MIBs
that the agent is going to support. A running prototype which handles set, get, and get-next can be created
without any programming.
The toolkit provides the following:
4 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
access control
authentication
privacy through encryption
loading and unloading of MIBs in run-time
the ability to change instrumentation functions without recompiling the MIB
rapid prototyping environment where the MIB compiler can use generic instrumentation functions, which later
can be refined by the programmer
a simple and extensible model for transaction handling and consistency checking of set-requests
support of the sub-agent concept via distributed Erlang
a mechanism for sending notifications (traps and informs)
support for implementing SNMP tables in the Mnesia DBMS.
Over time, as the Framework has evolved from SNMPv1 , through SNMPv2, to SNMPv3 the definitions of each of
these architectural components have become richer and more clearly defined, but the fundamental architecture has
remained consistent.
The main features of SNMPv2 compared to SNMPv1 are:
The standard documents that define SNMPv2 are incomplete, in the sense that they do not specify how an SNMPv2
message looks like. The message format and security issues are left to a special Administrative Framework. One
such framework is the Community-based SNMPv2 Framework (SNMPv2c), which uses the same message format and
framework as SNMPv1. Other experimental frameworks as exist, e.g. SNMPv2u and SNMPv2*.
The SNMPv3 specifications take a modular approach to SNMP. All modules are separated from each other, and can
be extended or replaced individually. Examples of modules are Message definition, Security and Access Control. The
main features of SNMPv3 are:
All these specifications are commonly referred to as "SNMPv3", but it is actually only the Message module, which
defines a new message format, and Security module, which takes care of encryption and authentication, that cannot
be used with SNMPv1 or SNMPv2c. In this version of the agent toolkit, all the standard MIBs for agent configuration
are used. This includes MIBs for definition of management targets for notifications. These MIBs are used regardless
of which SNMP version the agent is configured to use.
The extensible agent in this toolkit understands the SNMPv1, SNMPv2c and SNMPv3. Recall that SNMP consists
of two separate parts, the MIB definition language (SMI), and the protocol. On the protocol level, the agent can be
configured to speak v1, v2c, v3 or any combination of them at the same time, i.e. a v1 request gets an v1 reply, a v2c
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 5
request gets a v2c reply, and a v3 request gets a v3 reply. On the MIB level, the MIB compiler can compile both SMIv1
and SMIv2 MIBs. Once compiled, any of the formats can be loaded into the agent, regardless of which protocol version
the agent is configured to use. This means that the agent translates from v2 notifications to v1 traps, and vice versa.
For example, v2 MIBs can be loaded into an agent that speaks v1 only. The procedures for the translation between
the two protocols are described in RFC 1908 and RFC 2089.
In order for an implementation to make full use of the enhanced SNMPv2 error codes, it is essential that the
instrumentation functions always return SNMPv2 error codes, in case of error. These are translated into the
corresponding SNMPv1 error codes by the agent, if necessary.
Note:
The translation from an SMIv1 MIB to an SNMPv2c or SNMPv3 reply is always very straightforward, but
the translation from a v2 MIB to a v1 reply is somewhat more complicated. There is one data type in SMIv2,
called Counter64, that an SNMPv1 manager cannot decode correctly. Therefore, an agent may never send
a Counter64 object to an SNMPv1 manager. The common practice in these situations is to simple ignore
any Counter64 objects, when sending a reply or a trap to an SNMPv1 manager. For example, if an SNMPv1
manager tries to GET an object of type Counter64, he will get a noSuchName error, while an SNMPv2
manager would get a correct value.
1.2.3 Operation
The following steps are needed to get a running agent:
The figures in this section illustrate the steps involved in the development of an SNMP agent.
6 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
The compiler parses the SMI file and associates each table or variable with an instrumentation function (see the figure
MIB Compiler Principles). The actual instrumentation functions are not needed at MIB compile time, only their names.
The binary output file produced by the compiler is read by the agent at MIB load time (see the figure Starting the Agent).
The instrumentation is ordinary Erlang code which is loaded explicitly or automatically the first time it is called.
The SNMP agent system consists of one Master Agent and optional sub-agents. The Master Agent can be seen as a
special kind of sub-agent. It implements the core agent functionality, UDP packet processing, type checking, access
control, trap distribution, and so on. From a user perspective, it is used as an ordinary sub-agent.
Sub-agents are only needed if your application requires special support for distribution from the SNMP toolkit. A
sub-agent can also be used if the application requires a more complex set transaction scheme than is found in the
master agent.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 7
The sequence of steps shown is probably more complex than normal, but it illustrates the amount of functionality
which is available. The following points should be noted:
Most applications only need the Master Agent because an agent can have multiple MIBs loaded at the same time.
8 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
Refer to the chapter Advanced Agent Topics in this User's Guide for more information about these topics.
The communication protocol between sub-agents is the normal message passing which is used in distributed Erlang
systems. This implies that sub-agent communication is very efficient compared to SMUX, DPI, AgentX, and similar
protocols.
In SNMPv3, each of these usage areas has its own unique mechanism. A context is identified by the name of the
SNMP entity, contextEngineID, and the name of the context, contextName. Each SNMPv3 message contains
values for these two parameters.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 9
All of these MIBs should be loaded into the Master Agent. Once loaded, these MIBs are always available in all contexts.
The ASN.1 code, the Erlang source code, and the generated .hrl files for them are provided in the distribution and
are placed in the directories mibs, src, and include, respectively, in the snmp application.
The .hrl files are generated with snmpc:mib_to_hrl/1. Include these files in your code as in the following
example:
-include_lib("snmp/include/SNMPv2-MIB.hrl").
The initial values for the managed objects defined in these tables, are read at start-up from a set of configuration files.
These are described in Configuration Files.
10 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 11
snmpTargetParamsTable
An entry in the snmpTargetParamsTable defines which SNMP version to use, and which security parameters
to use.
Which SNMP version to use is implicitly defined by specifying the Message Processing Model. This version of the
agent handles the models v1, v2c and v3.
Each row specifies which security model to use, along with security level and security parameters.
SNMP-VIEW-BASED-ACM-MIB
The SNMP-VIEW-BASED-ACM-MIB defines managed objects to control access to the the managed objects for the
managers. The View Based Access Control Module (VACM) can be used with any SNMP version. However, if it
is used with SNMPv1 or SNMPv2c, the SNMP-COMMUNITY-MIB defines additional objects to map community
strings to VACM parameters.
All tables in this MIB have a column of type StorageType. The value of this column specifies how each row
is stored, and what happens in case of a restart of the agent. The implementation supports the values volatile
and nonVolatile. When the tables are initially filled with data from the configuration files, these rows will
automatically have storage type nonVolatile. Should the agent restart, all nonVolatile rows survive the restart,
while the volatile rows are lost. The configuration files are not read at restart by default.
This MIB is not loaded by default.
VACM is described in detail in RFC2275. Here is only a brief description given.
The basic concept is that of a MIB view. An MIB view is a subset of all the objects implemented by an agent. A
manager has access to a certain MIB view, depending on which security parameters are used, in which context the
request is made, and which type of request is made.
The following picture gives an overview of the mechanism to select an MIB view:
12 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
vacmContextTable
The vacmContextTable is a read-only table that lists all available contexts.
vacmSecurityToGroupTable
The vacmSecurityToGroupTable maps a securityModel and a securityName to a groupName.
vacmAccessTable
The vacmAccessTable maps the groupName (found in vacmSecurityToGroupTable), contextName,
securityModel, and securityLevel to an MIB view for each type of operation (read, write, or notify). The
MIB view is represented as a viewName. The definition of the MIB view represented by the viewName is found
in the vacmViewTreeFamilyTable
vacmViewTreeFamilyTable
The vacmViewTreeFamilyTable is indexed by the viewName, and defines which objects are included in the
MIB view.
The MIB definition for the table looks as follows:
SnmpAdminString,
OBJECT IDENTIFIER,
OCTET STRING,
INTEGER,
StorageType,
RowStatus
INDEX { vacmViewTreeFamilyViewName,
vacmViewTreeFamilySubtree
}
the OBJECT IDENTIFIER name of that MIB object instance comprises at least as many sub-identifiers as does
the sub-tree, and
each sub-identifier in the name of that MIB object instance matches the corresponding sub-identifier of the subtree whenever the corresponding bit of the associated mask is 1 (0 is a wild card that matches anything).
If an MIB object instance does not belong to any of the relevant sub-trees, then the instance is not in the MIB
view.
If an MIB object instance belongs to exactly one sub-tree, then the instance is included in, or excluded from, the
relevant MIB view according to the type of that entry.
If an MIB object instance belongs to more than one sub-tree, then the sub-tree which comprises the greatest
number of sub-identifiers, and is the lexicographically greatest, is used.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 13
Note:
If the OBJECT IDENTIFIER is longer than an OBJECT IDENTIFIER of an object type in the MIB, it refers to
object instances. Because of this, it is possible to control whether or not particular rows in a table shall be visible.
SNMP-COMMUNITY-MIB
The SNMP-COMMUNITY-MIB defines managed objects that is used for coexistence between SNMPv1 and
SNMPv2c with SNMPv3. Specifically, it contains objects for mapping between community strings and versionindependent SNMP message parameters. In addition, this MIB provides a mechanism for performing source address
validation on incoming requests, and for selecting community strings based on target addresses for outgoing
notifications.
All tables in this MIB have a column of type StorageType. The value of this column specifies how each row
is stored, and what happens in case of a restart of the agent. The implementation supports the values volatile
and nonVolatile. When the tables are initially filled with data from the configuration files, these rows will
automatically have storage type nonVolatile. Should the agent restart, all nonVolatile rows survive the restart,
while the volatile rows are lost. The configuration files are not read at restart, by default.
This MIB is not loaded by default.
SNMP-USER-BASED-SM-MIB
The SNMP-USER-BASED-SM-MIB defines managed objects that is used for the User-Based Security Model.
All tables in this MIB have a column of type StorageType. The value of the column specifies how each row
is stored, and what happens in case of a restart of the agent. The implementation supports the values volatile
and nonVolatile. When the tables are initially filled with data from the configuration files, these rows will
automatically have storage type nonVolatile. Should the agent restart, all nonVolatile rows survive the restart,
while the volatile rows are lost. The configuration files are not read at restart, by default.
This MIB is not loaded by default.
OTP-SNMPEA-MIB
The OTP-SNMPEA-MIB was used in earlier versions of the agent, before standard MIBs existed for access control,
MIB views, and trap target specification. All objects in this MIB are now obsolete.
1.2.7 Notifications
Notifications are defined in SMIv1 with the TRAP-TYPE macro in the definition of an MIB (see RFC1215). The
corresponding macro in SMIv2 is NOTIFICATION-TYPE. When an application decides to send a notification, it calls
one of the following functions:
providing the registered name or process identifier of the agent where the MIB, which defines the notification is loaded
and the symbolic name of the notification.
If the send_notification/3,4 function is used, all management targets are selected, as defined in RFC2273.
The Receiver parameter defines where the agent should send information about the delivery of inform requests.
14 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
If the send_notification/5 function is used, an NotifyName must be provided. This parameter is used as an
index in the snmpNotifyTable, and the management targets defined by that single entry is used.
The send_notification/6 function is the most general version of the function. A ContextName must be
specified, from which the notification will be sent. If this parameter is not specified, the default context ("") is used.
The function send_trap is kept for backwards compatibility and should not be used in new code. Applications that
use this function will continue to work. The snmpNotifyName is used as the community string by the agent when
a notification is sent.
Notification Sending
The simplest way to send a notification is to call the function snmpa:send_notification(Agent,
Notification, no_receiver). In this case, the agent performs a get-operation to retrieve the object values
that are defined in the notification specification (with the TRAP-TYPE or NOTIFICATION-TYPE macros). The
notification is sent to all managers defined in the target and notify tables, either unacknowledged as traps, or
acknowledged as inform requests.
If the caller of the function wants to know whether or not acknowledgments are received for a certain notification
(provided it is sent as an inform), the Receiver parameter can be specified as {Tag, ProcessName} (refer
to the Reference Manual, section snmp, module snmp for more details). In this case, the agent send a message
{snmp_notification, Tag, {got_response, ManagerAddr}} or {snmp_notification, Tag,
{no_response, ManagerAddr}} for each management target.
Sometimes it is not possible to retrieve the values for some of the objects in the notification specification with a getoperation. However, they are known when the send_notification function is called. This is the case if an object
is an element in a table. It is possible to give the values of some objects to the send_notification function
snmpa:send_notification(Agent, Notification, Receiver, Varbinds). In this function,
Varbinds is a list of Varbind, where each Varbind is one of:
{Variable, Value}, where Variable is the symbolic name of a scalar variable referred to in the
notification specification.
{Column, RowIndex, Value}, where Column is the symbolic name of a column variable. RowIndex
is a list of indices for the specified element. If this is the case, the OBJECT IDENTIFIER sent in the trap is the
RowIndex appended to the OBJECT IDENTIFIER for the table column. This is the OBJECT IDENTIFIER
which specifies the element.
{OID, Value}, where OID is the OBJECT IDENTIFIER for an instance of an object, scalar variable or
column variable.
For example, to specify that sysLocation should have the value "upstairs" in the notification, we could use
one of:
{sysLocation, "upstairs"} or
{[1,3,6,1,2,1,1,6,0], "upstairs"}
It is also possible to specify names and values for extra variables that should be sent in the notification, but were not
defined in the notification specification.
The notification is sent to all management targets found in the tables. However, make sure that each manager has
access to the variables in the notification. If a variable is outside a manager's MIB view, this manager will not receive
the notification.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 15
Note:
By definition, it is not possible to send objects with ACCESS not-accessible in notifications. However,
historically this is often done and for this reason we allow it in notification sending. If a variable has ACCESS
not-accessible, the user must provide a value for the variable in the Varbinds list. It is not possible for
the agent to perform a get-operation to retrieve this value.
Notification Filters
It is possible to add notification filters to an agent. These filters will be called when a notification is to be sent. Their
purpose is to allow modification, suppression or other type of actions.
A notification filter is a module implementing the snmpa_notification_filter behaviour. A filter is added/deleted using
the functions: snmpa:register_notification_filter and snmpa:unregister_notification_filter.
Unless otherwise specified, the order of the registered filters will be the order in which they are registered.
Sub-agent Path
If a value for an object is not given to the send_notification function, the sub-agent will perform a get-operation
to retrieve it. If the object is not implemented in this sub-agent, its parent agent tries to perform a get-operation to
retrieve it. If the object is not implemented in this agent either, it forwards the object to its parent, and so on. Eventually
the Master Agent is reached and at this point all unknown object values must be resolved. If some object is unknown
even to the Master Agent, this is regarded as an error and is reported with a call to user_err/2 of the error report
module. No notifications are sent in this case.
For a given notification, the variables, which are referred to in the notification specification, must be implemented by
the agent that has the MIB loaded, or by some parent to this agent. If not, the application must provide values for the
unknown variables. The application must also provide values for all elements in tables.
1.2.8 Discovery
The sender is authoritative for messages containing payload which does not expect a response (for example SNMPv2Trap, Response or Report PDU).
The receiver is authoritative for messages containing payload which expects a response (for example Get, GetNext,
Get-Bulk, Set or Inform PDU).
The agent can both perform and respond to discovery.
The agent responds to discovery autonomously, without interaction by the user.
Initiating discovery towards a manager is done by calling the discovery function. The EngineId field of the target
(manager) entry in the target_addr.conf file has to have the value discovery. Note that if the manager does not
respond, the Timeout and RetryCount fields decide how long the function will hang before it returns.
Discovery can only be performed towards one manager at a time.
16 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
A user in this context is basically a module implementing the snmpm_user behaviour. A user can issue snmp requests
and receive notification/traps.
Agents to be accessed by the manager needs to be registered by a user. Once registered, they can be accessed by all
registered users.
Notifications/traps from an agent is delivered to the user that did the registration.
Any message from an agent that is not registered is delivered to the default user.
By default, the default user is set to the snmpm_user_default module, which simply sends an info message to the
error_logger. It is however highly recommended that this module be replaced by another that does something useful
(see configuration params for more info).
When using version 3, then (at least one) usm user has to be registered.
Requests can be issued in two different ways. Synchronous (see sync_set, sync_get, sync_get_next and sync_get_bulk)
and asynchronous (see async_set, async_get, async_get_next and async_get_bulk). With synchronous the snmp reply
is returned by the function. With asynchronous, the reply will instead be delivered through a call to one of the
handle_pdu callback function defined by the handle_pdu behaviour.
1.3.2 Operation
The following steps are needed to get the manager running:
Operation
Import
Consistency checking between MIBs
.hrl file generation
Emacs integration
Deviations from the standard
Note:
When importing MIBs, ensure that the imported MIBs as well as the importing MIB are compiled using the same
version of the SNMP-compiler.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 17
1.4.1 Operation
The MIB must be written as a text file in SMIv1 or SMIv2 using an ASN.1 notation before it will be compiled. This
text file must have the same name as the MIB, but with the suffix .mib. This is necessary for handling the IMPORT
statement.
The association file, which contains the names of instrumentation functions for the MIB, should have the suffix
.funcs. If the compiler does not find the association file, it gives a warning message and uses default instrumentation
functions. (See Default Instrumentation for more details).
The MIB compiler is started with a call to snmpc:compile(<mibname>). For example:
snmpc:compile("RFC1213-MIB").
snmpc:compile("MY-MIB",
[{i, ["friend_mibs/", "../standard_mibs/"]}]).
It is also possible to import MIBs from OTP applications in an "include_lib" like fashion with the il option.
Example:
snmpc:compile("MY-MIB",
[{il, ["snmp/priv/mibs/", "myapp/priv/mibs/"]}]).
finds the latest version of the snmp and myapp applications in the OTP system and uses the expanded paths as include
paths.
Note that an SMIv2 MIB can import an SMIv1 MIB and vice versa.
The following MIBs are built-ins of the Erlang SNMP compiler: SNMPv2-SMI, RFC-1215, RFC-1212, SNMPv2TC, SNMPv2-CONF, and RFC1155-SMI. They cannot therefore be compiled separately.
18 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
erl>snmpc:is_consistent(ListOfMibNames).
ListOfMibNames is a list of compiled MIBs, for example ["RFC1213-MIB", "MY-MIB"]. The function also
performs consistency checking of trap definitions.
erl>snmpc:mib_to_hrl(MibName).
erlc MY-MIB.mib
The flags specific to the MIB compiler can be specified by using the + syntax:
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 19
Tables must be written in the following order: tableObject, entryObject, column1, ..., columnN (in
order).
Integer values, for example in the SIZE expression must be entered in decimal syntax, not in hex or bit syntax.
Symbolic names must be unique within a MIB and within a system.
Hyphens are allowed in SMIv2 (a pragmatic approach). The reason for this is that according to SMIv2, hyphens
are allowed for objects converted from SMIv1, but not for others. This is impossible to check for the compiler.
If a word is a keyword in any of SMIv1 or SMIv2, it is a keyword in the compiler (deviates from SMIv1 only).
Indexes in a table must be objects, not types (deviates from SMIv1 only).
A subset of all semantic checks on types are implemented. For example, strictly the TimeTicks may not be subclassed but the compiler allows this (standard MIBs must pass through the compiler) (deviates from SMIv2 only).
The MIB.Object syntax is not implemented (since all objects must be unique anyway).
Two different names cannot define the same OBJECT IDENTIFIER.
The type checking in the SEQUENCE construct is non-strict (i.e. subtypes may be specified). The reason for this
is that some standard MIBs use this.
A definition has normally a status field. When the status field has the value deprecated, then the MIB-compiler
will ignore this definition. With the MIB-compiler option {deprecated,true} the MIB-compiler does not
ignore the deprecated definitions.
An object has a DESCRIPTIONS field. The descriptions-field will not be included in the compiled mib by
default. In order to get the description, the mib must be compiled with the option description.
Refer also to the chapter(s) Definition of Agent Configuration Files and Definition of Manager Configuration Files
which contains more detailed information about the agent and manager configuration files.
the configuration directory stores all configuration files used by the agent (refer to the chapter Definition of Agent
Configuration Files for more information).
the database directory stores the internal database files.
The following directory must exist in the system to run the manager:
the configuration directory stores all configuration files used by the manager (refer to the chapter Definition of
Manager Configuration Files for more information).
the database directory stores the internal database files.
20 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
The agent and manager uses (application) configuration parameters to find out where these directories are located.
The parameters should be defined in an Erlang system configuration file. The following configuration parameters are
defined for the SNMP application:
agent_options() = [agent_option()]
agent_option() = {restart_type,
restart_type()}
|
{agent_type,
agent_type()}
|
{agent_verbosity, verbosity()}
|
{versions,
versions()}
|
{discovery,
agent_discovery()} |
{gb_max_vbs,
gb_max_vbs()}
|
{priority,
priority()}
|
{multi_threaded,
multi_threaded()}
|
{db_dir,
db_dir()}
|
{db_init_error,
db_init_error()}
|
{local_db,
local_db()}
|
{net_if,
agent_net_if()}
|
{mibs,
mibs()}
|
{mib_storage,
mib_storage()}
|
{mib_server,
mib_server()}
|
{audit_trail_log, audit_trail_log()} |
{error_report_mod, error_report_mod()} |
{note_store,
note_store()}
|
{symbolic_store,
symbolic_store()}
|
{target_cache,
target_cache()}
|
{config,
agent_config()}
manager_options() = [manager_option()]
manager_option() = {restart_type,
restart_type()}
{net_if,
manager_net_if()}
{server,
server()}
{note_store,
note_store()}
{config,
manager_config()}
{inform_request_behaviour, manager_irb()}
{mibs,
manager_mibs()}
{priority,
priority()}
{audit_trail_log,
audit_trail_log()}
{versions,
versions()}
{def_user_mod,
def_user_module()
{def_user_data,
def_user_data()}
|
|
|
|
|
|
|
|
|
|
|
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 21
agent_terminating_discovery_opts() = [agent_terminating_discovery_opt()]
<optional>
agent_terminating_discovery_opt() = {enable, boolean()} | {stage2, discovery
| plain} | {trigger_username, string()}
These are options effecting discovery terminating in this agent (i.e. initiated by a manager).
The default values for the terminating discovery options are:
enable: true
stage2: discovery
trigger_username: ""
agent_originating_discovery_opts() = [agent_originating_discovery_opt()]
<optional>
agent_originating_discovery_opt() = {enable, boolean()}
These are options effecting discovery originating in this agent.
The default values for the originating discovery options are:
enable: true
multi_threaded() = bool() <optional>
If true, the agent is multi-threaded, with one thread for each get request.
Default is false.
db_dir() = string() <mandatory>
Defines where the SNMP agent internal db files are stored.
gb_max_vbs() = pos_integer() | infinity <optional>
Defines the maximum number of varbinds allowed in a Get-BULK response.
Default is 1000.
local_db() = [local_db_opt()] <optional>
local_db_opt() = {repair, agent_repair()} | {auto_save, agent_auto_save()}
| {verbosity, verbosity()}
Defines options specific for the SNMP agent local database.
For defaults see the options in local_db_opt().
agent_repair() = false | true | force <optional>
When starting snmpa_local_db it always tries to open an existing database. If false, and some errors occur, a
new database is created instead. If true, an existing file will be repaired. If force, the table will be repaired
even if it was properly closed.
Default is true.
agent_auto_save() = integer() | infinity <optional>
The auto save interval. The table is flushed to disk whenever not accessed for this amount of time.
Default is 5000.
agent_net_if() = [agent_net_if_opt()] <optional>
agent_net_if_option() = {module, agent_net_if_module()}
verbosity()} | {options, agent_net_if_options()}
22 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
{verbosity,
Defines options specific for the SNMP agent network interface entity.
For defaults see the options in agent_net_if_opt().
agent_net_if_module() = atom() <optional>
Module which handles the network interface part for the SNMP agent. Must implement the
snmpa_network_interface behaviour.
Default is snmpa_net_if.
agent_net_if_options() = [agent_net_if_option()] <optional>
agent_net_if_option() = {bind_to, bind_to()} | {sndbuf, sndbuf()} | {recbuf,
recbuf()} | {no_reuse, no_reuse()} | {req_limit, req_limit()} | {filter,
agent_net_if_filter_options()}
These options are actually specific to the used module. The ones shown here are applicable to the default
agent_net_if_module().
For defaults see the options in agent_net_if_option().
req_limit() = integer() | infinity <optional>
Max number of simultaneous requests handled by the agent.
Default is infinity.
agent_net_if_filter_options() = [agent_net_if_filter_option()] <optional>
agent_net_if_filter_option() = {module, agent_net_if_filter_module()}
These options are actually specific to the used module. The ones shown here are applicable to the default
agent_net_if_filter_module().
For defaults see the options in agent_net_if_filter_option().
agent_net_if_filter_module() = atom() <optional>
Module which handles the network interface filter part for the SNMP agent. Must implement the
snmpa_network_interface_filter behaviour.
Default is snmpa_net_if_filter.
agent_mibs() = [string()] <optional>
Specifies a list of MIBs (including path) that defines which MIBs are initially loaded into the SNMP master agent.
Note that the following will always be loaded:
Default is [].
mib_storage() = [mib_storage_opt()] <optional>
mib_storage_opt()
=
mib_storage_options()}
{module,
mib_storage_module()}
{options,
This option specifies how basic mib data is stored. This option is used by two parts of the snmp agent: The mibserver and the symbolic-store.
Default is [{module, snmpa_mib_storage_ets}].
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 23
snmpa_mib_storage_ets,
snmpa_mib_storage_ets: {dir,
{checksum, boolean()}
filename()}
{action,
keep
clear},
dir - If present, points to a directory where a file to which all data in the ets table is "synced".
Also, when a table is opened this file is read, if it exists.
Default is keep.
checksum - Defines if the file is checksummed or not.
Default is false.
snmpa_mib_storage_dets: {dir, filename()} | {action, keep | clear},
{auto_save, default | pos_integer()} | {repair, force | boolean()}
dir - This mandatory option points to a directory where to place the file of a dets table.
action - Specifies the behaviour when a non-empty file is found: Keep its content or clear it out.
Default is keep.
auto_save - Defines the dets auto-save frequency.
Default is default.
repair - Defines the dets repair behaviour.
Default is false.
snmpa_mib_storage_mnesia: {action, keep | clear}, {nodes, [node()]}
action - Specifies the behaviour when a non-empty, already existing, table: Keep its content or clear
it out.
Default is keep.
nodes - A list of node names (or an atom describing a list of nodes) defining where to open the table.
Its up to the user to ensure that mnesia is actually running on the specified nodes.
The following distinct values are recognised:
24 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
|
|
{gclimit,
Defines options specific for the SNMP agent mib server cache.
For defaults see the options in mibs_cache_opt().
mibs_cache_autogc() = bool() <optional>
Defines if the mib server shall perform cache gc automatically or leave it to the user (see gc_mibs_cache/0,1,2,3).
Default is true.
mibs_cache_age() = integer() > 0 <optional>
Defines how old the entries in the cache will be allowed to become before they are GC'ed (assuming GC is
performed). Each entry in the cache is "touched" whenever it is accessed.
The age is defined in milliseconds.
Default is 10 timutes.
mibs_cache_gclimit() = integer() > 0 | infinity <optional>
When performing a GC, this is the max number of cache entries that will be deleted from the cache.
The reason for having this limit is that if the cache is large, the GC can potentially take a long time, during which
the agent is locked.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 25
Default is 100.
error_report_mod() = atom() <optional>
Defines an error report module, implementing the snmpa_error_report behaviour. Two modules are provided
with the toolkit: snmpa_error_logger and snmpa_error_io.
Default is snmpa_error_logger.
symbolic_store() = [symbolic_store_opt()]
symbolic_store_opt() = {verbosity, verbosity()}
Defines options specific for the SNMP agent symbolic store.
For defaults see the options in symbolic_store_opt().
target_cache() = [target_cache_opt()]
target_cache_opt() = {verbosity, verbosity()}
Defines options specific for the SNMP agent target cache.
For defaults see the options in target_cache_opt().
agent_config() = [agent_config_opt()] <mandatory>
agent_config_opt() = {dir, agent_config_dir()} | {force_load, force_load()}
| {verbosity, verbosity()}
Defines specific config related options for the SNMP agent.
For defaults see the options in agent_config_opt().
agent_config_dir = dir() <mandatory>
Defines where the SNMP agent configuration files are stored.
force_load() = bool() <optional>
If true the configuration files are re-read during start-up, and the contents of the configuration database ignored.
Thus, if true, changes to the configuration database are lost upon reboot of the agent.
Default is false.
Manager specific config options and types:
server() = [server_opt()] <optional>
server_opt() = {timeout, server_timeout()} | {verbosity, verbosity()}
Specifies the options for the manager server process.
Default is silence.
server_timeout() = integer() <optional>
Asynchroneous request cleanup time. For every requests, some info is stored internally, in order to be able to
deliver the reply (when it arrives) to the proper destination. If the reply arrives, this info will be deleted. But if
there is no reply (in time), the info has to be deleted after the best before time has been passed. This cleanup will
be performed at regular intervals, defined by the server_timeout() time. The information will have a best
before time, defined by the Expire time given when calling the request function (see async_get, async_get_next
and async_set).
Time in milli-seconds.
Default is 30000.
26 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
=
{dir,
manager_config_dir()}
|
{db_dir,
{db_init_error,
db_init_error()}
|
{repair,
{auto_save,
manager_auto_save()}
|
{verbosity,
auto - The manager will autonomously send response (acknowledgment> to inform-request messages.
{user, integer()} - The manager will send response (acknowledgment) to inform-request messages
when the handle_inform function completes. The integer is the time, in milli-seconds, that the manager will
consider the stored inform-request info valid.
user - Same as {user, integer()}, except that the default time, 15000 milli-seconds, is used.
See snmpm_network_interface, handle_inform and definition of the manager net if for more info.
Default is auto.
manager_mibs() = [string()] <optional>
Specifies a list of MIBs (including path) and defines which MIBs are initially loaded into the SNMP manager.
Default is [].
manager_net_if() = [manager_net_if_opt()] <optional>
manager_net_if_opt() = {module, manager_net_if_module()}
verbosity()} | {options, manager_net_if_options()}
{verbosity,
Defines options specific for the SNMP manager network interface entity.
For defaults see the options in manager_net_if_opt().
manager_net_if_options() = [manager_net_if_option()] <optional>
manager_net_if_option() = {bind_to, bind_to()} | {sndbuf,
|
{recbuf,
recbuf()}
|
{no_reuse,
no_reuse()}
|
manager_net_if_filter_options()}
sndbuf()}
{filter,
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 27
These options are actually specific to the used module. The ones shown here are applicable to the default
manager_net_if_module().
For defaults see the options in manager_net_if_option().
manager_net_if_module() = atom() <optional>
The module which handles the network interface part for the SNMP manager. It must implement the
snmpm_network_interface behaviour.
Default is snmpm_net_if.
manager_net_if_filter_options() = [manager_net_if_filter_option()] <optional>
manager_net_if_filter_option() = {module, manager_net_if_filter_module()}
These options are actually specific to the used module. The ones shown here are applicable to the default
manager_net_if_filter_module().
For defaults see the options in manager_net_if_filter_option().
manager_net_if_filter_module() = atom() <optional>
Module which handles the network interface filter part for the SNMP manager. Must implement the
snmpm_network_interface_filter behaviour.
Default is snmpm_net_if_filter.
def_user_module() = atom() <optional>
The module implementing the default user. See the snmpm_user behaviour.
Default is snmpm_user_default.
def_user_data() = term() <optional>
Data for the default user. Passed to the user when calling the callback functions.
Default is undefined.
Common config types:
restart_type() = permanent | transient | temporary
See supervisor documentation for more info.
Default is permanent for the agent and transient for the manager.
db_init_error() = terminate | create | create_db_and_dir
Defines what to do if the agent is unable to open an existing database file. terminate means that the agent/
manager will terminate, create means that the agent/manager will remove the faulty file(s) and create new
ones, and create_db_and_dir means that the agent/manager will create the database file along with any
missing parent directories for the database file.
Default is terminate.
priority() = atom() <optional>
Defines the Erlang priority for all SNMP processes.
Default is normal.
versions() = [version()] <optional>
version() = v1 | v2 | v3
Which SNMP versions shall be accepted/used.
Default is [v1,v2,v3].
28 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
{timeout,
note_store_timeout()}
{verbosity,
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 29
Default is read_write.
atl_dir = dir() <mandatory>
Specifies where the audit trail log should be stored.
If audit_trail_log specifies that logging should take place, this parameter must be defined.
atl_size() = {integer(), integer()} <mandatory>
Specifies the size of the audit trail log. This parameter is sent to disk_log.
If audit_trail_log specifies that logging should take place, this parameter must be defined.
atl_repair() = true | false | truncate | snmp_repair <optional>
Specifies if and how the audit trail log shall be repaired when opened. Unless this parameter has the value
snmp_repair it is sent to disk_log. If, on the other hand, the value is snmp_repair, snmp attempts to
handle certain faults on its own. And even if it cannot repair the file, it does not truncate it directly, but instead
moves it aside for later off-line analysis.
Default is true.
atl_seqno() = true | false <optional>
Specifies if the audit trail log entries will be (sequence) numbered or not. The range of the sequence numbers are
according to RFC 5424, i.e. 1 through 2147483647.
Default is false.
1> snmp:config().
Simple SNMP configuration tool (version 4.0)
-----------------------------------------------Note: Non-trivial configurations still has to be
done manually. IP addresses may be entered
as dront.ericsson.se (UNIX only) or
123.12.13.23
-----------------------------------------------Configure an agent (y/n)? [y]
Agent system config:
-------------------1. Agent process priority (low/normal/high) [normal]
2. What SNMP version(s) should be used (1,2,3,1&2,1&2&3,2&3)? [3] 1&2&3
3. Configuration directory (absolute path)? [/ldisk/snmp] /ldisk/snmp/agent/conf
4. Config verbosity (silence/info/log/debug/trace)? [silence]
5. Database directory (absolute path)? [/ldisk/snmp] /ldisk/snmp/agent/db
6. Mib storage type (ets/dets/mnesia)? [ets]
7. Target cache verbosity (silence/info/log/debug/trace)? [silence]
8. Symbolic store verbosity (silence/info/log/debug/trace)? [silence]
9. Local DB verbosity (silence/info/log/debug/trace)? [silence]
30 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
10.
11.
12.
13.
14.
15.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 31
32 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
If authentication or encryption is used (SNMPv3 only), start the crypto application. If this step is forgotten, the
agent will not start, but report a {config_error,{unsupported_crypto,_}} error.
1> application:start(crypto).
ok
2> application:start(snmp).
ok
3>
ok
5>
ok
6>
%%
**
snmpa:verbosity(master_agent, log).
snmpa:verbosity(net_if, log).
Example of output from the agent when a get-next-request arrives:
SNMP NET-IF LOG:
got packet from {147,12,12,12}:5000
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 33
34 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
The directory where the configuration files are found is given as a parameter to the agent.
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.
Syntax errors in these files are discovered and reported with the function config_err/2 of the error report module
at start-up.
{intAgentUDPPort, 4000}.
{intAgentTransports,
[{transportDomainUdpIpv4, {141,213,11,24}},
{transportDomainUdpIpv6, {0,0,0,0,0,0,0,1}}]}.
{snmpEngineID, "mbj's engine"}.
{snmpEngineMaxPacketSize, 484}.
The value of intAgentTransports is a list of {Domain, Addr} tuples, where Domain is either
transportDomainUdpIpv4 or transportDomainUdpIpv6, and Addr is the address in the domain. Addr
can be specified either as an IpAddr or as an {IpAddr, IpPort} tuple. IpAddr is either a regular Erlang/OTP
ip_address() or a traditional SNMP integer list and IpPort is an integer.
When the Addr value does not contain a port number, the value of intAgentUDPPort is used.
The legacy and intermediate variables intAgentIpAddress and intAgentTransportDomain are still
supported so old agent.conf files will work.
The value of snmpEngineID is a string, which for a deployed agent should have a very specific structure. See RFC
2271/2571 for details.
1.6.2 Contexts
The context information should be stored in a file called context.conf. The default context "" need not be present.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 35
Each row defines a context in the agent. This information is used in the table vacmContextTable in the SNMPVIEW-BASED-ACM-MIB.
Each entry is a term:
ContextName.
ContextName is a string.
A value must be provided for all variables, which lack default values in the MIB.
1.6.4 Communities
The community information should be stored in a file called community.conf. It must be present if the agent is
configured for SNMPv1 or SNMPv2c.
An SNMP community is a relationship between an SNMP agent and a set of SNMP managers that defines
authentication, access control and proxy characteristics.
The corresponding table is snmpCommunityTable in the SNMP-COMMUNITY-MIB.
Each entry is a term:
{CommunityIndex, CommunityName, SecurityName, ContextName, TransportTag}.
vacmAccessTable
Each entry is one of the terms, one entry corresponds to one row in one of the tables.
36 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
and
OwnAuthKeyC,
PrivP,
EngineID is a string.
UserName is a string.
SecName is a string.
Clone is zeroDotZero or a list of integers.
AuthP is a usmNoAuthProtocol, usmHMACMD5AuthProtocol, or usmHMACSHAAuthProtocol.
AuthKeyC is a string.
OwnAuthKeyC is a string.
PrivP is a usmNoPrivProtocol, usmDESPrivProtocol or usmAesCfb128Protocol.
PrivKeyC is a string.
OwnPrivKeyC is a string.
Public is a string.
AuthKey is a list (of integer). This is the User's secret localized authentication key. It is not visible in
the MIB. The length of this key needs to be 16 if usmHMACMD5AuthProtocol is used, and 20 if
usmHMACSHAAuthProtocol is used.
PrivKey is 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 if usmDESPrivProtocol or usmAesCfb128Protocol is used.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 37
in
the
SNMP-TARGET-MIB
and
The old tuple formats with Ip address and Udp port number found in old configurations still work.
Note that if EngineId has the value discovery, the agent cannot send inform messages to that manager until
it has performed the discovery process with that manager.
38 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
transports - which defines the transport domains and their addresses for the manager. Mandatory
Value is a list of {Domain, Addr} tuples or Domain atoms.
When a Addr is not specified i.e by using only a Domain atom, the host's name is resolved to find the
IP address, and the value of port is used.
port - which defines which UDP port the manager uses for communicating with agents. Mandatory if
transports does not define a port number for every transport.
engine_id - The SnmpEngineID as defined in SNMP-FRAMEWORK-MIB. Mandatory.
max_message_size - The snmpEngineMaxMessageSize as defined in SNMP-FRAMEWORKMIB. Mandatory.
Value is 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,
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 39
The value of engine_id is a string, which should have a very specific structure. See RFC 2271/2571 for details.
1.7.2 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}.
1.7.3 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}.
UserId is the identity of the manager user responsible for this agent (term).
TargetName is a unique non-empty string.
Comm is the community string (string).
Domain is the transport domain, either transportDomainUdpIpv4 or transportDomainUdpIpv6.
Addr is the address in the transport domain, either an {IpAddr, IpPort} tuple or a traditional SNMP integer
list containing port number. IpAddr is either a regular Erlang/OTP ip_address() or a traditional SNMP
integer list not containing port number, and IpPort is an integer.
EngineID is the engine-id of the agent (string).
Timeout is re-transmission timeout (infinity | integer).
MaxMessageSize is the max message size for outgoing messages to this agent (integer).
Version is the version (v1 | v2 | v3).
SecModel is the security model (any | v1 | v2c | usm).
SecName is the security name (string).
SecLevel is security level (noAuthNoPriv | authNoPriv | authPriv).
Legacy configurations using tuples without Domain element, as well as with all TDomain, Ip and Port elements
still work.
40 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
EngineID is a string.
UserName is a string.
SecName is a string.
AuthP is a usmNoAuthProtocol, usmHMACMD5AuthProtocol or usmHMACSHAAuthProtocol.
AuthKey is a list (of integer). This is the User's secret localized authentication key. It is not visible
in the MIB. The length of this key needs to be 16 if usmHMACMD5AuthProtocol is used and 20 if
usmHMACSHAAuthProtocol is used.
PrivP is a usmNoPrivProtocol, usmDESPrivProtocol or usmAesCfb128Protocol.
PrivKey is 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 if usmDESPrivProtocol or usmAesCfb128Protocol is used.
1.8.1 MIB
The MIB used in this example is called EX1-MIB. It contains two objects, a variable with a name and a table with
friends.
example1
RowStatus
DisplayString
OBJECT-TYPE
;
FROM STANDARD-MIB
FROM RFC1213-MIB
FROM RFC-1212
myName OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
ACCESS read-write
STATUS mandatory
DESCRIPTION
"My own name"
::= { example1 1 }
friendsTable OBJECT-TYPE
SYNTAX SEQUENCE OF FriendsEntry
ACCESS not-accessible
STATUS mandatory
DESCRIPTION
"A list of friends."
::= { example1 4 }
friendsEntry OBJECT-TYPE
SYNTAX FriendsEntry
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 41
ACCESS not-accessible
STATUS mandatory
DESCRIPTION
""
INDEX
{ fIndex }
::= { friendsTable 1 }
FriendsEntry ::=
SEQUENCE {
fIndex
INTEGER,
fName
DisplayString,
fAddress
DisplayString,
fStatus
RowStatus
fIndex OBJECT-TYPE
SYNTAX INTEGER
ACCESS not-accessible
STATUS mandatory
DESCRIPTION
"number of friend"
::= { friendsEntry 1 }
END
fName OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
ACCESS read-write
STATUS mandatory
DESCRIPTION
"Name of friend"
::= { friendsEntry 2 }
fAddress OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
ACCESS read-write
STATUS mandatory
DESCRIPTION
"Address of friend"
::= { friendsEntry 3 }
fStatus OBJECT-TYPE
SYNTAX
RowStatus
ACCESS
read-write
STATUS
mandatory
DESCRIPTION
"The status of this conceptual row."
::= { friendsEntry 4 }
fTrap TRAP-TYPE
ENTERPRISE example1
VARIABLES
{ myName, fIndex }
DESCRIPTION
"This trap is sent when something happens to
the friend specified by fIndex."
::= 1
42 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
This MIB is now loaded into the agent, and a manager can ask questions. As an example of this, we start another
Erlang system and the simple Erlang manager in the toolkit:
1> snmp_test_mgr:start_link([{agent,"dront.ericsson.se"},{community,"all-rights"},
%% making it understand symbolic names: {mibs,["EX1-MIB","STANDARD-MIB"]}]).
{ok, <0.89.0>}
%% a get-next request with one OID.
2> snmp_test_mgr:gn([[1,3,6,1,3,7]]).
ok
* Got PDU:
[myName,0] = []
%% A set-request (now using symbolic names for convenience)
3> snmp_test_mgr:s([{[myName,0], "Martin"}]).
ok
* Got PDU:
[myName,0] = "Martin"
%% Try the same get-next request again
4> snmp_test_mgr:gn([[1,3,6,1,3,7]]).
ok
* Got PDU:
[myName,0] = "Martin"
%% ... and we got the new value.
%% you can event do row operations. How to add a row:
5> snmp_test_mgr:s([{[fName,0], "Martin"}, {[fAddress,0],"home"}, {[fStatus,0],4}]).
%% createAndGo
ok
* Got PDU:
[fName,0] = "Martin"
[fAddress,0] = "home"
[fStatus,0] = 4
6> snmp_test_mgr:gn([[myName,0]]).
ok
* Got PDU:
[fName,0] = "Martin"
7> snmp_test_mgr:gn().
ok
* Got PDU:
[fAddress,0] = "home"
8> snmp_test_mgr:gn().
ok
* Got PDU:
[fStatus,0] = 1
9>
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 43
Note:
There are more efficient ways to create tables manually, i.e. to use the module snmp_index.
Code
-module(ex1).
-author('[email protected]').
%% External exports
-export([start/0, my_name/1, my_name/2, friends_table/3]).
%% Internal exports
-export([init/0]).
-define(status_col, 4).
-define(active, 1).
-define(notInService, 2).
-define(notReady, 3).
-define(createAndGo, 4).
% Action; written, not read
-define(createAndWait, 5). % Action; written, not read
-define(destroy, 6).
% Action; written, not read
start() ->
spawn(ex1, init, []).
%%---------------------------------------------------------------%% Instrumentation function for variable myName.
%% Returns: (get) {value, Name}
%%
(set) noError
%%---------------------------------------------------------------my_name(get) ->
ex1_server ! {self(), get_my_name},
Name = wait_answer(),
{value, Name}.
my_name(set, NewName) ->
ex1_server ! {self(), {set_my_name, NewName}},
noError.
%%---------------------------------------------------------------%% Instrumentation function for table friendsTable.
%%---------------------------------------------------------------friends_table(get, RowIndex, Cols) ->
case get_row(RowIndex) of
{ok, Row} ->
get_cols(Cols, Row);
_ ->
{noValue, noSuchInstance}
end;
friends_table(get_next, RowIndex, Cols) ->
case get_next_row(RowIndex) of
{ok, Row} ->
get_next_cols(Cols, Row);
_ ->
case get_next_row([]) of
{ok, Row} ->
% Get next cols from first row.
NewCols = add_one_to_cols(Cols),
get_next_cols(NewCols, Row);
44 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
->
end_of_table(Cols)
end
end;
%%---------------------------------------------------------------%% If RowStatus is set, then:
%%
*) If set to destroy, check that row does exist
%%
*) If set to createAndGo, check that row does not exist AND
%%
that all columns are given values.
%%
*) Otherwise, error (for simplicity).
%% Otherwise, row is modified; check that row exists.
%%---------------------------------------------------------------friends_table(is_set_ok, RowIndex, Cols) ->
RowExists =
case get_row(RowIndex) of
{ok, _Row} -> true;
_ -> false
end,
case is_row_status_col_changed(Cols) of
{true, ?destroy} when RowExists == true ->
{noError, 0};
{true, ?createAndGo} when RowExists == false,
length(Cols) == 3 ->
{noError, 0};
{true, _} ->
{inconsistentValue, ?status_col};
false when RowExists == true ->
{noError, 0};
_ ->
[{Col, _NewVal} | _Cols] = Cols,
{inconsistentName, Col}
end;
friends_table(set, RowIndex, Cols) ->
case is_row_status_col_changed(Cols) of
{true, ?destroy} ->
ex1_server ! {self(), {delete_row, RowIndex}};
{true, ?createAndGo} ->
NewRow = make_row(RowIndex, Cols),
ex1_server ! {self(), {add_row, NewRow}};
false ->
{ok, Row} = get_row(RowIndex),
NewRow = merge_rows(Row, Cols),
ex1_server ! {self(), {delete_row, RowIndex}},
ex1_server ! {self(), {add_row, NewRow}}
end,
{noError, 0}.
%%---------------------------------------------------------------%% Make a list of {value, Val} of the Row and Cols list.
%%---------------------------------------------------------------get_cols([Col | Cols], Row) ->
[{value, element(Col, Row)} | get_cols(Cols, Row)];
get_cols([], _Row) ->
[].
%%---------------------------------------------------------------%% As get_cols, but the Cols list may contain invalid column
%% numbers. If it does, we must find the next valid column,
%% or return endOfTable.
%%---------------------------------------------------------------get_next_cols([Col | Cols], Row) when Col < 2 ->
[{[2, element(1, Row)], element(2, Row)} |
get_next_cols(Cols, Row)];
get_next_cols([Col | Cols], Row) when Col > 4 ->
[endOfTable |
get_next_cols(Cols, Row)];
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 45
46 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
Association File
The association file EX1-MIB.funcs for the real implementation looks as follows:
Transcript
To use the real implementation, we must recompile the MIB and load it into the agent.
1> application:start(snmp).
ok
2> snmpc:compile("EX1-MIB").
{ok,"EX1-MIB.bin"}
3> snmpa:load_mibs(snmp_master_agent, ["EX1-MIB"]).
ok
4> ex1:start().
<0.115.0>
%% Now all requests operates on this "real" implementation.
%% The output from the manager requests will *look* exactly the
%% same as for the default implementation.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 47
Trap Sending
How to send a trap by sending the fTrap from the master agent is shown in this section. The master agent has the
MIB EX1-MIB loaded, where the trap is defined. This trap specifies that two variables should be sent along with the
trap, myName and fIndex. fIndex is a table column, so we must provide its value and the index for the row in
the call to snmpa:send_trap/4. In the example below, we assume that the row in question is indexed by 2 (the
row with fIndex 2).
we use a simple Erlang SNMP manager, which can receive traps.
[MANAGER]
1> snmp_test_mgr:start_link([{agent,"dront.ericsson.se"},{community,"public"}
%% does not have write-access
1>{mibs,["EX1-MIB","STANDARD-MIB"]}]).
{ok, <0.100.0>}
2> snmp_test_mgr:s([{[myName,0], "Klas"}]).
ok
* Got PDU:
Received a trap:
Generic: 4
%% authenticationFailure
Enterprise: [iso,2,3]
Specific: 0
Agent addr: [123,12,12,21]
TimeStamp: 42993
2>
[AGENT]
3> snmpa:send_trap(snmp_master_agent, fTrap,"standard trap", [{fIndex,[2],2}]).
[MANAGER]
2>
* Got PDU:
Received a trap:
Generic: 6
Enterprise: [example1]
Specific: 1
Agent addr: [123,12,12,21]
TimeStamp: 69649
[myName,0] = "Martin"
[fIndex,2] = 2
2>
A simple example of how to use the manager component of the SNMP Development Toolkit.
A simple example of how to write agent test cases, using the new manager.
48 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
1.10Instrumentation Functions
start_link/0, start_link/1
stop/0
agent/2, agent/3
sync_get/2, sync_get/3
sync_get_next/2, sync_get_next/3
sync_get_bulk/4, sync_get_bulk/5
sync_set/2, sync_set/3
oid_to_name/1
This module is also used by the test module described in the next section.
using
the
1.10Instrumentation Functions
A user-defined instrumentation function for each object attaches the managed objects to real resources. This function is
called by the agent on a get or set operation. The function could read some hardware register, perform a calculation,
or whatever is necessary to implement the semantics associated with the conceptual variable. These functions must
be written both for scalar variables and for tables. They are specified in the association file, which is a text file. In
this file, the OBJECT IDENTIFIER, or symbolic name for each managed object, is associated with an Erlang tuple
{Module,Function, ListOfExtraArguments}.
When a managed object is referenced in an SNMP operation, the associated {Module, Function,
ListOfExtraArguments} is called. The function is applied to some standard arguments (for example, the
operation type) and the extra arguments supplied by the user.
Instrumentation functions must be written for get and set for scalar variables and tables, and for get-next for
tables only. The get-bulk operation is translated into a series of calls to get-next.
For tables:
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 49
1.10Instrumentation Functions
These functions are called for each object in an MIB when the MIB is unloaded or loaded, respectively.
Get Operation
For scalar variables:
For tables:
Cols is a list of Column. The agent will sort incoming variables so that all operations on one row (same index) will
be supplied at the same time. The reason for this is that a database normally retrieves information row by row.
These functions must return the current values of the associated variables.
Set Operation
For scalar variables:
For tables:
Is-set-ok Operation
As a complement to the set operation, it is possible to specify a test function. This function has the same syntax as
the set operation above, except that the first argument is is_set_ok instead of set. This function is called before
the variable is set. Its purpose is to ensure that it is permissible to set the variable to the new value.
For tables:
50 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
1.10Instrumentation Functions
Undo Operation
A function which has been called with is_set_ok will be called again, either with set if there was no error, or
with undo, if an error occurred. In this way, resources can be reserved in the is_set_ok operation, released in the
undo operation, or made permanent in the set operation.
For tables:
GetNext Operation
The GetNext Operation operation should only be defined for tables since the agent can find the next instance of plain
variables in the MIB and call the instrumentation with the get operation.
Cols is a list of integers, all greater than or equal to zero. This indicates that the instrumentation should find the
next accessible instance. This function returns the tuple {NextOid, NextValue}, or endOfTable. NextOid
should be the lexicographically next accessible instance of a managed object in the table. It should be a list of integers,
where the first integer is the column, and the rest of the list is the indices for the next row. If endOfTable is returned,
the agent continues to search for the next instance among the other variables and tables.
RowIndex may be an empty list, an incompletely specified row index, or the index for an unspecified row.
This operation is best described with an example.
GetNext Example
A table called myTable has five columns. The first two are keys (not accessible), and the table has three rows. The
instrumentation function for this table is called my_table.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 51
1.10Instrumentation Functions
Note:
N/A means not accessible.
The manager issues the following getNext request:
getNext{ myTable.myTableEntry.3.1.1,
myTable.myTableEntry.5.1.1 }
Since both operations involve the 1.1 index, this is transformed into one call to my_table:
In this call, [1, 1] is the RowIndex, where key 1 has value 1, and key 2 has value 1, and [3, 5] is the list of
requested columns. The function should now return the lexicographically next elements:
52 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
1.10Instrumentation Functions
getNext{ myTable.myTableEntry.3.2.1,
myTable.myTableEntry.5.2.1 }
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 53
1.10Instrumentation Functions
getNext{ myTable.myTableEntry.3.1.2,
myTable.myTableEntry.4.1.2 }
getNext{ myTable.myTableEntry,
myTable.myTableEntry.1.3.2 }
54 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
1.10Instrumentation Functions
In both cases, the first accessible element in the table should be returned. As the key columns are not accessible, this
means that the third column is the first row.
Note:
Normally, the functions described above behave exactly as shown, but they are free to perform other actions.
For example, a get-request may have side effects such as setting some other variable, perhaps a global
lastAccessed variable.
The ExtraArgument parameter is the empty list. For example, when the agent receives a get-request for the ipAdr
variable, a call will be made to ip_access(get). The value returned by this function is the answer to the getrequest.
If ip_access and name_access are implemented similarly, we could write a generic_access function using
the ListOfExtraArguments:
When the agent receives the same get-request as above, a call will be made to generic_access(get, 'IPADR').
Yet another possibility, closer to the hardware, could be:
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 55
1.10Instrumentation Functions
Implementing an MIB can be a tedious task. Most probably, there is a need to test the agent before all tables and
variables are implemented. In this case, the default instrumentation functions are useful. The toolkit can generate
default instrumentation functions for variables as well as for tables. Consequently, a running prototype agent, which
can handle set, get, get-next and table operations, is generated without any programming.
The agent stores the values in an internal volatile database, which is based on the standard module ets. However,
it is possible to let the MIB compiler generate functions which use an internal, persistent database, or the Mnesia
DBMS. Refer to the Mnesia User Guide and the Reference Manual, section SNMP, module snmp_generic for
more information.
When parts of the MIB are implemented, you recompile it and continue on by using default functions. With this
approach, the SNMP agent can be developed incrementally.
The default instrumentation allows the application on the manager side to be developed and tested simultaneously
with the agent. As soon as the ASN.1 file is completed, let the MIB compiler generate a default implementation and
develop the management application from this.
Table Operations
The generation of default functions for tables works for tables which use the RowStatus textual convention from
SNMPv2, defined in STANDARD-MIB and SNMPv2-TC.
Note:
We strongly encourage the use of the RowStatus convention for every table that can be modified from the
manager, even for newly designed SNMPv1 MIBs. In SNMPv1, everybody has invented their own scheme for
emulating table operations, which has led to numerous inconsistencies. The convention in SNMPv2 is flexible
and powerful and has been tested successfully. If the table is read only, no RowStatus column should be used.
the type
the length
the range
the variable is writable and within the MIB view.
At the end of phase one, the user defined is_set_ok functions are called for each scalar variable, and for each
group of table operations.
If no error occurs, the second phase is performed. This phase calls the user defined set function for all variables.
If an error occurs, either in the is_set_ok phase, or in the set phase, all functions which were called with
is_set_ok but not set, are called with undo.
There are limitations with this transaction mechanism. If complex dependencies exist between variables, for example
between month and day, another mechanism is needed. Setting the date to 'Feb 31' can be avoided by a somewhat
more generic transaction mechanism. You can continue and find more and more complex situations and construct an
N-phase set-mechanism. This toolkit only contains a trivial mechanism.
56 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
The most common application of transaction mechanisms is to keep row operations together. Since our agent sorts
row operations, the mechanism implemented in combination with the RowStatus (particularly 'createAndWait' value)
solve most problems elegantly.
f(new [, ExtraArgs])
The function f(new [, ExtraArgs]) is called for each variable in the MIB when the MIB is loaded into the
agent. This makes it possible to perform necessary initialization.
This function is optional. The return value is discarded.
f(delete [, ExtraArgs])
The function f(delete [, ExtraArgs]) is called for each object in an MIB when the MIB is unloaded from
the agent. This makes it possible to perform necessary clean-up.
This function is optional. The return value is discarded.
f(get [, ExtraArgs])
The function f(get [, ExtraArgs]) is called when a get-request or a get-next request refers to the variable.
This function is mandatory.
Valid Return Values
{value, Value}. The Value must be of correct type, length and within ranges, otherwise genErr is
returned in the response PDU. If the object is an enumerated integer, the symbolic enum value may be used as
an atom. If the object is of type BITS, the return value shall be an integer or a list of bits that are set.
{noValue, noSuchName}(SNMPv1)
{noValue, noSuchObject | noSuchInstance} (SNMPv2)
genErr. Used if an error occurred. Note, this should be an internal processing error, e.g. a caused by a
programing fault somewhere. If the variable does not exist, use {noValue, noSuchName} or {noValue,
noSuchInstance}.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 57
If this function is called, it will be called again, either with undo or with set as first argument.
Valid return values
noError
badValue | noSuchName | genErr(SNMPv1)
noAccess | noCreation | inconsistentValue | resourceUnavailable |
inconsistentName | genErr(SNMPv2)
f(new [, ExtraArgs])
The function f(new [, ExtraArgs]) is called for each object in an MIB when the MIB is loaded into the agent.
This makes it possible to perform the necessary initialization.
This function is optional. The return value is discarded.
f(delete [, ExtraArgs])
The function f(delete [, ExtraArgs]) is called for each object in an MIB when the MIB is unloaded from
the agent. This makes it possible to perform any necessary clean-up.
58 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
{value, Value}. The Value must be of correct type, length and within ranges, otherwise genErr is
returned in the response PDU. If the object is an enumerated integer, the symbolic enum value may be used
(as an atom). If the object is of type BITS, the return value shall be an integer or a list of bits that are set.
{noValue, noSuchName}(SNMPv1)
{noValue, noSuchObject | noSuchInstance}(SNMPv2)
{noValue, Error}. If the row does not exist, because all columns have {noValue, Error}),
the single tuple {noValue, Error} can be returned. This is a shorthand for a list with all elements
{noValue, Error}.
genErr. Used if an error occurred. Note that this should be an internal processing error, e.g. a caused
by a programing fault somewhere. If some column does not exist, use {noValue, noSuchName} or
{noValue, noSuchInstance}.
{NextOid, NextValue}, where NextOid is the lexicographic next OBJECT IDENTIFIER for the
corresponding column. This should be specified as the OBJECT IDENTIFER part following the table
entry. This means that the first integer is the column number and the rest is a specification of the keys.
NextValue is the value of this element.
endOfTable if there are no accessible elements after this one.
{genErr, Column} where Column denotes the column that caused the error. Column must be one
of the columns in the Cols list. Note that this should be an internal processing error, e.g. a caused by a
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 59
programing fault somewhere. If some column does not exist, you must return the next accessible element (or
endOfTable).
60 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
or of type BITS, the integer value is used. The list is sorted by Column (increasing) and each Column is
guaranteed to be a valid column number.
Valid Return Values
{noError, 0}
{Error, Column} where Error is the same as set for variables, and Column denotes the faulty column.
Column must be one of the columns in the Cols list.
The Network Interface (Net if) process delivers SNMP PDUs to a master agent, and receives SNMP PDUs from the
master agent. The most common behaviour of a Net if process is that is receives bytes from a network, decodes them
into an SNMP PDU, which it sends to a master agent. When the master agent has processed the PDU, it sends a
response PDU to the Net if process, which encodes the PDU into bytes and transmits the bytes onto the network.
However, that simple behaviour can be modified in numerous ways. For example, the Net if process can apply some
kind of encrypting/decrypting scheme on the bytes or act as a proxy filter, which sends some packets to a proxy agent
and some packets to the master agent.
It is also possible to write your own Net if process. The default Net if process is implemented in the module
snmpa_net_if and it uses UDP as the transport protocol i.e the transport domains transportDomainUdpIpv4
and/or transportDomainUdpIpv6.
This section describes how to write a Net if process.
1.12.2 Messages
The section Messages describes mandatory messages, which Net if must send and be able to receive.
In this section an Address field is a {Domain, Addr} tuple where Domain is transportDomainUdpIpv4
or transportDomainUdpIpv4, and Addr is an {IpAddr, IpPort} tuple.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 61
Outgoing Messages
Net if must send the following message when it receives an SNMP PDU from the network that is aimed for the
MasterAgent:
The following message is used to report that a response to a request has been received. The only request an agent can
send is an Inform-Request.
Pid is the Process that waits for the response for the request. The Pid was specified in the send_pdu_req
message (see below).
Vsn is either 'version-1', 'version-2', or 'version-3'.
Pdu is the SNMP Pdu received
From is the source Address.
Incoming Messages
This section describes the incoming messages which a Net if process must be able to receive.
62 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
Notes
Since the Net if process is responsible for encoding and decoding of SNMP messages, it must also update the relevant
counters in the SNMP group in MIB-II. It can use the functions in the module snmpa_mpd for this purpose (refer to
the Reference Manual, section snmp, module snmpa_mpd for more details.)
There are also some useful functions for encoding and decoding of SNMP messages in the module snmp_pdus.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 63
The Network Interface (Net if) process delivers SNMP PDUs to the manager server, and receives SNMP PDUs from
the manager server. The most common behaviour of a Net if process is that is receives request PDU from the manager
server, encodes the PDU into bytes and transmits the bytes onto the network to an agent. When the reply from the
agent is received by the Net if process, which it decodes into an SNMP PDU, which it sends to the manager server.
However, that simple behaviour can be modified in numerous ways. For example, the Net if process can apply some
kind of encrypting/decrypting scheme on the bytes.
The snmp application provides two different modules, snmpm_net_if (the default) and snmpm_net_if_mt,
both uses UDP as the transport protocol i.e the transport domains transportDomainUdpIpv4 and/or
transportDomainUdpIpv6. The difference between the two modules is that the latter is "multi-threaded", i.e.
for each message/request a new process is created that processes the message/request and then exits.
It is also possible to write your own Net if process and this section describes how to do that.
1.13.2 Messages
The section Messages describes mandatory messages, which Net if must send to the manager server process.
In this section a Domain field is the transport domain i.e one of transportDomainUdpIpv4 or
transportDomainUdpIpv6, and an Addr field is an {IpAddr, IpPort} tuple.
Net if must send the following message when it receives an SNMP PDU from the network that is aimed for the
MasterAgent:
Pdu is an SNMP PDU record, as defined in snmp_types.hrl, with the SNMP request.
Domain is the source transport domain.
Addr is the source address.
Trap is either an SNMP pdu record or an trappdu record, as defined in snmp_types.hrl, with the SNMP
request.
Domain is the source transport domain.
Addr is the source address.
Ref is either the atom ignore or something that can be used to identify the inform-request (e.g. request-id).
ignore is used if the response (acknowledgment) to the inform-request has already been sent (this means that
the server will not make the call to the inform_response function). See the inform request behaviour configuration
option for more info.
64 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
Pdu is an SNMP PDU record, as defined in snmp_types.hrl, with the SNMP request.
Domain is the source transport domain.
Addr is the source address.
Data is either {ok, Pdu} or {error, ReqId, ReasonInfo, Pdu}. Which one is used depends on the
return value from the MPD process_msg function. If the MsgData is ok, the first is used, and if it is {error,
ReqId, Reason} the latter is used.
Pdu is an SNMP PDU record, as defined in snmp_types.hrl, with the SNMP request.
ReqId is an integer.
ReasonInfo is a term().
Domain is the source transport domain.
Addr is the source address.
Notes
Since the Net if process is responsible for encoding and decoding of SNMP messages, it must also update the relevant
counters in the SNMP group in MIB-II. It can use the functions in the module snmpm_mpd for this purpose (refer to
the Reference Manual, section snmp, module snmpm_mpd for more details).
There are also some useful functions for encoding and decoding of SNMP messages in the module snmp_pdus.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 65
Process Communication
A simple distributed agent can be managed without sub-agents. The instrumentation functions can use distributed
Erlang to communicate with other parts of the application. However, a sub-agent can be used on each node if this
generates too much unnecessary traffic. A sub-agent processes requests per incoming SNMP request, not per variable.
Therefore the network traffic is minimized.
If the instrumentation functions communicate with UNIX processes, it might be a good idea to use a special sub-agent.
This sub-agent sends the SNMP request to the other process in one packet in order to minimize context switches. For
example, if a whole MIB is implemented on the C level in UNIX, but you still want to use the Erlang SNMP tool, then
you may have one special sub-agent, which sends the variables in the request as a single operation down to C.
66 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
all set requests are serialized, which means that if the agent is waiting for the application to complete a complicated
write operation, it will not process any new write requests until this operation is finished. It processes read requests
and sends traps, concurrently. The reason for not handle write requests in parallel is that a complex locking mechanism
would be needed even in the simplest cases. Even with the scheme described above, the user must be careful not to
violate that the set requests are atoms. If this is hard to do, do not use the multi-threaded feature.
The order within an request is undefined and variables are not processed in a defined order. Do not assume that the
first variable in the PDU will be processed before the second, even if the agent processes variables in this order. It
cannot even be assumed that requests belonging to different sub-agents have any order.
If the manager tries to set the same variable many times in the same PDU, the agent is free to improvise. There is
no definition which determines if the instrumentation will be called once or twice. If called once only, there is no
definition that determines which of the new values is going to be supplied.
When the agent receives a request, it keeps the request ID for one second after the response is sent. If the agent receives
another request with the same request ID during this time, from the same IP address and UDP port, that request will
be discarded. This mechanism has nothing to do with the function snmpa:current_request_id/0.
We do not need a sub-agent for each table holder. Normally, the sub-agent is needed to take care of
communication, but in Distributed Erlang we use ordinary message passing.
Most likely, some type of table coordinator already exists. This process should take care of the instrumentation
for the table.
The method used to present a distributed table is strongly application dependent. The use of different masking
techniques is only valid for a small subset of problems and registering every row in a distributed table makes it
non-distributed.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 67
The agent is highly fault tolerant. If the manager gets an unexpected response from the agent, it is possible that some
instrumentation function has returned an erroneous value. The agent will not crash even if the instrumentation does.
It should be noted that if an instrumentation function enters an infinite loop, the agent will also be blocked forever.
The supervisor ,or the application, specifies how to restart the agent.
We get all features of Mnesia, such as fault tolerance, persistent data storage, replication, and so on.
Much of the work involved is automated. This includes get-next processing and RowStatus handling.
The table may be used as an ordinary Mnesia table, using the Mnesia API internally in the application at the
same time as it is visible through SNMP.
When this mapping is used, insertion and deletion in the original Mnesia table is slower, with a factor O(log n). The
read access is not affected.
A drawback with implementing an SNMP table as a Mnesia table is that the internal resource is forced to use the
table definition from the MIB, which means that the external data model must be used internally. Actually, this is only
partially true. The Mnesia table may extend the SNMP table, which means that the Mnesia table may have columns
which are use internally and are not seen by SNMP. Still, the data model from SNMP must be maintained. Although
this is undesirable, it is a pragmatic compromise in many situations where simple and efficient implementation is
preferable to abstraction.
68 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
The following example illustrates a situation in which we have an SNMP table that we wish to implement as a Mnesia
table. The table stores information about employees at a company. Each employee is indexed with the department
number and the name.
empTable OBJECT-TYPE
SYNTAX
SEQUENCE OF EmpEntry
ACCESS
not-accessible
STATUS
mandatory
DESCRIPTION
"A table with information about employees."
::= { emp 1}
empEntry OBJECT-TYPE
SYNTAX
EmpEntry
ACCESS
not-accessible
STATUS
mandatory
DESCRIPTION
""
INDEX
{ empDepNo, empName }
::= { empTable 1 }
EmpEntry ::=
SEQUENCE {
empDepNo
INTEGER,
empName
DisplayString,
empTelNo
DisplayString
empStatus
RowStatus
}
mnesia:create_table([{name, employees},
{snmp, [{key, {integer, string}}]},
{attributes, [key, telno, row_status]}]).
Note:
In the Mnesia tables, the two key columns are stored as a tuple with two elements. Therefore, the arity of the
table is 3.
Instrumentation Functions
The MIB table shown in the previous section can be compiled as follows:
This is all that has to be done! Now the manager can read, add, and modify rows. Also, you can use the ordinary
Mnesia API to access the table from your programs. The only explicit action is to create the Mnesia table, an action
the user has to perform in order to create the required table schemas.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 69
The default instrumentation functions are defined in the module snmp_generic. Refer to the Reference Manual,
section SNMP, module snmp_generic for details.
mnesia:create_table([{name, employees},
{snmp, [{key, {integer, string}}]},
{attributes, {key, telno, row_status, internal_col}}]).
The last column is the internal column. When performing a set operation, which creates a row, we must give a value
to the internal column. The instrumentation functions will now look as follows:
-define(createAndGo, 4).
-define(createAndWait, 5).
emp_table(set, RowIndex, Cols) ->
notify_internal_resources(RowIndex, Cols),
NewCols =
case is_row_created(empTable, Cols) of
true -> Cols ++ [{4, "internal"}]; % add internal column
false -> Cols
% keep original cols
end,
snmp_generic:table_func(set, RowIndex, NewCols, {empTable, mnesia});
emp_table(Op, RowIndex, Cols) ->
snmp_generic:table_func(Op, RowIndex, Cols, {empTable, mnesia}).
is_row_created(Name, Cols) ->
case snmp_generic:get_status_col(Name, Cols) of
{ok, ?createAndGo} -> true;
{ok, ?createAndWait} -> true;
_ -> false
end.
70 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
1.16SNMP Appendix A
The default functions and snmp_generic cannot handle an object of type NetworkAddress as INDEX
(SNMPv1 only!). Use IpAddress instead.
The agent does not check complex ranges specified for INTEGER objects. In these cases it just checks that
the value lies within the minimum and maximum values specified. For example, if the range is specified as
1..10 | 12..20 the agent would let 11 through, but not 0 or 21. The instrumentation functions must check
the complex ranges itself.
The agent will never generate the wrongEncoding error. If a variable binding is erroneous encoded, the
asn1ParseError counter will be incremented.
A tooBig error in an SNMPv1 packet will always use the 'NULL' value in all variable bindings.
The default functions and snmp_generic do not check the range of each OCTET in textual conventions
derived from OCTET STRING, e.g. DisplayString and DateAndTime. This must be checked in an
overloaded is_set_ok function.
1.16SNMP Appendix A
1.16.1 Appendix A
This appendix describes the conversion of SNMPv2 to SNMPv1 error messages. The instrumentation functions should
return v2 error messages.
Mapping of SNMPv2 error message to SNMPv1:
SNMPv2 message
SNMPv1 message
noError
noError
genErr
genErr
noAccess
noSuchName
wrongType
badValue
wrongLength
badValue
wrongEncoding
badValue
wrongValue
badValue
noCreation
noSuchName
inconsistentValue
badValue
resourceUnavailable
genErr
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 71
1.17SNMP Appendix B
commitFailed
genErr
undoFailed
genErr
notWritable
noSuchName
inconsistentName
noSuchName
1.17SNMP Appendix B
1.17.1 Appendix B
RowStatus (from RFC1903)
RowStatus ::= TEXTUAL-CONVENTION
STATUS
current
DESCRIPTION
"The RowStatus textual convention is used to manage the
creation and deletion of conceptual rows, and is used as the
value of the SYNTAX clause for the status column of a
conceptual row (as described in Section 7.7.1 in RFC1902.)
The status column has six defined values:
- `active', which indicates that the conceptual row is
available for use by the managed device;
- `notInService', which indicates that the conceptual
row exists in the agent, but is unavailable for use by
the managed device (see NOTE below);
- `notReady', which indicates that the conceptual row
exists in the agent, but is missing information
necessary in order to be available for use by the
managed device;
- `createAndGo', which is supplied by a management
station wishing to create a new instance of a
conceptual row and to have its status automatically set
to active, making it available for use by the managed
device;
- `createAndWait', which is supplied by a management
station wishing to create a new instance of a
conceptual row (but not make it available for use by
the managed device); and,
- `destroy', which is supplied by a management station
wishing to delete all of the instances associated with
an existing conceptual row.
Whereas five of the six values (all except `notReady') may
be specified in a management protocol set operation, only
three values will be returned in response to a management
protocol retrieval operation: `notReady', `notInService' or
`active'. That is, when queried, an existing conceptual row
72 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
1.17SNMP Appendix B
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 73
1.17SNMP Appendix B
notInService
|
|
|
|
|
|
or
|
|
or
|
|
|
|
|
|see 3
->C|
->C|wrongValue
--------------+--------------+-----------+-------------+------------set status
|noError
|noError
|noError
|noError
column to
|
|
|
|
destroy
|
->A|
->A|
->A|
->A
--------------+--------------+-----------+-------------+------------set any other |see 4
|noError
|noError
|see 5
column to some|
|
|
|
value
|
|
see 1|
->C|
->D
--------------+--------------+-----------+-------------+------------(1) goto B or C, depending on information available to the
agent.
(2) if other variable bindings included in the same PDU,
provide values for all columns which are missing but
required, then return noError and goto D.
(3) if other variable bindings included in the same PDU,
provide values for all columns which are missing but
required, then return noError and goto C.
(4) at the discretion of the agent, the return value may be
either:
inconsistentName: because the agent does not choose to
create such an instance when the corresponding
RowStatus instance does not exist, or
inconsistentValue: if the supplied value is
inconsistent with the state of some other MIB object's
value, or
noError: because the agent chooses to create the
instance.
If noError is returned, then the instance of the status
column must also be created, and the new state is B or C,
depending on the information available to the agent. If
inconsistentName or inconsistentValue is returned, the row
remains in state A.
(5) depending on the MIB definition for the column/table,
either noError or inconsistentValue may be returned.
NOTE: Other processing of the set request may result in a
response other than noError being returned, e.g.,
wrongValue, noCreation, etc.
Conceptual Row Creation
There are four potential interactions when creating a
conceptual row: selecting an instance-identifier which is
not in use; creating the conceptual row; initializing any
objects for which the agent does not supply a default; and,
making the conceptual row available for use by the managed
device.
Interaction 1: Selecting an Instance-Identifier
74 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
1.17SNMP Appendix B
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 75
1.17SNMP Appendix B
row.
We return to interaction 1.
76 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
1.17SNMP Appendix B
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 77
1.17SNMP Appendix B
78 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
1.17SNMP Appendix B
INTEGER {
-- the following two values are states:
-- these values may be read or written
active(1),
notInService(2),
-- the following value is a state:
-- this value may be read, but not written
notReady(3),
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 79
1.17SNMP Appendix B
2 Reference Manual
A multilingual Simple Network Management Protocol application featuring an Extensible Agent, simple manager, a
MIB compiler and facilities for implementing SNMP MIBs etc.
80 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmp
snmp
Erlang module
Exports
config() -> ok | {error, Reason}
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!
start() -> ok | {error, Reason}
start(Type) -> ok | {error, Reason}
Types:
Type = start_type()
Starts the SNMP application.
See application for more info.
start_agent() -> ok | {error, Reason}
start_agent(Type) -> ok | {error, Reason}
Types:
Type = start_type()
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.
start_manager() -> ok | {error, Reason}
start_manager(Type) -> ok | {error, Reason}
Types:
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 81
snmp
Type = start_type()
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.
date_and_time() -> DateAndTime
Types:
DateAndTime = [int()]
Returns current date and time as the data type DateAndTime, as specified in RFC1903. This is an OCTET STRING.
date_and_time_to_universal_time_dst(DateAndTime) -> [utc()]
Types:
DateAndTime = [int()]
utc() = {{Y,Mo,D},{H,M,S}}
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).
date_and_time_to_string(DateAndTime) -> string()
date_and_time_to_string(DateAndTime, Validate) -> string()
Types:
DateAndTime = [int()]
Validate = fun(Kind, Data) -> boolean()
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.
date_and_time_to_string2(DateAndTime) -> string()
Types:
DateAndTime = [int()]
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.
local_time_to_date_and_time_dst(Local) -> [DateAndTime]
Types:
Local = {{Y,Mo,D},{H,M,S}}
DateAndTime = [int()]
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).
82 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmp
Kind
-------------year
month
day
hour
minute
seconds
deci_seconds
diff
valid_date
Data
---------------------{Year1, Year2}
Month
Day
Hour
Minute
Seconds
DeciSeconds
[Sign, Hour, Minute]
{Year, Month, Day}
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 83
snmp
84 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmp
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.
log_to_io(LogDir, Mibs, LogName, LogFile) -> ok | {error, Reason}
log_to_io(LogDir, Mibs, LogName, LogFile, Block | Start) -> ok | {error,
Reason}
log_to_io(LogDir, Mibs, LogName, LogFile, Start, Block | Stop) -> ok |
{error, Reason}
log_to_io(LogDir, Mibs, LogName, LogFile, Start, Stop, Block) -> ok | {error,
Reason}
Types:
LogDir = string()
Mibs = [MibName]
MibName = string()
LogName = string()
LogFile = string()
Start = Stop = null | datetime() | {local_time,datetime()} |
{universal_time,datetime()}
Reason = term()
Converts an Audit Trail Log to a readable format and prints it on stdio. See log_to_txt above for more info.
change_log_size(LogName, NewSize) -> ok | {error, Reason}
Types:
LogName = string()
NewSize = {MaxBytes, MaxFiles}
MaxBytes = integer()
MaxFiles = integer()
Reason = term()
Changes the log size of the Audit Trail Log. The application must be configured to use the audit trail log function.
Please refer to disk_log(3) in Kernel Reference Manual for a description of how to change the log size.
The change is permanent, as long as the log is not deleted. That means, the log size is remembered across reboots.
print_version_info() -> void()
print_version_info(Prefix) -> void()
Types:
Prefix = string() | 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).
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 85
snmp
{ok, V} = snmp:versions1(),
snmp:print_versions(V).
86 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmp
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.
reset_trace(Targets) -> void()
Types:
Targets = module() | modules()
modules() = [module()]
module() = atom()
This function is used to reset (disable) trace for the given module(s).
set_trace(Targets, Opts) -> void()
Types:
Targets = target() | targets()
target() = module()
module() = atom()
targets() = [target() | {target(), target_options()}]
target_options() = [target_option()]
target_option() = {return_trace, boolean()} | {scope, scope()}
scope() = all_functions | exported_functions | function_name() |
{function_name(), function_arity()}
function_name() = atom()
function_arity() = integer() >= 0
Opts = disable | trace_options()
trace_options() = [trace_option()]
trace_option() = {timestamp, boolean()} | target_option()
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(),
See Also
calendar(3)
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 87
snmp
snmp
Application
This chapter describes the snmp application in OTP. The SNMP application provides the following services:
Configuration
The following configuration parameters are defined for the SNMP application. Refer to application(3) for more
information about configuration parameters.
The snmp part of the config file specifying the configuration parameters is basically the following tuple:
{snmp, snmp_components_config()}
A minimal config file for starting a node with both a manager and an agent:
[{snmp,
[{agent, [{db_dir, "/tmp/snmp/agent/db"},
{config, [{dir, "/tmp/snmp/agent/conf"}]}]},
{manager, [{config, [{dir, "/tmp/snmp/manager/conf"},
{db_dir, "/tmp/snmp/manager/db"}]}]}]}
]
}
].
Each snmp component has its own set of configuration parameters, even though some of the types are common to
both components.
88 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmp
{error_report_mod, error_report_mod()} |
{note_store,
note_store()}
|
{symbolic_store,
symbolic_store()}
|
{target_cache,
target_cache()}
|
{config,
agent_config()}
manager_options() = [manager_option()]
manager_option() = {restart_type,
restart_type()}
{net_if,
manager_net_if()}
{server,
server()}
{note_store,
note_store()}
{config,
manager_config()}
{inform_request_behaviour, manager_irb()}
{mibs,
manager_mibs()}
{priority,
priority()}
{audit_trail_log,
audit_trail_log()}
{versions,
versions()}
{def_user_mod,
def_user_module()
{def_user_data,
def_user_data()}
|
|
|
|
|
|
|
|
|
|
|
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 89
snmp
Default is false.
db_dir() = string() <mandatory>
Defines where the SNMP agent internal db files are stored.
gb_max_vbs() = pos_integer() | infinity <optional>
Defines the maximum number of varbinds allowed in a Get-BULK response.
Default is 1000.
local_db() = [local_db_opt()] <optional>
local_db_opt() = {repair, agent_repair()} | {auto_save, agent_auto_save()}
| {verbosity, verbosity()}
Defines options specific for the SNMP agent local database.
For defaults see the options in local_db_opt().
agent_repair() = false | true | force <optional>
When starting snmpa_local_db it always tries to open an existing database. If false, and some errors occur, a
new database is created instead. If true, an existing file will be repaired. If force, the table will be repaired
even if it was properly closed.
Default is true.
agent_auto_save() = integer() | infinity <optional>
The auto save interval. The table is flushed to disk whenever not accessed for this amount of time.
Default is 5000.
agent_net_if() = [agent_net_if_opt()] <optional>
agent_net_if_opt()
=
{module,
agent_net_if_module()}
verbosity()} | {options, agent_net_if_options()}
{verbosity,
Defines options specific for the SNMP agent network interface entity.
For defaults see the options in agent_net_if_opt().
agent_net_if_module() = atom() <optional>
Module which handles the network interface part for the SNMP agent. Must implement the
snmpa_network_interface behaviour.
Default is snmpa_net_if.
agent_net_if_options() = [agent_net_if_option()] <optional>
agent_net_if_option() = {bind_to, bind_to()} | {sndbuf, sndbuf()} | {recbuf,
recbuf()} | {no_reuse, no_reuse()} | {req_limit, req_limit()} | {filter,
agent_net_if_filter_options()}
These options are actually specific to the used module. The ones shown here are applicable to the default
agent_net_if_module().
For defaults see the options in agent_net_if_option().
req_limit() = integer() | infinity <optional>
Max number of simultaneous requests handled by the agent.
Default is infinity.
90 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmp
Default is [].
mib_storage() = [mib_storage_opt()] <optional>
mib_storage_opt()
=
mib_storage_options()}
{module,
mib_storage_module()}
{options,
This option specifies how basic mib data is stored. This option is used by two parts of the snmp agent: The mibserver and the symbolic-store.
Default is [{module, snmpa_mib_storage_ets}].
mib_storage_module() = snmpa_mib_data_ets | snmpa_mib_data_dets |
snmpa_mib_data_mnesia | module()
Defines the mib storage module of the SNMP agent as defined by the snmpa_mib_storage behaviour.
Several entities (mib-server via the its data module and the symbolic-store) of the snmp agent uses this
for storage of miscelaneous mib related data retrieved while loading a mib.
There are several implementations provided with the agent:
snmpa_mib_storage_dets and snmpa_mib_storage_mnesia.
snmpa_mib_storage_ets,
snmpa_mib_storage_ets: {dir,
{checksum, boolean()}
filename()}
{action,
keep
clear},
dir - If present, points to a directory where a file to which all data in the ets table is "synced".
Also, when a table is opened this file is read, if it exists.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 91
snmp
Default is false.
snmpa_mib_storage_dets: {dir, filename()} | {action, keep | clear},
{auto_save, default | pos_integer()} | {repair, force | boolean()}
dir - This mandatory option points to a directory where to place the file of a dets table.
action - Specifies the behaviour when a non-empty file is found: Keep its content or clear it out.
Default is keep.
auto_save - Defines the dets auto-save frequency.
Default is default.
repair - Defines the dets repair behaviour.
Default is false.
snmpa_mib_storage_mnesia: {action, keep | clear}, {nodes, [node()]}
action - Specifies the behaviour when a non-empty, already existing, table: Keep its content or clear
it out.
Default is keep.
nodes - A list of node names (or an atom describing a list of nodes) defining where to open the table.
Its up to the user to ensure that mnesia is actually running on the specified nodes.
The following distinct values are recognised:
|
|
92 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmp
At present only the default module is provided with the agent, snmpa_mib_data_tttn.
Default module is snmpa_mib_data_tttn.
mibs_cache() = bool() | mibs_cache_opts() <optional>
Shall the agent utilize the mib server lookup cache or not.
Default is true (in which case the mibs_cache_opts() default values apply).
mibs_cache_opts() = [mibs_cache_opt()] <optional>
mibs_cache_opt()
=
{autogc,
mibs_cache_autogc()}
mibs_cache_gclimit()} | {age, mibs_cache_age()}
{gclimit,
Defines options specific for the SNMP agent mib server cache.
For defaults see the options in mibs_cache_opt().
mibs_cache_autogc() = bool() <optional>
Defines if the mib server shall perform cache gc automatically or leave it to the user (see gc_mibs_cache/0,1,2,3).
Default is true.
mibs_cache_age() = integer() > 0 <optional>
Defines how old the entries in the cache will be allowed to become before they are GC'ed (assuming GC is
performed). Each entry in the cache is "touched" whenever it is accessed.
The age is defined in milliseconds.
Default is 10 timutes.
mibs_cache_gclimit() = integer() > 0 | infinity <optional>
When performing a GC, this is the max number of cache entries that will be deleted from the cache.
The reason for having this limit is that if the cache is large, the GC can potentially take a long time, during which
the agent is locked.
Default is 100.
error_report_mod() = atom() <optional>
Defines an error report module, implementing the snmpa_error_report behaviour. Two modules are provided
with the toolkit: snmpa_error_logger and snmpa_error_io.
Default is snmpa_error_logger.
symbolic_store() = [symbolic_store_opt()]
symbolic_store_opt() = {verbosity, verbosity()}
Defines options specific for the SNMP agent symbolic store.
For defaults see the options in symbolic_store_opt().
target_cache() = [target_cache_opt()]
target_cache_opt() = {verbosity, verbosity()}
Defines options specific for the SNMP agent target cache.
For defaults see the options in target_cache_opt().
agent_config() = [agent_config_opt()] <mandatory>
agent_config_opt() = {dir, agent_config_dir()} | {force_load, force_load()}
| {verbosity, verbosity()}
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 93
snmp
=
{dir,
manager_config_dir()}
|
{db_dir,
{db_init_error,
db_init_error()}
|
{repair,
{auto_save,
manager_auto_save()}
|
{verbosity,
94 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmp
auto - The manager will autonomously send response (acknowledgment> to inform-request messages.
{user, integer()} - The manager will send response (acknowledgment) to inform-request messages
when the handle_inform function completes. The integer is the time, in milli-seconds, that the manager will
consider the stored inform-request info valid.
user - Same as {user, integer()}, except that the default time, 15 seconds (15000), is used.
See snmpm_network_interface, handle_inform and definition of the manager net if for more info.
Default is auto.
manager_mibs() = [string()] <optional>
Specifies a list of MIBs (including path) and defines which MIBs are initially loaded into the SNMP manager.
Default is [].
manager_net_if() = [manager_net_if_opt()] <optional>
manager_net_if_opt() = {module, manager_net_if_module()}
verbosity()} | {options, manager_net_if_options()}
{verbosity,
Defines options specific for the SNMP manager network interface entity.
For defaults see the options in manager_net_if_opt().
manager_net_if_options() = [manager_net_if_option()] <optional>
manager_net_if_option() = {bind_to, bind_to()} | {sndbuf,
|
{recbuf,
recbuf()}
|
{no_reuse,
no_reuse()}
|
manager_net_if_filter_options()}
sndbuf()}
{filter,
These options are actually specific to the used module. The ones shown here are applicable to the default
manager_net_if_module().
For defaults see the options in manager_net_if_option().
manager_net_if_module() = atom() <optional>
The module which handles the network interface part for the SNMP manager. It must implement the
snmpm_network_interface behaviour.
Default is snmpm_net_if.
manager_net_if_filter_options() = [manager_net_if_filter_option()] <optional>
manager_net_if_filter_option() = {module, manager_net_if_filter_module()}
These options are actually specific to the used module. The ones shown here are applicable to the default
manager_net_if_filter_module().
For defaults see the options in manager_net_if_filter_option().
manager_net_if_filter_module() = atom() <optional>
Module which handles the network interface filter part for the SNMP manager. Must implement the
snmpm_network_interface_filter behaviour.
Default is snmpm_net_if_filter.
def_user_module() = atom() <optional>
The module implementing the default user. See the snmpm_user behaviour.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 95
snmp
Default is snmpm_user_default.
def_user_data() = term() <optional>
Data for the default user. Passed to the user module when calling the callback functions.
Default is undefined.
Common config types:
restart_type() = permanent | transient | temporary
See supervisor documentation for more info.
Default is permanent for the agent and transient for the manager.
db_init_error() = terminate | create | create_db_and_dir
Defines what to do if the agent or manager is unable to open an existing database file. terminate means that
the agent/manager will terminate and create means that the agent/manager will remove the faulty file(s) and
create new ones, and create_db_and_dir means that the agent/manager will create the database file along
with any missing parent directories for the database file.
Default is terminate.
priority() = atom() <optional>
Defines the Erlang priority for all SNMP processes.
Default is normal.
versions() = [version()] <optional>
version() = v1 | v2 | v3
Which SNMP versions shall be accepted/used.
Default is [v1,v2,v3].
verbosity() = silence | info | log | debug | trace <optional>
Verbosity for a SNMP process. This specifies now much debug info is printed.
Default is silence.
bind_to() = bool() <optional>
If true, net_if binds to the IP address. If false, net_if listens on any IP address on the host where it is running.
Default is false.
no_reuse() = bool() <optional>
If true, net_if does not specify that the IP and port address should be reusable. If false, the address is set
to reusable.
Default is false.
recbuf() = integer() <optional>
Receive buffer size.
Default value is defined by gen_udp.
sndbuf() = integer() <optional>
Send buffer size.
Default value is defined by gen_udp.
96 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmp
{timeout,
note_store_timeout()}
{verbosity,
Default is read_write.
atl_dir = dir() <mandatory>
Specifies where the audit trail log should be stored.
If audit_trail_log specifies that logging should take place, this parameter must be defined.
atl_size() = {integer(), integer()} <mandatory>
Specifies the size of the audit trail log. This parameter is sent to disk_log.
If audit_trail_log specifies that logging should take place, this parameter must be defined.
atl_repair() = true | false | truncate | snmp_repair <optional>
Specifies if and how the audit trail log shall be repaired when opened. Unless this parameter has the value
snmp_repair it is sent to disk_log. If, on the other hand, the value is snmp_repair, snmp attempts to
handle certain faults on its own. And even if it cannot repair the file, it does not truncate it directly, but instead
moves it aside for later off-line analysis.
Default is true.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 97
snmp
See Also
application(3), disk_log(3)
98 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpa
snmpa
Erlang module
DATA TYPES
oid() = [byte()]
atl_type() = read | write | read_write
notification_delivery_info() = #snmpa_notification_delivery_info{}
Exports
add_agent_caps(SysORID, SysORDescr) -> SysORIndex
Types:
SysORID = oid()
SysORDescr = string()
SysORIndex = integer()
This function can be used to add an AGENT-CAPABILITY statement to the sysORTable in the agent. The table is
defined in the SNMPv2-MIB.
del_agent_caps(SysORIndex) -> void()
Types:
SysORIndex = integer()
This function can be used to delete an AGENT-CAPABILITY statement to the sysORTable in the agent. This table
is defined in the SNMPv2-MIB.
get_agent_caps() -> [[SysORIndex, SysORID, SysORDescr, SysORUpTime]]
Types:
SysORIndex = integer()
SysORId = oid()
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 99
snmpa
SysORDescr = string()
SysORUpTime = integer()
Returns all AGENT-CAPABILITY statements in the sysORTable in the agent. This table is defined in the SNMPv2MIB.
get(Agent, Vars) -> Values | {error, Reason}
get(Agent, Vars, Context) -> Values | {error, Reason}
Types:
Agent = pid() | atom()
Vars = [oid()]
Context = string()
Values = [term()]
Reason = {atom(), oid()}
Performs a GET operation on the agent. All loaded MIB objects are visible in this operation. The agent calls the
corresponding instrumentation functions just as if it was a GET request coming from a manager.
Note that the request specific parameters (such as current_request_id) are not accessible for the instrumentation
functions if this function is used.
get_next(Agent, Vars) -> Values | {error, Reason}
get_next(Agent, Vars, Context) -> Values | {error, Reason}
Types:
Agent = pid() | atom()
Vars = [oid()]
Context = string()
Values = [{oid(), term()}]
Reason = {atom(), oid()}
Performs a GET-NEXT operation on the agent. All loaded MIB objects are visible in this operation. The agent calls
the corresponding instrumentation functions just as if it was a GET request coming from a manager.
Note that the request specific parameters (such as snmpa:current_request_id/0 are not accessible for the
instrumentation functions if this function is used.
backup(BackupDir) -> ok | {error, Reason}
backup(Agent, BackupDir) -> ok | {error, Reason}
Types:
BackupDir = string()
Agent = pid() | atom()
Reason = backup_in_progress | term()
Backup persistent/permanent data handled by the agent (such as local-db, mib-data and vacm).
Data stored by mnesia is not handled.
BackupDir cannot be identical to DbDir.
Simultaneous backup calls are not allowed. That is, two different processes cannot simultaneously successfully call this
function. One of them will be first, and succeed. The second will fail with the error reason backup_in_progress.
100 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpa
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 101
snmpa
If Force = true then the agent will continue attempting to load each mib even after failing to load a previous
mib. Use with care.
unload_mib(Mib) -> ok | {error, Reason}
unload_mib(Agent, Mib) -> ok | {error, Reason}
Types:
Agent = pid() | atom()
MibName = string()
Reason = not_loaded | term()
Unload a single Mib from an agent.
unload_mibs(Mibs) -> ok | {error, Reason}
unload_mibs(Mibs, Force) -> ok | {error, Reason}
unload_mibs(Agent, Mibs) -> ok | {error, Reason}
unload_mibs(Agent, Mibs, Force) -> ok | {error, Reason}
Types:
Agent = pid() | atom()
Mibs = [MibName]
Force = boolean()
MibName = string()
Reason = {'unload aborted at', MibName, InternalReason}
InternalReason = not_loaded | term()
Unload Mibs from an agent. If it cannot unload all MIBs (the default value of the Force argument is false), it
will indicate where unloading was aborted.
If Force = true then the agent will continue attempting to unload each mib even after failing to unload a previous
mib. Use with care.
which_mibs() -> Mibs
which_mibs(Agent) -> Mibs
Types:
Agent = pid() | atom()
Mibs = [{MibName, MibFile}]
MibName = atom()
MibFile = string()
Retrieve the list of all the mibs loaded into this agent. Default is the master agent.
whereis_mib(MibName) -> {ok, MibFile} | {error, Reason}
whereis_mib(Agent, MibName) -> {ok, MibFile} | {error, Reason}
Types:
Agent = pid() | atom()
102 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpa
MibName = atom()
MibFile = string()
Reason = term()
Get the full path to the (compiled) mib-file.
current_request_id() -> {value, RequestId} | false
current_context() -> {value, Context} | false
current_community() -> {value, Community} | false
current_address() -> {value, Address} | false
Types:
RequestId = integer()
Context = string()
Community = string()
Address = term()
Get the request-id, context, community and address of the request currently being processed by the agent.
Note that these functions is intended to be called by the instrumentation functions and only if they are executed in the
context of the agent process (e.g. it does not work if called from a spawned process).
enum_to_int(Name, Enum) -> {value, Int} | false
enum_to_int(Db, Name, Enum) -> {value, Int} | false
Types:
Db = term()
Name = atom()
Enum = atom()
Int = int()
Converts the symbolic value Enum to the corresponding integer of the enumerated object or type Name in a MIB.
The MIB must be loaded.
false is returned if the object or type is not defined in any loaded MIB, or if it does not define the symbolic value
as enumerated.
Db is a reference to the symbolic store database (retrieved by a call to get_symbolic_store_db/0).
int_to_enum(Name, Int) -> {value, Enum} | false
int_to_enum(Db, Name, Int) -> {value, Enum} | false
Types:
Db = term()
Name = atom()
Int = int()
Enum = atom()
Converts the integer Int to the corresponding symbolic value of the enumerated object or type Name in a MIB. The
MIB must be loaded.
false is returned if the object or type is not defined in any loaded MIB, or if it does not define the symbolic value
as enumerated.
Db is a reference to the symbolic store database (retrieved by a call to get_symbolic_store_db/0).
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 103
snmpa
104 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpa
log_to_txt(LogDir)
log_to_txt(LogDir, Block | Mibs)
log_to_txt(LogDir, Mibs, Block | OutFile) -> ok | {error, Reason}
log_to_txt(LogDir, Mibs, OutFile, Block | LogName) -> ok | {error, Reason}
log_to_txt(LogDir, Mibs, OutFile, LogName, Block | LogFile) -> ok | {error,
Reason}
log_to_txt(LogDir, Mibs, OutFile, LogName, LogFile, Block | Start) -> ok |
{error, Reason}
log_to_txt(LogDir, Mibs, OutFile, LogName, LogFile, Block, Start) -> ok |
{error, Reason}
log_to_txt(LogDir, Mibs, OutFile, LogName, LogFile, Start, Stop) -> ok |
{error, Reason}
log_to_txt(LogDir, Mibs, OutFile, LogName, LogFile, Block, Start, Stop) -> ok
| {error, Reason}
Types:
LogDir = string()
Mibs = [MibName]
MibName = string()
Block = boolean()
OutFile = string()
LogName = string()
LogFile = string()
Start = Stop = null | calendar:datetime() | {local_time,
calendar:datetime()} | {universal_time, calendar:datetime()}
Reason = disk_log_open_error() | file_open_error() | term()
disk_log_open_error() = {LogName, term()}
file_open_error() = {OutFile, term()}
Converts an Audit Trail Log to a readable text file. OutFile defaults to "./snmpa_log.txt". LogName defaults to
"snmpa_log". LogFile defaults to "snmpa.log".
The Block option indicates if the log should be blocked during conversion. This could be usefull when converting
large logs (when otherwise the log could wrap during conversion). Defaults to true.
See snmp:log_to_txt for more info.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 105
snmpa
106 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpa
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 107
snmpa
108 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpa
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 109
snmpa
snmp_agent:register_subagent(MAPid,[1,2,3,4],SA1),
snmp_agent:register_subagent(SA1,[1,2,3], SA2).
SA2 will not get requests starting with object identifier [1,2,3] since SA1 does not.
unregister_subagent(Agent, SubagentOidOrPid) -> ok | {ok, SubAgentPid} |
{error, Reason}
Types:
Agent = pid() | atom()
SubTreeOidorPid = oid() | pid()
Unregister a sub-agent. If the second argument is a pid, then that sub-agent will be unregistered from all trees in Agent.
send_notification2(Agent, Notification, SendOpts) -> void()
Types:
Agent = pid() | atom()
Notification = atom()
SendOpts = [send_option()]
send_option() = {receiver, receiver()} | {name, notify_name()} | {context,
context_name()} | {varbinds, varbinds()} | {local_engine_id, string()} |
{extra, extra_info()}
110 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpa
This informs the user which target addresses the notification was sent to.
{snmp_notification, tag(), {got_response, Address}}
This informs the user that this target address acknowledged the notification.
{snmp_notification, tag(), {no_response, Address}}
This informs the user that this target address did not acknowledge the notification.
The notification is sent as an Inform-Request to each target address in Addresses and if there are no targets
for which an Inform-Request is sent, Addresses is the empty list [].
The tag_receiver() will first be sent the snmp_targets message, and then for each address in
Addresses list, one of the two snmp_notification messages.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 111
snmpa
{Mod, Func, Args} - The info will be delivered via the function call:
Mod:Func([Msg | Args])
where Msg has the same content and purpose as the messages descrived above.
Note:
The extra info is not normally interpreted by the agent, instead it is passed through to the net-if process. It is
up to the implementor of that process to make use of this data.
The version of net-if provided by this application makes no use of this data, with one exception: Any tuple
containing the atom snmpa_default_notification_extra_info may be used by the agent and is
therefor reserved.
See the net-if incomming messages for sending a trap and notification for more info.
send_notification(Agent, Notification, Receiver)
send_notification(Agent, Notification, Receiver, Varbinds)
send_notification(Agent, Notification, Receiver, NotifyName, Varbinds)
send_notification(Agent, Notification, Receiver, NotifyName, ContextName,
Varbinds) -> void()
send_notification(Agent, Notification, Receiver, NotifyName, ContextName,
Varbinds, LocalEngineID) -> void()
Types:
Agent = pid() | atom()
Notification = atom()
Receiver = no_receiver | {Tag, Recv} | notification_delivery_info()
Tag = term()
Recv = receiver()
receiver() = pid() | atom() | {Mod, Func, Args}
Mod = atom()
Func = atom()
Args = list()
NotifyName = string()
ContextName = string()
Varbinds = varbinds()
varbinds() = [varbind()]
varbind() = {Variable, Value} | {Column, RowIndex, Value} | {OID, Value}
Variable = atom()
Column = atom()
OID = oid()
Value = term()
RowIndex = [int()]
LocalEngineID = string()
112 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpa
Sends the notification Notification to the management targets defined for NotifyName in the
snmpNotifyTable in SNMP-NOTIFICATION-MIB from the specified context.
If no NotifyName is specified (or if it is ""), the notification is sent to all management targets (Addresses below).
If no ContextName is specified, the default "" context is used.
The parameter Receiver specifies where information about delivery of Inform-Requests should be sent. The agent
sends Inform-Requests and waits for acknowledgments from the managers. Receiver can have three values:
If Receiver has the value {Tag, Recv}, the delivery is done according to Recv:
This inform the user which target addresses the notification was sent to.
{snmp_notification, Tag, {got_response, Address}}
This informs the user that this target address acknowledged the notification.
{snmp_notification, Tag, {no_response, Address}}
This informs the user that this target address did not acknowledge notification.
The notification is sent as an Inform-Request to each target address in Addresses and if there are no targets for
which an Inform-Request is sent, Addresses is the empty list [].
The receiver will first be sent the snmp_targets message, and then for each address in Addresses list,
one of the two snmp_notification messages.
{Mod, Func, Args} - The info will be delivered via the function call:
Mod:Func([Msg | Args])
where Msg has the same content and purpose as the messages descrived above.
Address is a management target address and Addresses is a list of management target addresses. They are defined
as followes:
Addresses =
Address
=
address() =
v1_address()
v3_address()
TDomain
=
TAddress
=
tdomain() =
[address()]
address()
v1_address() | v3_address()
= {TDomain, TAddress}
= {{TDomain, TAddress}, V3MsgData}
tdoamin()
taddress()
The oid of snmpUDPDomain
This is the only supported transport domain.
taddress() = [A1, A2, A3, A4, P1, P3]
The 4 first bytes makes up the IP-address and the last 2,
the UDP-port number.
V3MsgData = v3_msg_data()
v3_msg_data() = term()
then the
via the
information about
callback functions
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 113
snmpa
{Variable, Value}, where Variable is the symbolic name of a scalar variable referred to in the
notification specification.
{Column, RowIndex, Value}, where Column is the symbolic name of a column variable. RowIndex
is a list of indices for the specified element. If this is the case, the OBJECT IDENTIFIER sent in the
notification is the RowIndex appended to the OBJECT IDENTIFIER for the table column. This is the
OBJECT IDENTIFIER which specifies the element.
{OID, Value}, where OID is the OBJECT IDENTIFIER for an instance of an object, scalar variable, or
column variable.
For example, to specify that sysLocation should have the value "upstairs" in the notification, we could use
one of:
{sysLocation, "upstairs"} or
{[1,3,6,1,2,1,1,6,0], "upstairs"} or
{?sysLocation_instance, "upstairs"} (provided that the generated .hrl file is included)
If a variable in the notification is a table element, the RowIndex for the element must be given in the Varbinds
list. In this case, the OBJECT IDENTIFIER sent in the notification is the OBJECT IDENTIFIER that identifies this
element. This OBJECT IDENTIFIER could be used in a get operation later.
This function is asynchronous, and does not return any information. If an error occurs, user_err/2 of the error
report module is called and the notification is discarded.
Note:
Note that the use of the LocalEngineID argument is only intended for special cases, if the agent is to "emulate"
multiple EngineIDs! By default, the agent uses the value of SnmpEngineID (see SNMP-FRAMEWORK-MIB).
ExtraInfo is not normally used in any way by the agent. It is intended to be passed along to the net-if process,
which is a component that a user can implement themself. The users own net-if may then make use of ExtraInfo. The
net-if provided with this application does not process ExtraInfo.
There is one exception. Any tuple containing the atom snmpa_default_notification_extra_info will, in
this context, be considered belonging to this application, and may be processed by the agent.
114 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpa
Note:
If we are not at security-level noAuthNoPriv, this could be complicated, since the agent will then continue
with stage 2, before which the usm-related updates must be done.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 115
snmpa
Note:
The default discovery handler will require additional actions by the caller and the discovery will not work if the
security-level is higher then noAuthNoPriv.
convert_config(OldConfig) -> AgentConfig
Types:
OldConfig = list()
AgentConfig = list()
This off-line utility function can be used to convert the old snmp application config (pre snmp-4.0) to the new snmp
agent config (as of snmp-4.0).
For information about the old config (OldConfig) see the OTP R9C documentation.
For information about the current agent config (AgentConfig), see either the SNMP application part of the reference
manual or the Configuring the application chapter of the SNMP user's guide.
restart_worker() -> void()
restart_worker(Agent) -> void()
Types:
Agent = pid() | atom()
Restart the worker process of a multi-threaded agent.
This is a utility function, that can be useful when e.g. debugging instrumentation functions.
restart_set_worker() -> void()
restart_set_worker(Agent) -> void()
Types:
Agent = pid() | atom()
Restart the set worker process of a multi-threaded agent.
This is a utility function, that can be useful when e.g. debugging instrumentation functions.
print_mib_info() -> void()
Prints the content of all the (snmp) tables and variables for all mibs handled by the snmp agent.
print_mib_tables() -> void()
Prints the content of all the (snmp) tables for all mibs handled by the snmp agent.
print_mib_variables() -> void()
Prints the content of all the (snmp) variables for all mibs handled by the snmp agent.
verbosity(Ref,Verbosity) -> void()
Types:
Ref = pid() | sub_agents | master_agent | net_if | mib_server |
symbolic_store | note_store | local_db
116 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpa
See Also
calendar(3), erlc(1)
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 117
snmpa_conf
snmpa_conf
Erlang module
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:ip_address()
inet:ip6_address()
and
inet:port_number(),
see
Exports
agent_entry(Tag, Val) -> agent_entry()
Types:
Tag = intAgentTransports | intAgentUDPPort | intAgentMaxPacketSize |
snmpEngineMaxMessageSize | snmpEngineID
Val = term()
118 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
also
snmpa_conf
agent_entry() = term()
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.
write_agent_config(Dir, Conf) -> ok
write_agent_config(Dir, Hdr, Conf) -> ok
Types:
Dir = string()
Hdr = string()
Conf = [agent_entry()]
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.
append_agent_config(Dir, Conf) -> ok
Types:
Dir = string()
Conf = [agent_entry()]
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.
read_agent_config(Dir) -> Conf
Types:
Dir = string()
Conf = [agent_entry()]
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.
standard_entry(Tag, Val) -> standard_entry()
Types:
Tag = sysDescr | sysObjectID | sysContact | sysName | sysLocation |
sysServices | snmpEnableAuthenTraps
Val = term()
standard_entry() = term()
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.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 119
snmpa_conf
120 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpa_conf
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.
append_context_config(Dir, Conf) -> ok
Types:
Dir = string()
Conf = [context_entry()]
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.
read_context_config(Dir) -> Conf
Types:
Dir = string()
Conf = [context_entry()]
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.
community_entry(CommunityIndex) -> community_entry()
community_entry(CommunityIndex, CommunityName, SecName, ContextName,
TransportTag) -> community_entry()
Types:
CommunityIndex = string()
CommunityName = string()
SecName = string()
CtxName = string()
TransportTag = string()
community_entry() = term()
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
community_entry(CommunityIndex, CommunityIndex, CommunityIndex, "", "").
call:
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 121
snmpa_conf
Hdr = string()
Conf = [community_entry()]
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.
append_community_config(Dir, Conf) -> ok
Types:
Dir = string()
Conf = [community_entry()]
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.
read_community_config(Dir) -> Conf
Types:
Dir = string()
Conf = [community_entry()]
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.
target_addr_entry(Name, Domain, Addr, TagList, ParamsName, EngineId) ->
target_addr_entry()
target_addr_entry(Name, Domain, Addr, TagList, ParamsName, EngineId, TMask) > target_addr_entry()
target_addr_entry(Name, Domain, Addr, TagList, ParamsName, EngineId, TMask,
MaxMessageSize) -> target_addr_entry()
target_addr_entry(Name, Domain, Addr, Timeout, RetryCount, TagList,
ParamsName, EngineId, TMask, MaxMessageSize) -> target_addr_entry()
Types:
Name = string()
Domain = transportDomain()
Ip = transportAddress() (depends on Domain)
Timeout = integer()
RetryCount = integer()
TagList = string()
ParamsName = string()
EngineId = string()
TMask = transportAddressMask() (depends on Domain)
MaxMessageSize = integer()
122 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpa_conf
target_addr_entry() = term()
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.
write_target_addr_config(Dir, Conf) -> ok
write_target_addr_config(Dir, Hdr, Conf) -> ok
Types:
Dir = string()
Hdr = string()
Conf = [target_addr_entry()]
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.
append_target_addr_config(Dir, Conf) -> ok
Types:
Dir = string()
Conf = [target_addr_entry()]
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.
read_target_addr_config(Dir) -> Conf
Types:
Dir = string()
Conf = [target_addr_entry()]
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.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 123
snmpa_conf
\011
\011
\011
Vsn,
124 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpa_conf
Dir is the path to the directory where to store the config file.
See Target Parameters Definitions for more info.
read_target_params_config(Dir) -> Conf
Types:
Dir = string()
Conf = [target_params_entry()]
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.
vacm_s2g_entry(SecModel, SecName, GroupName) -> vacm_s2g_entry()
vacm_acc_entry(GroupName, Prefix, SecModel, SecLevel, Match, ReadView,
WriteView, NotifyView) -> vacm_acc_entry()
vacm_vtf_entry(ViewIndex, ViewSubtree) -> vacm_vtf_entry()
vacm_vtf_entry(ViewIndex, ViewSubtree, ViewStatus, ViewMask) ->
vacm_vtf_entry()
Types:
SecModel = v1 | v2c | usm
SecName = string()
GroupName = string()
Prefix = string()
SecLevel = noAuthNoPriv | authNoPriv | authPriv
Match = prefix | exact
ReadView = string()
WriteView = string()
NotifyView = string()
ViewIndex = integer()
ViewSubtree = [integer()]
ViewStatus = included | excluded
ViewMask = null | [zero_or_one()]
zero_or_one() = 0 | 1
vacm_s2g_entry() = term()
vacm_acc_entry() = term()
vacm_vtf_entry() = term()
Create an entry for the agent vacm config file, vacm.conf.
vacm_vtf_entry/2 translates to the following call: vacm_vtf_entry(ViewIndex,
included, null).
ViewSubtree,
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 125
snmpa_conf
Dir = string()
Hdr = string()
Conf = [vacm_entry()]
vacm_entry() = vacm_sg2_entry() | vacm_acc_entry() | vacm_vtf_entry()
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.
append_vacm_config(Dir, Conf) -> ok
Types:
Dir = string()
Conf = [vacm_entry()]
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.
read_vacm_config(Dir) -> Conf
Types:
Dir = string()
Conf = [vacm_entry()]
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.
usm_entry(EngineId) -> usm_entry()
usm_entry(EngineID, UserName, SecName, Clone, AuthP, AuthKeyC, OwnAuthKeyC,
PrivP, PrivKeyC, OwnPrivKeyC, Public, AuthKey, PrivKey) -> usm_entry()
Types:
EngineId = string()
UserName = string()
SecName = string()
Clone = zeroDotZero | [integer()]
AuthP = usmNoAuthProtocol | usmHMACMD5AuthProtocol, |
usmHMACSHAAuthProtocol
AuthKeyC = string()
OwnAuthKeyC = string()
PrivP = usmNoPrivProtocol | usmDESPrivProtocol | usmAesCfb128Protocol
PrivKeyC = string()
OwnPrivKeyC = string()
Public = string()
AuthKey = [integer()]
126 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpa_conf
PrivKey = [integer()]
usm_entry() = term()
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.
write_usm_config(Dir, Conf) -> ok
write_usm_config(Dir, Hdr, Conf) -> ok
Types:
Dir = string()
Hdr = string()
Conf = [usm_entry()]
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.
append_usm_config(Dir, Conf) -> ok
Types:
Dir = string()
Conf = [usm_entry()]
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.
read_usm_config(Dir) -> Conf
Types:
Dir = string()
Conf = [usm_entry()]
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.
notify_entry(Name, Tag, Type) -> notify_entry()
Types:
Name = string()
Tag = string()
Type = trap | inform
community_entry() = term()
Create an entry for the agent notify config file, notify.conf.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 127
snmpa_conf
128 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpa_discovery_handler
snmpa_discovery_handler
Erlang module
This module defines the behaviour of the agent discovery handler. A snmpa_discovery_handler compliant
module must export the following functions:
stage1_finish/2
The semantics of them and their exact signatures are explained below.
Exports
stage1_finish(TargetName, ManagerEngineID, ExtraInfo) -> ignore |
{ok, usm_entry() | [usm_entry()]} | {ok, usm_entry() | [usm_entry()],
NewExtraInfo}
Types:
TargetName = string()
ManagerEngineID = string()
ExtraInfo = term()
usm_entry() = tuple() compatible with usm.conf
NewExtraInfo = term()
This function is called at the end of stage 1 of the discovery process. It should return either the atom ignore or {ok,
usm_entry() | [usm_entry()]}. See usm_entry() and usm_entry/13 for more info.
If the function returns ignore, then it is assumed that either:
The caller (of the discovery function) will make the needed updates later.
The callback function itself did the updates.
In either case, the agent will do nothing, but return the retrieved ManagerEngineID (see discovery for more info) and
possible continue with stage 2 of the discovery process.
The ExtraInfo argument is passed on from the discovery function.
This function may return an updated NewExtraInfo that will be used in subsequent calls to the callback functions.
Intended for future use.
The purpose of this function is to generate the usm- related security data needed for usm processing in the agent.
Specifically, updating the usmUserTable.
When an usm_entry() tuple (or a list of such tuples) is returned, this data is then added to the usmUserTable
by the (master-) agent.
When an usm_entry() tuple (or a list of such tuples) is returned, this data is then added to the usmUserTable
by the (master-) agent.
Note:
Note that the function does not check if this entry already exists.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 129
snmpa_discovery_handler
Note:
Note that this function is executed in the context of the master-agent process.
130 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpa_error_report
snmpa_error_report
Erlang module
This module defines the behaviour of the agent error reporting. A snmpa_error_report compliant module must
export the following functions:
config_err/2
user_err/2
The semantics of them and their exact signatures are explained below.
Exports
config_err(Format, Args) -> void()
Types:
Format = string()
Args = list()
The function is called if an error occurs during the configuration phase, for example if a syntax error is found in a
configuration file.
Format and Args are as in io:format(Format, Args).
user_err(Format, Args) -> void()
Types:
Format = string()
Args = list()
The function is called if a user related error occurs at run-time, for example if a user defined instrumentation function
returns erroneous.
Format and Args are as in io:format(Format, Args).
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 131
snmpa_error
snmpa_error
Erlang module
The module snmpa_error contains two callback functions which are called if an error occurs at different times
during agent operation. These functions in turn calls the corresponding function in the configured error report module,
which implements the actual report functionality.
Two simple implementation(s) is provided with the toolkit; the modules snmpa_error_logger which is the default and
snmpa_error_io.
The error report module is configured using the directive error_report_mod, see configuration parameters.
Exports
config_err(Format, Args) -> void()
Types:
Format = string()
Args = list()
The function is called if an error occurs during the configuration phase, for example if a syntax error is found in a
configuration file.
Format and Args are as in io:format(Format, Args).
user_err(Format, Args) -> void()
Types:
Format = string()
Args = list()
The function is called if a user related error occurs at run-time, for example if a user defined instrumentation function
returns erroneous.
Format and Args are as in io:format(Format, Args).
132 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpa_error_io
snmpa_error_io
Erlang module
Exports
config_err(Format, Args) -> void()
Types:
Format = string()
Args = list()
The function is called if an error occurs during the configuration phase, for example if a syntax error is found in a
configuration file.
Format and Args are as in io:format(Format, Args).
user_err(Format, Args) -> void()
Types:
Format = string()
Args = list()
The function is called if a user related error occurs at run-time, for example if a user defined instrumentation function
returns erroneous.
Format and Args are as in io:format(Format, Args).
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 133
snmpa_error_logger
snmpa_error_logger
Erlang module
(see
This module provides a simple mechanism for reporting SNMP errors. Errors are sent to the error_logger after
a size check. Messages are truncated after 1024 chars. It is provided as an example.
This module is the default error report module, but can be explicitly configured, see snmpa_error and configuration
parameters.
Exports
config_err(Format, Args) -> void()
Types:
Format = string()
Args = list()
The function is called if an error occurs during the configuration phase, for example if a syntax error is found in a
configuration file.
Format and Args are as in io:format(Format, Args).
user_err(Format, Args) -> void()
Types:
Format = string()
Args = list()
The function is called if a user related error occurs at run-time, for example if a user defined instrumentation function
returns erroneous.
Format and Args are as in io:format(Format, Args).
See Also
error_logger(3)
134 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpa_local_db
snmpa_local_db
Erlang module
The module snmpa_local_db contains functions for implementing tables (and variables) using the SNMP built-in
database. The database exists in two instances, one volatile and one persistent. The volatile database is implemented
with ets. The persistent database is implemented with dets.
There is a scaling problem with this database.
where RowIndex denotes the last part of the OID, that specifies the index of the row in the table. Cols is a list of
column numbers in case of a get operation, and a list of column numbers and values in case of a set operation.
Exports
dump() -> ok | {error, Reason}
Types:
Reason = term()
This function can be used to manually dump the database to file.
match(NameDb, Pattern)
Performs an ets/dets matching on the table. See Stdlib documentation, module ets, for a description of Pattern and
the return values.
print()
print(TableName)
print(TableName, Db)
Types:
TableName = atom()
Prints the contents of the database on screen. This is useful for debugging since the STANDARD-MIB and OTPSNMPEA-MIB (and maybe your own MIBs) are stored in snmpa_local_db.
TableName is an atom for a table in the database. When no name is supplied, the whole database is shown.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 135
snmpa_local_db
See Also
ets(3), dets(3), snmp_generic(3)
136 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpa_mib_data
snmpa_mib_data
Erlang module
This module defines the behaviour of the SNMP agent mib-server data module. A snmpa_mib_data compliant
module must export the following functions:
new/1
close/1
sync/1
load_mib/4
unload_mib/4
lookup/2
next/3
register_subagent/3
unregister_subagent/2
which_mib/2
which_mibs/1
whereis_mib/2
dump/2
info/1
backup/2
code_change/4
The semantics of them and their exact signatures are explained below.
Note that the data extracted from the imported (loaded) mibs are stored partly by the mib-server and partly by the
symbolic-store server. See the default mib-server data module, snmpa_mib_data_tttn for details.
CALLBACK FUNCTIONS
The following functions must be exported from a mib-server data callback module:
Exports
Module:new(Storage) -> State
Types:
Storage = mib_storage()
State = term()
Create a new mib-server data instance.
Module:close(State) -> void()
Types:
State = term()
Close the mib-storage.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 137
snmpa_mib_data
138 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpa_mib_data
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 139
snmpa_mib_data
MibName = atom()
Filename = string()
Retrieve all loaded mib-files.
Module:whereis_mib(State, MibName) -> Reply
Types:
State = term()
MibName = atom()
Reply = {ok, Filename} | {error, Reason}
Filename = string()
Reason = term()
Retrieve the mib file for the mib.
Module:info(State) -> Reply
Types:
State = term()
Reply = {ok, Filename} | {error, Reason}
Filename = string()
Reason = term()
Retrieve misc info for the mib data.
This is a utility function used to inspect, for instance, memory usage, in a simple way.
Module:backup(State, BackupDir) -> Reply
Types:
State = term()
Reply = ok | {error, Reason}
BackupDir = string()
Reason = term()
Perform a backup of the mib-server data.
Note that its implementation dependant (and also dependent on mib-storage is used) if a backup is possible.
Module:code_change(Destination, Vsn, Extra, State) -> NewState
Types:
Destination = up | down
Vsn = term()
Extra = term()
State = NewState = term()
Perform a code-change (upgrade or downgrade).
See gen_server for more info regarding the Vsn and Extra arguments.
140 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpa_mib_storage
snmpa_mib_storage
Erlang module
This module defines the behaviour of the SNMP agent mib storage.
The mib storage is used by the agent to store internal mib- related information. The mib storage module is used by
several entities, not just the mib-server.
A snmpa_mib_storage compliant module must export the following functions:
open/5
close/1
read/2
write/2
delete/1
delete/2
match_object/2
match_delete/2
tab2list/1
info/1
sync/1
backup/2
The semantics of them and their exact signatures are explained below.
CALLBACK FUNCTIONS
The following functions must be exported from a mib-server data callback module:
Exports
Module:open(Name, RecordName, Fields, Type, Options) -> {ok, TabId} | {error,
Reason}
Types:
Name = atom()
RecordName = atom()
Fields = [atom()]
Type = set | bag()
Options = list()
TabId = term()
Reason = term()
Create or open a mib storage table.
Note that the RecordName and Fields arguments my not be used in all implementations (they are actually only
needed for mnesia-based implementations).
Note also that the Options argument comes from the options config option of the mib-storage config option,
and is passed on as is.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 141
snmpa_mib_storage
142 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpa_mib_storage
Recs = [tuple()]
Reason = term()
Search the mib-storage table for record that match the specified pattern and then delete them. The records deleted
are also returned.
Module:tab2list(TabId) -> Recs
Types:
TabId = term()
Recs = [tuple()]
Return all records in the mib-storage table in the form of a list.
Module:info(TabId) -> {ok, Info} | {error, Reason}
Types:
TabId = term()
Info = term()
Reason = term()
Retrieve implementation dependent mib-storage table information.
Module:sync(TabId) -> void()
Types:
TabId = term()
Synchronize the mib-storage table.
What this means, if anything, is implementation dependent.
Module:backup(TabId, BackupDir) -> ok | {error, Reason}
Types:
TabId = term()
BackupDir = string()
Reason = term()
Perform a backup of the mib-storage table.
What this means, if anything, is implementation dependent.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 143
snmpa_mpd
snmpa_mpd
Erlang module
The module snmpa_mpd implements the version independent Message Processing and Dispatch functionality in
SNMP for the agent. It is supposed to be used from a Network Interface process (Definition of Agent Net if).
DATA TYPES
See the data types in snmpa_conf.
Exports
init(Vsns) -> mpd_state()
Types:
Vsns = [Vsn]
Vsn = v1 | v2 | v3
This function can be called from the net_if process at start-up. The options list defines which versions to use.
It also initializes some SNMP counters.
process_packet(Packet, From, State, NoteStore, Log) -> {ok, Vsn, Pdu, PduMS,
ACMData} | {discarded, Reason} | {discovery, DiscoPacket}
process_packet(Packet, From, LocalEngineID, State, NoteStore, Log) -> {ok,
Vsn, Pdu, PduMS, ACMData} | {discarded, Reason} | {discovery, DiscoPacket}
Types:
Packet = binary()
From = {TDomain, TAddr}
TDomain = transportDomainUdpIpv4 | transportDomainUdpIpv6
TAddr = {IpAddr, IpPort}
LocalEngineID = string()
IpAddr = inet:ip_address()
IpPort = inet:port_number()
State = mpd_state()
NoteStore = pid()
Log = snmp_log()
Vsn = 'version-1' | 'version-2' | 'version-3'
Pdu = #pdu
PduMs = integer()
ACMData = acm_data()
Reason = term()
DiscoPacket = binary()
Processes an incoming packet. Performs authentication and decryption as necessary. The return values should be
passed to the agent.
144 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpa_mpd
Note:
Note that the use of the LocalEngineID argument is only intended for special cases, if the agent is to "emulate"
multiple EngineIDs! By default, the agent uses the value of SnmpEngineID (see SNMP-FRAMEWORK-MIB).
generate_response_msg(Vsn, RePdu, Type, ACMData, Log) -> {ok, Packet} |
{discarded, Reason}
generate_response_msg(Vsn, RePdu, Type, ACMData, LocalEngineID, Log) -> {ok,
Packet} | {discarded, Reason}
Types:
Vsn = 'version-1' | 'version-2' | 'version-3'
RePdu = #pdu
Type = atom()
ACMData = acm_data()
LocalEngineID = string()
Packet = binary()
Generates a possibly encrypted response packet to be sent to the network. Type is the #pdu.type of the original
request.
Note:
Note that the use of the LocalEngineID argument is only intended for special cases, if the agent is to "emulate"
multiple EngineIDs! By default, the agent uses the value of SnmpEngineID (see SNMP-FRAMEWORK-MIB).
generate_msg(Vsn, NoteStore, Pdu, MsgData, To) -> {ok, PacketsAndAddresses} |
{discarded, Reason}
generate_msg(Vsn, NoteStore, Pdu, MsgData, LocalEngineID, To) -> {ok,
PacketsAndAddresses} | {discarded, Reason}
Types:
Vsn = 'version-1' | 'version-2' | 'version-3'
NoteStore = pid()
Pdu = #pdu
MsgData = msg_data()
LocalEngineID = string()
To = [dest_addrs()]
PacketsAndAddresses = [{TDomain, TAddress, Packet}]
TDomain = snmpUDPDomain
TAddress = {Ip, Udp}
Ip = {integer(), integer(), integer(), integer()}
Udp = integer()
Packet = binary()
Generates a possibly encrypted request packet to be sent to the network.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 145
snmpa_mpd
MsgData is the message specific data used in the SNMP message. This value is received in a send_pdu or
send_pdu_req message from the agent. In SNMPv1 and SNMPv2c, this message data is the community string.
In SNMPv3, it is the context information.
To is a list of destination addresses and their corresponding security parameters. This value is received in the same
message from the agent and then transformed trough process_taddrs before passed to this function.
Note:
Note that the use of the LocalEngineID argument is only intended for special cases, if the agent is to "emulate"
multiple EngineIDs! By default, the agent uses the value of SnmpEngineID (see SNMP-FRAMEWORK-MIB).
process_taddrs(TDests) -> Dests
Types:
TDests = [TDest]
TDest = {{TDomain, TAddr}, SecData} | {TDomain, TAddr}
TDomain = term() % Not at tuple
TAddr = term()
SecData = term()
Dests = [Dest]
Dest = {{Domain, Addr}, SecData} | {Domain, Addr}
Domain = transportDomain()
Addr = transportAddress() % Depends on Domain
Transforms addresses from internal MIB format to one more useful to Agent Net if.
See also generate_msg.
discarded_pdu(Variable) -> void()
Types:
Variable = atom()
Increments the variable associated with a discarded pdu. This function can be used when the net_if process receives
a discarded_pdu message from the agent.
146 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpa_network_interface
snmpa_network_interface
Erlang module
This module defines the behaviour of the agent network interface. A snmpa_network_interface compliant
module must export the following functions:
start_link/4
info/1
get_log_type/1
set_log_type/2
verbosity/2
The semantics of them and their exact signatures are explained below.
But this is not enough. There is also a set of mandatory messages which the network interface entity must be able to
receive and be able to send. This is described in chapter snmp_agent_netif.
Exports
start_link(Prio, NoteStore, MasterAgent, Opts) -> {ok, Pid} | {error, Reason}
Types:
Prio = priority()
NoteStore = pid()
MasterAgent = pid()
Opts = [opt()]
opt() = {verbosity, verbosity()} | {versions, versions()} | term()
versions() = [version()]
version() = v1 | v2 | v3
Start-link the network interface process.
NoteStore is the pid of the note-store process and MasterAgent is the pid of the master-agent process.
Opts is an (basically) implementation dependent list of options to the network interface process. There are however
a number of options which must be handled: versions and verbosity.
info(Pid) -> [{Key, Value}]
Types:
Pid = pid()
The info returned is basically up to the implementer to decide. This implementation provided by the application
provides info about memory allocation and various socket information.
The info returned by this function is returned together with other info collected by the agent when the info function
is called (tagged with with the key net_if).
verbosity(Pid, Verbosity) -> void()
Types:
Pid = pid()
Verbosity = verbosity()
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 147
snmpa_network_interface
148 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpa_network_interface_filter
snmpa_network_interface_filter
Erlang module
This
module
defines
the
behaviour
of
the
agent
network
interface
snmpa_network_interface_filter compliant module must export the following functions:
filter.
accept_recv/2
accept_send/2
accept_recv_pdu/3
accept_send_pdu/2
The semantics of them and their exact signatures are explained below.
The purpose of the network interface filter is to allow for filtering of messages (accept or reject) receive and send.
This is done on two levels:
The first level is at the transport entry / exit point, i.e. immediately after the receipt of the message before
any message processing is done (accept_recv) and immediately before sending the message after all message
processing is done (accept_send).
The second level is at the MPD entry / exit point, i.e. immediately after the basic message processing
(accept_recv_pdu) / immediately before the basic message processing (accept_send_pdu).
Note that the network interface filter is something which is used by the network interface implementation provided by
the application (snmpa_net_if). The default filter accepts all messages.
A network interface filter can e.g. be used during testing or for load regulation. If the intended use is load regulation,
see also req_limit and the function register_notification_filter.
Legacy network interface filter modules used arguments on the form (IpAddr, PortNumber,...) instead of
(Domain, Addr, ...), and if the SNMP agent is run without changing the configuration to use transport domains
the network interface filter will still get the old arguments and work as before.
DATA TYPES
port() = integer() > 0
pdu_type() = 'get-request' | 'get-next-request' | 'get-response' |
'set-request' | trap | 'get-bulk-request' | 'inform-request' |
report
Exports
accept_recv(Domain, Addr) -> boolean()
Types:
Domain = transportDomain()
Addr = transportAddressWithPort()
Called at the reception of a message (before any processing has been done).
For the message to be discarded, the function must return false.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 149
snmpa_network_interface_filter
150 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpa_notification_delivery_info_receiver
snmpa_notification_delivery_info_receiver
Erlang module
This module defines the behaviour of the notification delivery information receiver.
A snmpa_notification_delivery_info_receiver compliant module must export the following
functions:
delivery_targets/3
delivery_info/4
The semantics of them and their exact signatures are explained below.
Legacy notification delivery information receiver modules used a target argument on the form {IpAddr,
PortNumber} instead of {Domain, Addr}, and if the SNMP Agent is run without changing the configuration to
use transport domains the notification delivery information receiver will still get the old arguments and work as before.
DATA TYPES
See the data types in snmpa_conf.
Exports
delivery_targets(Tag, Targets, Extra) -> void()
Types:
Tag = term()
Targets = [Target]
Target = {transportDomain(), transportAddressWithPort()
Extra = term()
Inform about target addresses.
This is the first function called when a notification delivery is in progress. It informs the receiver which targets will
get the notification. The result of the delivery will be provided via successive calls to delivery_info/4 function,
see below.
delivery_info(Tag, Target, DeliveryResult, Extra) -> void()
Types:
Tag = term()
Targets = [Target]
Target = {transportDomain(), transportAddressWithPort()
DeliveryResult = delivery_result()
delivery_result() = no_response | got_response
Extra = term()
Inform about delivery result.
This function is called for each target in the Targets argument of the delivery_targets/3 function, see above.
The purpose is to inform the receiver of the result of the delivery (was the notification acknowledged or not) for
each target.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 151
snmpa_notification_filter
snmpa_notification_filter
Erlang module
This module defines the behaviour of the agent notification filters. A snmpa_notification_filter compliant
module must export the following functions:
handle_notification/2
The semantics of them and their exact signatures are explained below.
The purpose of notification filters is to allow for modification and/or suppression of a notification.
A misbehaving filter will be removed.
Exports
handle_notification(Notif, Data) -> Reply
Types:
Reply = send | {send, NewNotif} | dont_send
Notif = NewNotif = notification() | trap()
Data = term()
Handle a notification to be sent. The filter can either accept the notification as is, return send, modify the notification,
return {send, NewNotif} or suppress the notification, return dont_send.
Data is supplied at filter registration time, see register_notification_filter.
152 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpa_supervisor
snmpa_supervisor
Erlang module
This is the top supervisor for the agent part of the SNMP application. There is always one supervisor at each node
with an SNMP agent (master agent or sub-agent).
Exports
start_sub_sup(Opts) -> {ok, pid()} | {error, {already_started, pid()}} |
{error, Reason}
Types:
Opts = [opt()]
opt() = {db_dir, string()} | ...
Starts a supervisor for the SNMP agent system without a master agent. The supervisor starts all involved SNMP
processes, but no agent processes. Sub-agents should be started by calling start_sub_agent/3.
db_dir is mandatory.
See configuration parameters for a description of the options.
start_master_sup(Opts) -> {ok, pid()} | {error, {already_started, pid()}} |
{error, Reason}
Types:
Opts = [opt()]
opt() = {db_dir, string()} | {config, ConfOpts()} | ...
ConfOpts = [conf_opts()]
conf_opts() = {dir, string()} | ...
Reason = term()
Starts a supervisor for the SNMP agent system. The supervisor starts all involved SNMP processes, including the
master agent. Sub-agents should be started by calling start_subagent/3.
db_dir is mandatory.
dir in config is mandatory.
See snmp config for a description of the options.
start_sub_agent(ParentAgent,Subtree,Mibs) -> {ok, pid()} | {error, Reason}
Types:
ParentAgent = pid()
SubTree = oid()
Mibs = [MibName]
MibName = [string()]
Starts a sub-agent on the node where the function is called. The snmpa_supervisor must be running.
If the supervisor is not running, the function fails with the reason badarg.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 153
snmpa_supervisor
154 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmp_community_mib
snmp_community_mib
Erlang module
The module snmp_community_mib implements the instrumentation functions for the SNMP-COMMUNITYMIB, and functions for configuring the database.
The configuration files are described in the SNMP User's Manual.
Exports
configure(ConfDir) -> void()
Types:
ConfDir = string()
This function is called from the supervisor at system start-up.
Inserts all data in the configuration files into the database and destroys all old rows with StorageType volatile.
The rows created from the configuration file will have StorageType nonVolatile.
All snmp counters are set to zero.
If an error is found in the configuration file, it is reported using the function config_err/2 of the error, report
module and the function fails with reason configuration_error.
ConfDir is a string which points to the directory where the configuration files are found.
The configuration file read is: community.conf.
reconfigure(ConfDir) -> void()
Types:
ConfDir = string()
Inserts all data in the configuration files into the database and destroys all old data, including the rows with StorageType
nonVolatile. The rows created from the configuration file will have StorageType nonVolatile.
Thus, the data in the SNMP-COMMUNITY-MIB, after this function has been called, is from the configuration files.
All snmp counters are set to zero.
If an error is found in the configuration file, it is reported using the function config_err/2 of the error report
module, and the function fails with reason configuration_error.
ConfDir is a string which points to the directory where the configuration files are found.
The configuration file read is: community.conf.
add_community(Idx, CommName, SecName, CtxName, TransportTag) -> Ret
add_community(Idx, CommName, SecName, EngineId, CtxName, TransportTag) -> Ret
Types:
Idx = string()
CommName = string()
SecName = string()
EngineId = string()
CtxName = string()
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 155
snmp_community_mib
TransportTag = string()
Ret = {ok, Key} | {error, Reason}
Key = term()
Reason = term()
Adds a community to the agent config. Equivalent to one line in the community.conf file.
With the EngineId argument it is possible to override the configured engine-id (SNMP-FRAMEWORK-MIB).
delete_community(Key) -> Ret
Types:
Key = term()
Ret = ok | {error, Reason}
Reason = term()
Delete a community from the agent config.
156 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmp_framework_mib
snmp_framework_mib
Erlang module
Exports
configure(ConfDir) -> void()
Types:
ConfDir = string()
This function is called from the supervisor at system start-up.
Inserts all data in the configuration files into the database and destroys all old data.
Thus, the data in the SNMP-FRAMEWORK-MIB, after this function has been called, is from the configuration files.
All snmp counters are set to zero.
If an error is found in the configuration file, it is reported using the function config_err/2 of the error report
module, and the function fails with reason configuration_error.
ConfDir is a string which points to the directory where the configuration files are found.
The configuration file read is: context.conf.
init() -> void()
This function is called from the supervisor at system start-up.
Creates the necessary objects in the database if they do not exist. It does not destroy any old values.
add_context(Ctx) -> Ret
Types:
Ctx = string()
Ret = {ok, Key} | {error, Reason}
Key = term()
Reason = term()
Adds a context to the agent config. Equivalent to one line in the context.conf file.
delete_context(Key) -> Ret
Types:
Key = term()
Ret = ok | {error, Reason}
Reason = term()
Delete a context from the agent config.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 157
snmp_generic
snmp_generic
Erlang module
The module snmp_generic contains generic functions for implementing tables (and variables) using the SNMP
built-in database or Mnesia. These default functions are used if no instrumentation function is provided for a managed
object in a MIB. Sometimes, it might be necessary to customize the behaviour of the default functions. For example,
in some situations a trap should be sent if a row is deleted or modified, or some hardware is to be informed, when
information is changed.
The overall structure is shown in the following figure:
+---------------+
|
SNMP Agent |
+- - - - - - - -+
|
MIB
|
+---------------+
|
Association file
(associates a MIB object with
|
snmp_generic:table_funct
|
snmp_generic:variable_func)
+--------------------------------------+
|
snmp_generic
| Support for get-next,
|
| RowStatus operations
+----------------------+---------------+
|
snmpa_local_db
|
Mnesia
| Database
+--------------+-------+---------------+
|
dets
| ets |
| (persistent) |
|
+--------------+-------+
Each function takes the argument NameDb, which is a tuple {Name, Db}, to identify which database the functions
should use. Name is the symbolic name of the managed object as defined in the MIB, and Db is either volatile,
persistent, or mnesia. If it is mnesia, all variables are stored in the Mnesia table snmp_variables which
must be a table with two attributes (not a Mnesia SNMP table). The SNMP tables are stored in Mnesia tables with
the same names as the SNMP tables. All functions assume that a Mnesia table exists with the correct name and
attributes. It is the programmer's responsibility to ensure this. Specifically, if variables are stored in Mnesia, the table
snmp_variables must be created by the programmer. The record definition for this table is defined in the file
snmp/include/snmp_types.hrl.
If an instrumentation function in the association file for a variable myVar does not have a name when compiling an
MIB, the compiler generates an entry.
158 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmp_generic
DATA TYPES
In the functions defined below, the following types are used:
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).
columns()
Is a list of column numbers in the case of a get operation, and a list of column numbers and values in the case
of a set operation.
Exports
get_status_col(Name, Cols)
get_status_col(NameDb, Cols) -> {ok, StatusVal} | false
Types:
Name = name()
NameDb = name_db()
Cols = columns()
StatusVal = term()
Gets the value of the status column from Cols.
This function can be used in instrumentation functions for is_set_ok, undo or set to check if the status column
of a table is modified.
get_index_types(Name)
Types:
Name = name()
Gets the index types of Name
This function can be used in instrumentation functions to retrieve the index types part of the table info.
get_table_info(Name, Item) -> table_info_result()
Types:
Name = name()
Item = table_item() | all
table_item() = nbr_of_cols | defvals | status_col | not_accessible |
index_types | first_accessible | first_own_index
table_info_result() = Value | [{table_item(), Value}]
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 159
snmp_generic
Value = term()
Get a specific table info item or, if Item has the value all, a two tuple list (property list) is instead returned with
all the items and their respctive values of the given table.
This function can be used in instrumentation functions to retrieve a given part of the table info.
table_func(Op1, NameDb)
table_func(Op2, RowIndex, Cols, NameDb) -> Ret
Types:
Op1 = new | delete
Op2 = get | next | is_set_ok | set | undo
NameDb = name_db()
RowIndex = row_index()
Cols = columns()
Ret = term()
This is the default instrumentation function for tables.
The new function creates the table if it does not exist, but only if the database is the SNMP internal db.
The delete function does not delete the table from the database since unloading an MIB does not necessarily
mean that the table should be destroyed.
The is_set_ok function checks that a row which is to be modified or deleted exists, and that a row which is
to be created does not exist.
The undo function does nothing.
The set function checks if it has enough information to make the row change its status from notReady to
notInService (when a row has been been set to createAndWait). If a row is set to createAndWait,
columns without a value are set to noinit. If Mnesia is used, the set functionality is handled within a
transaction.
If it is possible for a manager to create or delete rows in the table, there must be a RowStatus column for
is_set_ok, set and undo to work properly.
The function returns according to the specification of an instrumentation function.
table_get_elements(NameDb, RowIndex, Cols) -> Values
Types:
NameDb = name_db()
RowIndex = row_index()
Cols = columns()
Values = [value() | noinit]
Returns a list with values for all columns in Cols. If a column is undefined, its value is noinit.
table_next(NameDb, RestOid) -> RowIndex | endOfTable
Types:
NameDb = name_db()
RestOid = [int()]
RowIndex = row_index()
Finds the indices of the next row in the table. RestOid does not have to specify an existing row.
160 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmp_generic
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 161
snmp_generic
Example
The following example shows an implementation of a table which is stored in Mnesia, but with some checks performed
at set-request operations.
162 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmp_index
snmp_index
Erlang module
The module snmp_index implements an Abstract Data Type (ADT) for an SNMP index structure for SNMP tables.
It is implemented as an ets table of the ordered_set data-type, which means that all operations are O(log n). In the
table, the key is an ASN.1 OBJECT IDENTIFIER.
This index is used to separate the implementation of the SNMP ordering from the actual implementation of the table.
The SNMP ordering, that is implementation of GET NEXT, is implemented in this module.
For example, suppose there is an SNMP table, which is best implemented in Erlang as one process per SNMP table
row. Suppose further that the INDEX in the SNMP table is an OCTET STRING. The index structure would be created
as follows:
snmp_index:new(string)
With this structure, we can now map an OBJECT IDENTIFIER in e.g. a GET NEXT request, to the correct process:
index()
oid() = [byte()]
key_types = type_spec() | {type_spec(), type_spec(), ...}
type_spec() = fix_string | string | integer
key() = key_spec() | {key_spec(), key_spec(), ...}
key_spec() = string() | integer()
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 163
snmp_index
The key_types() type defines the types of the SNMP INDEX columns for the table. If the table has one single
INDEX column, this type should be a single atom, but if the table has multiple INDEX columns, it should be a tuple
with atoms.
If the INDEX column is of type INTEGER, or derived from INTEGER, the corresponding type should be integer. If
it is a variable length type (e.g. OBJECT IDENTIFIER, OCTET STRING), the corresponding type should be string.
Finally, if the type is of variable length, but with a fixed size restriction (e.g. IpAddress), the corresponding type should
be fix_string.
For example, if the SNMP table has two INDEX columns, the first one an OCTET STRING with size 2, and the second
one an OBJECT IDENTIFER, the corresponding key_types parameter would be {fix_string, string}.
The key() type correlates to the key_types() type. If the key_types() is a single atom, the corresponding
key() is a single type as well, but if the key_types() is a tuple, key must be a tuple of the same size.
In the example above, valid keys could be {"hi", "mom"} and {"no", "thanks"}, whereas "hi", {"hi",
42} and {"hello", "there"} would be invalid.
Warning:
All API functions that update the index return a NewIndex term. This is for backward compatibility with a
previous implementation that used a B+ tree written purely in Erlang for the index. The NewIndex return value
can now be ignored. The return value is now the unchanged table identifier for the ets table.
The implementation using ets tables introduces a semantic incompatibility with older implementations. In those
older implementations, using pure Erlang terms, the index was garbage collected like any other Erlang term and
did not have to be deleted when discarded. An ets table is deleted only when the process creating it explicitly
deletes it or when the creating process terminates.
A new interface delete/1 is now added to handle the case when a process wants to discard an index table (i.e.
to build a completely new). Any application using transient snmp indexes has to be modified to handle this.
As an snmp adaption usually keeps the index for the whole of the systems lifetime, this is rarely a problem.
Exports
delete(Index) -> true
Types:
Index = NewIndex = index()
Key = key()
Deletes a complete index structure (i.e. the ets table holding the index). The index can no longer be referenced after
this call. See the warning note above.
delete(Index, Key) -> NewIndex
Types:
Index = NewIndex = index()
Key = key()
Deletes a key and its value from the index structure. Returns a new structure.
get(Index, KeyOid) -> {ok, {KeyOid, Value}} | undefined
Types:
164 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmp_index
Index = index()
KeyOid = oid()
Value = term()
Gets the item with key KeyOid. Could be used from within an SNMP instrumentation function.
get_last(Index) -> {ok, {KeyOid, Value}} | undefined
Types:
Index = index()
KeyOid = oid()
Value = term()
Gets the last item in the index structure.
get_next(Index, KeyOid) -> {ok, {NextKeyOid, Value}} | undefined
Types:
Index = index()
KeyOid = NextKeyOid = oid()
Value = term()
Gets the next item in the SNMP lexicographic ordering, after KeyOid in the index structure. KeyOid does not have
to refer to an existing item in the index.
insert(Index, Key, Value) -> NewIndex
Types:
Index = NewIndex = index()
Key = key()
Value = term()
Inserts a new key value tuple into the index structure. If an item with the same key already exists, the new Value
overwrites the old value.
key_to_oid(Index, Key) -> KeyOid
Types:
Index = index()
Key = key()
KeyOid = NextKeyOid = oid()
Converts Key to an OBJECT IDENTIFIER.
new(KeyTypes) -> Index
Types:
KeyTypes = key_types()
Index = index()
Creates a new snmp index structure. The key_types() type is described above.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 165
snmp_notification_mib
snmp_notification_mib
Erlang module
The module snmp_notification_mib implements the instrumentation functions for the SNMPNOTIFICATION-MIB, and functions for configuring the database.
The configuration files are described in the SNMP User's Manual.
Exports
configure(ConfDir) -> void()
Types:
ConfDir = string()
This function is called from the supervisor at system start-up.
Inserts all data in the configuration files into the database and destroys all old rows with StorageType volatile.
The rows created from the configuration file will have StorageType nonVolatile.
If an error is found in the configuration file, it is reported using the function config_err/2 of the error report
module, and the function fails with reason configuration_error.
ConfDir is a string which points to the directory where the configuration files are found.
The configuration file read is: notify.conf.
reconfigure(ConfDir) -> void()
Types:
ConfDir = string()
Inserts all data in the configuration files into the database and destroys all old data, including the rows with StorageType
nonVolatile. The rows created from the configuration file will have StorageType nonVolatile.
Thus, the data in the SNMP-NOTIFICATION-MIB, after this function has been called, is from the configuration files.
If an error is found in the configuration file, it is reported using the function config_err/2 of the error report
module, and the function fails with reason configuration_error.
ConfDir is a string which points to the directory where the configuration files are found.
The configuration file read is: notify.conf.
add_notify(Name, Tag, Type) -> Ret
Types:
Name = string()
Tag = string()
Type = trap | inform
Ret = {ok, Key} | {error, Reason}
Key = term()
Reason = term()
Adds a notify definition to the agent config. Equivalent to one line in the notify.conf file.
166 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmp_notification_mib
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 167
snmp_pdus
snmp_pdus
Erlang module
RFC1157, RFC1905 and/or RFC2272 should be studied carefully before using this module, snmp_pdus.
The module snmp_pdus contains functions for encoding and decoding of SNMP protocol data units (PDUs). In short,
this module converts a list of bytes to Erlang record representations and vice versa. The record definitions can be found
in the file snmp/include/snmp_types.hrl. If snmpv3 is used, the module that includes snmp_types.hrl
must define the constant SNMP_USE_V3 before the header file is included. Example:
-define(SNMP_USE_V3, true).
-include_lib("snmp/include/snmp_types.hrl").
Encoding and decoding must be done explicitly when writing your own Net if process.
Exports
dec_message([byte()]) -> Message
Types:
Message = #message
Decodes a list of bytes into an SNMP Message. Note, if there is a v3 message, the msgSecurityParameters
are not decoded. They must be explicitly decoded by a call to a security model specific decoding function,
e.g. dec_usm_security_parameters/1. Also note, if the scopedPDU is encrypted, the OCTET STRING
encoded encryptedPDU will be present in the data field.
dec_message_only([byte()]) -> Message
Types:
Message = #message
Decodes a list of bytes into an SNMP Message, but does not decode the data part of the Message. That means, data is
still a list of bytes, normally an encoded PDU (v1 and V2) or an encoded and possibly encrypted scopedPDU (v3).
dec_pdu([byte()]) -> Pdu
Types:
Pdu = #pdu
Decodes a list of bytes into an SNMP Pdu.
dec_scoped_pdu([byte()]) -> ScopedPdu
Types:
ScopedPdu = #scoped_pdu
Decodes a list of bytes into an SNMP ScopedPdu.
dec_scoped_pdu_data([byte()]) -> ScopedPduData
Types:
ScopedPduData = #scoped_pdu | EncryptedPDU
168 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmp_pdus
EncryptedPDU = [byte()]
Decodes a list of bytes into either a scoped pdu record, or - if the scoped pdu was encrypted - to a list of bytes.
dec_usm_security_parameters([byte()]) -> UsmSecParams
Types:
UsmSecParams = #usmSecurityParameters
Decodes a list of bytes into an SNMP UsmSecurityParameters
enc_encrypted_scoped_pdu(EncryptedScopedPdu) -> [byte()]
Types:
EncryptedScopedPdu = [byte()]
Encodes an encrypted SNMP ScopedPdu into an OCTET STRING that can be used as the data field in a message
record, that later can be encoded with a call to enc_message_only/1.
This function should be used whenever the ScopedPDU is encrypted.
enc_message(Message) -> [byte()]
Types:
Message = #message
Encodes a message record to a list of bytes.
enc_message_only(Message) -> [byte()]
Types:
Message = #message
Message is a record where the data field is assumed to be encoded (a list of bytes). If there is a v1 or v2 message, the
data field is an encoded PDU, and if there is a v3 message, data is an encoded and possibly encrypted scopedPDU.
enc_pdu(Pd) -> [byte()]
Types:
Pdu = #pdu
Encodes an SNMP Pdu into a list of bytes.
enc_scoped_pdu(ScopedPdu) -> [byte()]
Types:
ScopedPdu = #scoped_pdu
Encodes an SNMP ScopedPdu into a list of bytes, which can be encrypted, and after encryption, encoded with a call
to enc_encrypted_scoped_pdu/1; or it can be used as the data field in a message record, which then can
be encoded with enc_message_only/1.
enc_usm_security_parameters(UsmSecParams) -> [byte()]
Types:
UsmSecParams = #usmSecurityParameters
Encodes SNMP UsmSecurityParameters into a list of bytes.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 169
snmp_standard_mib
snmp_standard_mib
Erlang module
The module snmp_standard_mib implements the instrumentation functions for the STANDARD-MIB and
SNMPv2-MIB, and functions for configuring the database.
The configuration files are described in the SNMP User's Manual.
Exports
configure(ConfDir) -> void()
Types:
ConfDir = string()
This function is called from the supervisor at system start-up.
Inserts all data in the configuration files into the database and destroys all old rows with StorageType volatile.
The rows created from the configuration file will have StorageType nonVolatile.
All snmp counters are set to zero.
If an error is found in the configuration file, it is reported using the function config_err/2 of the error report
module, and the function fails with the reason configuration_error.
ConfDir is a string which points to the directory where the configuration files are found.
The configuration file read is: standard.conf.
inc(Name) -> void()
inc(Name, N) -> void()
Types:
Name = atom()
N = integer()
Increments a variable in the MIB with N, or one if N is not specified.
reconfigure(ConfDir) -> void()
Types:
ConfDir = string()
Inserts all data in the configuration files into the database and destroys all old data, including the rows with StorageType
nonVolatile. The rows created from the configuration file will have StorageType nonVolatile.
Thus, the data in the SNMP-STANDARD-MIB and SNMPv2-MIB, after this function has been called, is from the
configuration files.
All snmp counters are set to zero.
If an error is found in the configuration file, it is reported using the function config_err/2 of the error report
module, and the function fails with the reason configuration_error.
ConfDir is a string which points to the directory where the configuration files are found.
The configuration file read is: standard.conf.
170 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmp_standard_mib
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 171
snmp_target_mib
snmp_target_mib
Erlang module
The module snmp_target_mib implements the instrumentation functions for the SNMP-TARGET-MIB, and
functions for configuring the database.
The configuration files are described in the SNMP User's Manual.
Legacy API functions add_addr/10 that does not specify transport domain, and add_addr/11 that has got
separate IpAddr and PortNumber arguments still work as before for backwards compatibility reasons.
DATA TYPES
See the data types in snmpa_conf.
Exports
configure(ConfDir) -> void()
Types:
ConfDir = string()
This function is called from the supervisor at system start-up.
Inserts all data in the configuration files into the database and destroys all old rows with StorageType volatile.
The rows created from the configuration file will have StorageType nonVolatile.
All snmp counters are set to zero.
If an error is found in the configuration file, it is reported using the function config_err/2 of the error report
module, and the function fails with the reason configuration_error.
ConfDir is a string which points to the directory where the configuration files are found.
The configuration files read are: target_addr.conf and target_params.conf.
reconfigure(ConfDir) -> void()
Types:
ConfDir = string()
Inserts all data in the configuration files into the database and destroys all old data, including the rows with StorageType
nonVolatile. The rows created from the configuration file will have StorageType nonVolatile.
Thus, the data in the SNMP-TARGET-MIB, after this function has been called, is the data from the configuration files.
All snmp counters are set to zero.
If an error is found in the configuration file, it is reported using the function config_err/2 of the , and the function
fails with the reason configuration_error.
ConfDir is a string which points to the directory where the configuration files are found.
The configuration files read are: target_addr.conf and target_params.conf.
set_target_engine_id(TargetAddrName, EngineId) -> boolean()
Types:
TargetAddrName = string()
172 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmp_target_mib
EngineId = string()
Changes the engine id for a target in the snmpTargetAddrTable. If notifications are sent as Inform requests to
a target, its engine id must be set.
add_addr(Name, Domain, Addr, Timeout, Retry, TagList, Params, EngineId,
TMask, MMS) -> Ret
Types:
Name = string()
Domain = transportDomain()
Addr = transportAddress() % Default port is 162
Timeout = integer()
Retry = integer()
TagList = string()
ParamsName = string()
EngineId = string()
TMask = transportAddressMask() % Depends on Domain
MMS = integer()
Ret = {ok, Key} | {error, Reason}
Key = term()
Reason = term()
Adds a target address definition to the agent config. Equivalent to one line in the target_addr.conf file.
delete_addr(Key) -> Ret
Types:
Key = term()
Ret = ok | {error, Reason}
Reason = term()
Delete a target address definition from the agent config.
add_params(Name, MPModel, SecModel, SecName, SecLevel) -> Ret
Types:
Name = string()
MPModel = v1 | v2c | v3
SecModel = v1 | v2c | usm
SecName = string()
SecLevel = noAuthNoPriv | authNoPriv | authPriv
Ret = {ok, Key} | {error, Reason}
Key = term()
Reason = term()
Adds a target parameter definition to the agent config. Equivalent to one line in the target_params.conf file.
delete_params(Key) -> Ret
Types:
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 173
snmp_target_mib
Key = term()
Ret = ok | {error, Reason}
Reason = term()
Delete a target parameter definition from the agent config.
174 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmp_user_based_sm_mib
snmp_user_based_sm_mib
Erlang module
The module snmp_user_based_sm_mib implements the instrumentation functions for the SNMP-USERBASED-SM-MIB, and functions for configuring the database.
The configuration files are described in the SNMP User's Manual.
Exports
configure(ConfDir) -> void()
Types:
ConfDir = string()
This function is called from the supervisor at system start-up.
Inserts all data in the configuration files into the database and destroys all old rows with StorageType volatile.
The rows created from the configuration file will have StorageType nonVolatile.
All snmp counters are set to zero.
If an error is found in the configuration file, it is reported using the function config_err/2 of the error report
module, and the function fails with the reason configuration_error.
ConfDir is a string which points to the directory where the configuration files are found.
The configuration file read is: usm.conf.
reconfigure(ConfDir) -> void()
Types:
ConfDir = string()
Inserts all data in the configuration files into the database and destroys all old data, including the rows with StorageType
nonVolatile. The rows created from the configuration file will have StorageType nonVolatile.
Thus, the data in the SNMP-USER-BASED-SM-MIB, after this function has been called, is the data from the
configuration files.
All snmp counters are set to zero.
If an error is found in the configuration file, it is reported using the function config_err/2 of the error report
module, and the function fails with the reason configuration_error.
ConfDir is a string which points to the directory where the configuration files are found.
The configuration file read is: usm.conf.
add_user(EngineID, Name, SecName, Clone, AuthP, AuthKeyC, OwnAuthKeyC, PrivP,
PrivKeyC, OwnPrivKeyC, Public, AuthKey, PrivKey) -> Ret
Types:
EngineID = string()
Name = string()
SecName = string()
Clone = zeroDotZero | [integer()]
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 175
snmp_user_based_sm_mib
176 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmp_view_based_acm_mib
snmp_view_based_acm_mib
Erlang module
The module snmp_view_based_acm_mib implements the instrumentation functions for the SNMP-VIEWBASED-ACM-MIB, and functions for configuring the database.
The configuration files are described in the SNMP User's Manual.
Exports
configure(ConfDir) -> void()
Types:
ConfDir = string()
This function is called from the supervisor at system start-up.
Inserts all data in the configuration files into the database and destroys all old rows with StorageType volatile.
The rows created from the configuration file will have StorageType nonVolatile.
All snmp counters are set to zero.
If an error is found in the configuration file, it is reported using the function config_err/2 of the error report
module, and the function fails with the reason configuration_error.
ConfDir is a string which points to the directory where the configuration files are found.
The configuration file read is: vacm.conf.
reconfigure(ConfDir) -> void()
Types:
ConfDir = string()
Inserts all data in the configuration files into the database and destroys all old data, including the rows with StorageType
nonVolatile. The rows created from the configuration file will have StorageType nonVolatile.
Thus, the data in the SNMP-VIEW-BASED-ACM-MIB, after this function has been called, is the data from the
configuration files.
All snmp counters are set to zero.
If an error is found in the configuration file, it is reported using the function config_err/2 of the error report module,
and the function fails with the reason configuration_error.
ConfDir is a string which points to the directory where the configuration files are found.
The configuration file read is: vacm.conf.
add_sec2group(SecModel, SecName, GroupName) -> Ret
Types:
SecModel = v1 | v2c | usm
SecName = string()
GroupName = string()
Ret = {ok, Key} | {error, Reason}
Key = term()
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 177
snmp_view_based_acm_mib
Reason = term()
Adds a security to group definition to the agent config. Equivalent to one vacmSecurityToGroup-line in the
vacm.conf file.
delete_sec2group(Key) -> Ret
Types:
Key = term()
Ret = ok | {error, Reason}
Reason = term()
Delete a security to group definition from the agent config.
add_access(GroupName, Prefix, SecModel, SecLevel, Match, RV, WV, NV) -> Ret
Types:
GroupName = string()
Prefix = string()
SecModel = v1 | v2c | usm
SecLevel = string()
Match = prefix | exact
RV = string()
WV = string()
NV = string()
Ret = {ok, Key} | {error, Reason}
Key = term()
Reason = term()
Adds a access definition to the agent config. Equivalent to one vacmAccess-line in the vacm.conf file.
delete_access(Key) -> Ret
Types:
Key = term()
Ret = ok | {error, Reason}
Reason = term()
Delete a access definition from the agent config.
add_view_tree_fam(ViewIndex, SubTree, Status, Mask) -> Ret
Types:
ViewIndex = integer()
SubTree = oid()
Status = included | excluded
Mask = null | [integer()], where all values are either 0 or 1
Ret = {ok, Key} | {error, Reason}
Key = term()
Reason = term()
178 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmp_view_based_acm_mib
Adds a view tree family definition to the agent config. Equivalent to one vacmViewTreeFamily-line in the
vacm.conf file.
delete_view_tree_fam(Key) -> Ret
Types:
Key = term()
Ret = ok | {error, Reason}
Reason = term()
Delete a view tree family definition from the agent config.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 179
snmpc
snmpc
Erlang module
The module snmpc contains interface functions to the SNMP toolkit MIB compiler.
Exports
compile(File)
compile(File, Options) -> {ok, BinFileName} | {error, Reason}
Types:
File = string()
Options = [opt()]
opt() = db() | relaxed_row_name_assign_check() | deprecated() |
description() | reference() | group_check() | i() | il() | imports() |
module() | module_identity() | module_compliance() | agent_capabilities()
| outdir() | no_defs() | verbosity() | warnings() | warnings_as_errors()
db() = {db, volatile|persistent|mnesia}
deprecated() = {deprecated, bool()}
relaxed_row_name_assign_check() = relaxed_row_name_assign_check
description() = description
reference() = reference
group_check() = {group_check, bool()}
i() = {i, [dir()]}
il() = {il, [dir()]}
imports() = imports
module() = {module, atom()}
module_identity() = module_identity
module_compliance() = module_compliance
agent_capabilities() = agent_capabilities
no_defs() = no_defs
outdir() = {outdir, dir()}
verbosity() = {verbosity, silence|warning|info|log|debug|trace}
warnings() = {warnings, bool()}
warnings_as_errors() = warnings_as_errors
dir() = string()
BinFileName = string()
Compiles the specified MIB file <File>.mib. The compiled file BinFileName is called <File>.bin.
The option db specifies which database should be used for the default instrumentation.
Default is volatile.
The option deprecated specifies if a deprecated definition should be kept or not. If the option is false the MIB
compiler will ignore all deprecated definitions.
Default is true.
180 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpc
The option relaxed_row_name_assign_check, if present, specifies that the row name assign check shall
not be done strictly according to the SMI (which allows only the value 1). With this option, all values greater than
zero is allowed (>= 1). This means that the error will be converted to a warning.
By default it is not included, but if this option is present it will be.
The option description specifies if the text of the DESCRIPTION field will be included or not.
By default it is not included, but if this option is present it will be.
The option reference specifies if the text of the REFERENCE field, when found in a table definition, will
be included or not.
By default it is not included, but if this option is present it will be. The reference text will be placed in the allocList
field of the mib-entry record (#me{}) for the table.
The option group_check specifies whether the mib compiler should check the OBJECT-GROUP macro and
the NOTIFICATION-GROUP macro for correctness or not.
Default is true.
The option i specifies the path to search for imported (compiled) MIB files. The directories should be strings
with a trailing directory delimiter.
Default is ["./"].
The option il (include_lib) also specifies a list of directories to search for imported MIBs. It assumes that the
first element in the directory name corresponds to an OTP application. The compiler will find the current installed
version. For example, the value ["snmp/mibs/"] will be replaced by ["snmp-3.1.1/mibs/"] (or what the current
version may be in the system). The current directory and the <snmp-home>/priv/mibs/ are always listed
last in the include path.
The option imports, if present, specifies that the IMPORT statement of the MIB shall be included in the
compiled mib.
The option module, if present, specifies the name of a module which implements all instrumentation functions
for the MIB.
The name of all instrumentation functions must be the same as the corresponding managed object it implements.
The option module_identity, if present, specifies that the info part of the MODULE-IDENTITY statement
of the MIB shall be included in the compiled mib.
The option module_compliance, if present, specifies that the MODULE-COMPLIANCE statement of the
MIB shall be included (with a mib-entry record) in the compiled mib. The mib-entry record of the modulecompliance will contain reference and module part(s) this info in the assocList field).
The option agent_capabilities, if present, specifies that the AGENT-CAPABILITIES statement of the
MIB shall be included (with a mib-entry record) in the compiled mib. The mib-entry record of the agent-capabilitie
will contain reference and modules part(s) this info in the assocList field).
The option no_defs, if present, specifies that if a managed object does not have an instrumentation function,
the default instrumentation function should NOT be used, instead this is reported as an error, and the compilation
aborts.
The option verbosity specifies the verbosity of the SNMP mib compiler. I.e. if warning, info, log, debug and
trace messages shall be shown.
Default is silence.
Note that if the option warnings is true and the option verbosity is silence, warning messages will
still be shown.
The option warnings specifies whether warning messages should be shown.
Default is true.
The option warnings_as_errors, if present, specifies whether warnings should be treated as errors.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 181
snmpc
The MIB compiler understands both SMIv1 and SMIv2 MIBs. It uses the MODULE-IDENTITY statement to determine
if the MIB is version 1 or 2.
The MIB compiler can be invoked from the OS command line by using the command erlc. erlc recognizes the
extension .mib, and invokes the SNMP MIB compiler for files with that extension. The options db, group_check,
deprecated, description, verbosity, imports and module_identity have to be specified to erlc
using the syntax +term. See erlc(1) for details.
is_consistent(Mibs) -> ok | {error, Reason}
Types:
Mibs = [MibName]
MibName = string()
Checks for multiple usage of object identifiers and traps between MIBs.
mib_to_hrl(MibName) -> ok | {error, Reason}
Types:
MibName = string()
Generates a .hrl file with definitions of Erlang constants for the objects in the MIB. The .hrl file is called
<MibName>.hrl. The MIB must be compiled, and present in the current directory.
The mib_to_hrl generator can be invoked from the OS command line by using the command erlc. erlc
recognizes the extension .bin, and invokes this function for files with that extension.
See Also
erlc(1)
182 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpc(command)
snmpc(command)
Command
The snmpc program provides a way to run the SNMP MIB compiler of the Erlang system.
Exports
snmpc [options] file.mib | file.bin
snmpc compile a SNMP MIB file, see compile/1,2 for more info.
It can also be used to generate a header file (.hrl) with definitions of Erlang constants for the objects in the MIB, see
mib_to_hrl/1.
Compiler options
The following options are supported (note that most of these relate to the compilation of the MIB file):
--help
Prints help info.
--version
Prints application and mib format version.
--verbosity verbosity
Print debug info.
verbosity = trace | debug | log | info | silence
Defaults to silence.
--warnings | --W
Print warning messages.
--wae | --Werror
Warnings as errors. Indicates that warnings shall be treated as errors.
--o directory
The directory where the compiler should place the output files. If not specified, output files will be placed in the
current working directory.
--i Directory
Specifies the path to search for imported (compiled) MIB files. By default, the current working directory is always
included.
This option can be present several times, each time specifying one path.
--il Directory
This option (include_lib), specifies a list of directories to search for imported MIBs. It assumes that the first
element in the directory name corresponds to an OTP application. The compiler will find the current installed
version. For example, the value ["snmp/mibs/"] will be replaced by ["snmp-3.1.1/mibs/"] (or what the current
version may be in the system). The current directory and the "snmp-home"/priv/mibs/ are always listed last in
the include path.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 183
snmpc(command)
--sgc
This option (skip group check), if present, disables the group check of the mib compiler. That is, should the
OBJECT-GROUP and the NOTIFICATION-GROUP macro(s) be checked for correctness or not.
--dep
Keep deprecated definition(s). If not specified the compiler will ignore deprecated definitions.
--desc
The DESCRIPTION field will be included.
--ref
The REFERENCE field will be included.
--imp
The IMPORTS field will be included.
--mi
The MODULE-IDENTITY field will be included.
--mc
The MODULE-COMPLIANCE field will be included.
--ac
The AGENT-CAPABILITIES field will be included.
--mod module
The module which implements all the instrumentation functions.
The name of all instrumentation functions must be the same as the corresponding managed object it implements.
--nd
The default instrumentation functions will not be used if a managed object have no instrumentation function.
Instead this will be reported as an error, and the compilation aborts.
--rrnac
This option, if present, specifies that the row name assign check shall not be done strictly according to the SMI
(which allows only the value 1).
With this option, all values greater than zero is allowed (>= 1). This means that the error will be converted to
a warning.
By default it is not included, but if this option is present it will be.
SEE ALSO
erlc(1), compile(3), snmpc(3)
184 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpm
snmpm
Erlang module
oid() = [byte()] - The oid() type is used to represent an ASN.1 OBJECT IDENTIFIER
snmp_reply() = {error_status(), error_index(), varbinds()}
error_status() = noError | atom()
error_index() = integer()
varbinds() = [varbind()]
atl_type() = read | write | read_write
target_name() = string() - Is a unique *non-empty* string
vars_and_vals() = [var_and_val()]
var_and_val() = {oid(), value_type(), value()} | {oid(), value()}
value_type() = o ('OBJECT IDENTIFIER') |
i ('INTEGER') |
u ('Unsigned32') |
g ('Unsigned32') |
s ('OCTET SRING') |
b ('BITS') |
ip ('IpAddress') |
op ('Opaque') |
c32 ('Counter32') |
c64 ('Counter64') |
tt ('TimeTicks')
value() = term()
community() = string()
sec_model() = any | v1 | v2c | usm
sec_name() = string()
sec_level() = noAuthNoPriv | authNoPriv | authPriv
Exports
monitor() -> Ref
Types:
Ref = reference()
Monitor the SNMP manager. In case of a crash, the calling (monitoring) process will get a 'DOWN' message (see the
erlang module for more info).
demonitor(Ref) -> void()
Types:
Ref = reference()
Turn off monitoring of the SNMP manager.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 185
snmpm
During the start of a system, when a client application could start prior to the SNMP manager but is dependent
upon it, and therefor has to wait for it to start.
When the SNMP manager has crashed, the dependent client application has to wait for the SNMP manager to be
restarted before it can reconnect.
The function returns the pid() of a handler process, that does the supervision on behalf of the client application. Note
that the client application is linked to this handler.
This function is used in conjunction with the monitor function.
cancel_notify_started(Pid) -> void()
Types:
Pid = pid()
Cancel a previous request to be notified of SNMP manager start.
register_user(Id, Module, Data) -> ok | {error, Reason}
register_user(Id, Module, Data, DefaultAgentConfig) -> ok | {error, Reason}
Types:
Id = term()
Module = snmpm_user()
Data = term()
DefaultAgentConfig = [default_agent_config()]
default_agent_config() = {Item, Val}
Item = community | timeout | max_message_size | version | sec_model |
sec_name | sec_level
Val = term()
Reason = term()
snmpm_user() = Module implementing the snmpm_user behaviour
Register the manager entity (=user) responsible for specific agent(s).
Module is the callback module (snmpm_user behaviour) which will be called whenever something happens (detected
agent, incoming reply or incoming trap/notification). Note that this could have already been done as a consequence
of the node config. (see users.conf).
The argument DefaultAgentConfig is used as default values when this user register agents.
The type of Val depends on Item:
186 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpm
community = string()
timeout = integer() | snmp_timer()
max_message_size = integer()
version = v1 | v2 | v3
sec_model = any | v1 | v2c | usm
sec_name = string()
sec_level = noAuthNoPriv | authNoPriv | authPriv
community = string()
timeout = integer() | snmp_timer()
max_message_size = integer()
version = v1 | v2 | v3
sec_model = any | v1 | v2c | usm
sec_name = string()
sec_level = noAuthNoPriv | authNoPriv | authPriv
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 187
snmpm
[mandatory]
[mandatory]
[optional]
[optional]
[optional]
[optional]
[optional]
[optional]
[optional]
[optional]
[optional]
engine_id = string()
tadress = transportAddress() % Depends on tdomain
port = inet:port_number()
tdomain = transportDomain()
community = string()
timeout = integer() | snmp_timer()
max_message_size = integer()
version = v1 | v2 | v3
sec_model = any | v1 | v2c | usm
sec_name = string()
sec_level = noAuthNoPriv | authNoPriv | authPriv
188 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpm
TargetName = target_name()
Item = atom()
Reason = term()
Retrieve agent config.
update_agent_info(UserId, TargetName, Info) -> ok | {error, Reason}
update_agent_info(UserId, TargetName, Item, Val) -> ok | {error, Reason}
Types:
UserId = term()
TargetName = target_name()
Info = [{item(), item_value()}]
Item = item()
item() = atom()
Val = item_value()
item_value() = term()
Reason = term()
Update agent config. The function update_agent_info/3 should be used when several values needs to be
updated atomically.
See function register_agent for more info about what kind of items are allowed.
which_agents() -> Agents
which_agents(UserId) -> Agents
Types:
UserId = term()
Agents = [TargetName]
TargetName = target_name()
Get a list of all registered agents or all agents registered by a specific user.
register_usm_user(EngineID, UserName, Conf) -> ok | {error, Reason}
Types:
EngineID = string()
UserName = string()
Conf = [usm_config()]
usm_config() = {Item, Val}
Item = sec_name | auth | auth_key | priv | priv_key
Val = term()
Reason = term()
Explicitly instruct the manager to handle this USM user. Note that there is an alternate way to do the same thing: Add
the usm user to the manager config files (see usm.conf).
The type of Val depends on Item:
sec_name = string()
auth = usmNoAuthProtocol | usmHMACMD5AuthProtocol | usmHMACSHAAuthProtocoltimeout
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 189
snmpm
auth_key = [integer()]
190 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpm
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 191
snmpm
192 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpm
SendOpts = send_opts()
send_opts() = [send_opt()]
send_opt() = {context, string()} | {timeout, pos_integer()} | {extra,
term()} | {community, community()} | {sec_model, sec_model()} | {sec_name,
string()} | {sec_level, sec_level()} | {max_message_size, pos_integer()}
ReqId = term()
Reason = term()
Asynchronous get-request.
The reply, if it arrives, will be delivered to the user through a call to the snmpm_user callback function handle_pdu.
The send option timeout specifies for how long the request is valid (after which the manager is free to delete it).
The send option extra specifies an opaque data structure passed on to the net-if process. The net-if process included
in this application makes, with one exception, no use of this info, so the only use for it in such a option (when using
the built in net-if) would be tracing. The one usage exception is: Any tuple with snmpm_extra_info_tag as its
first element is reserved for internal use.
Some of the send options (community, sec_model, sec_name, sec_level and max_message_size) are
override options. That is, for this request, they override any configuration done when the agent was registered.
async_get(UserId, TargetName,
async_get(UserId, TargetName,
Reason}
async_get(UserId, TargetName,
async_get(UserId, TargetName,
{error, Reason}
async_get(UserId, TargetName,
ReqId} | {error, Reason}
Types:
UserId = term()
TargetName = target_name()
ContextName = string()
Oids = [oid()]
Expire = integer()
ExtraInfo = term()
ReqId = term()
Reason = term()
Asynchronous get-request.
The reply, if it arrives, will be delivered to the user through a call to the snmpm_user callback function handle_pdu.
The Expire time indicates for how long the request is valid (after which the manager is free to delete it).
ExtraInfo is an opaque data structure passed on to the net-if process. The net-if process included in this application
makes, with one exception, no use of this info, so the only use for it in such a configuration (when using the built in
net-if) would be tracing. The one usage exception is: Any tuple with snmpm_extra_info_tag as its first element
is reserved for internal use.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 193
snmpm
194 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpm
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 195
snmpm
The reply will be delivered to the user through a call to the snmpm_user callback function handle_pdu.
The send option timeout specifies for how long the request is valid (after which the manager is free to delete it).
The send option extra specifies an opaque data structure passed on to the net-if process. The net-if process included
in this application makes, with one exception, no use of this info, so the only use for it in such a option (when using
the built in net-if) would be tracing. The one usage exception is: Any tuple with snmpm_extra_info_tag as its
first element is reserved for internal use.
Some of the send options (community, sec_model, sec_name, sec_level and max_message_size) are
override options. That is, for this request, they override any configuration done when the agent was registered.
async_get_next(UserId, TargetName,
async_get_next(UserId, TargetName,
{error, Reason}
async_get_next(UserId, TargetName,
Reason}
async_get_next(UserId, TargetName,
| {error, Reason}
async_get_next(UserId, TargetName,
{ok, ReqId} | {error, Reason}
Types:
UserId = term()
TargetName = target_name()
ContextName = string()
Oids = [oid()]
Expire = integer()
ExtraInfo = term()
ReqId = integer()
Reason = term()
Asynchronous get-next-request.
The reply will be delivered to the user through a call to the snmpm_user callback function handle_pdu.
The Expire time indicates for how long the request is valid (after which the manager is free to delete it).
ExtraInfo is an opaque data structure passed on to the net-if process. The net-if process included in this application
makes, with one exception, no use of this info, so the only use for it in such a configuration (when using the built in
net-if) would be tracing. The one usage exception is: Any tuple with snmpm_extra_info_tag as its first element
is reserved for internal use.
sync_set2(UserId, TargetName, VarsAndVals) -> {ok, SnmpReply, Remaining} |
{error, Reason}
sync_set2(UserId, TargetName, VarsAndVals, SendOpts) -> {ok, SnmpReply,
Remaining} | {error, Reason}
Types:
UserId = term()
TargetName = target_name()
VarsAndVals = vars_and_vals()
SendOpts = send_opts()
196 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpm
send_opts() = [send_opt()]
send_opt() = {context, string()} | {timeout, pos_integer()} | {extra,
term()} | {community, community()} | {sec_model, sec_model()} | {sec_name,
string()} | {sec_level, sec_level()} | {max_message_size, pos_integer()}
SnmpReply = snmp_reply()
Remaining = integer()
Reason = {send_failed, ReqId, ActualReason} | {invalid_sec_info, SecInfo,
SnmpInfo} | term()
ReqId = term()
ActualReason = term()
SecInfo = [sec_info()]
sec_info() = {sec_tag(), ExpectedValue, ReceivedValue}
sec_tag() = atom()
ExpectedValue = ReceivedValue = term()
SnmpInfo = term()
Synchronous set-request.
Remaining is the remaining time of the given (or default) timeout time.
When Reason is {send_failed, ...} it means that the net_if process failed to send the message. This could happen because
of any number of reasons, i.e. encoding error. ActualReason is the actual reason in this case.
When var_and_val() is {oid(), value()}, the manager makes an educated guess based on the loaded mibs.
The send option extra specifies an opaque data structure passed on to the net-if process. The net-if process included
in this application makes, with one exception, no use of this info, so the only use for it in such a option (when using
the built in net-if) would be tracing. The one usage exception is: Any tuple with snmpm_extra_info_tag as its
first element is reserved for internal use.
Some of the send options (community, sec_model, sec_name, sec_level and max_message_size) are
override options. That is, for this request, they override any configuration done when the agent was registered.
For SnmpInfo, see the user callback function handle_report.
sync_set(UserId, TargetName, VarsAndVals) -> {ok, SnmpReply, Remaining} |
{error, Reason}
sync_set(UserId, TargetName, ContextName, VarsAndVals) -> {ok, SnmpReply,
Remaining} | {error, Reason}
sync_set(UserId, TargetName, VarsAndVals, Timeout) -> {ok, SnmpReply,
Remaining} | {error, Reason}
sync_set(UserId, TargetName, ContextName, VarsAndVals, Timeout) -> {ok,
SnmpReply, Remaining} | {error, Reason}
sync_set(UserId, TargetName, ContextName, VarsAndVals, Timeout, ExtraInfo) ->
{ok, SnmpReply, Remaining} | {error, Reason}
Types:
UserId = term()
TargetName = target_name()
ContextName = string()
VarsAndVals = vars_and_vals()
Timeout = integer()
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 197
snmpm
ExtraInfo = term()
SnmpReply = snmp_reply()
Remaining = integer()
Reason = {send_failed, ReqId, ActualReason} | {invalid_sec_info, SecInfo,
SnmpInfo} | term()
ActualReason = term()
Synchronous set-request.
Remaining time of the given or default timeout time.
When Reason is {send_failed, ...} it means that the net_if process failed to send the message. This could happen because
of any number of reasons, i.e. encoding error. R is the actual reason in this case.
When var_and_val() is {oid(), value()}, the manager makes an educated guess based on the loaded mibs.
ExtraInfo is an opaque data structure passed on to the net-if process. The net-if process included in this application
makes, with one exception, no use of this info, so the only use for it in such a configuration (when using the built in
net-if) would be tracing. The one usage exception is: Any tuple with snmpm_extra_info_tag as its first element
is reserved for internal use.
async_set2(UserId, TargetName, VarsAndVals) -> {ok, ReqId} | {error, Reason}
async_set2(UserId, TargetName, VarsAndVals, SendOpts) -> {ok, ReqId} |
{error, Reason}
Types:
UserId = term()
TargetName = target_name()
VarsAndVals = vars_and_vals()
SendOpts = send_opts()
send_opts() = [send_opt()]
send_opt() = {context, string()} | {timeout, pos_integer()} | {extra,
term()} | {community, community()} | {sec_model, sec_model()} | {sec_name,
string()} | {sec_level, sec_level()} | {max_message_size, pos_integer()}
ReqId = term()
Reason = term()
Asynchronous set-request.
The reply will be delivered to the user through a call to the snmpm_user callback function handle_pdu.
The send option timeout specifies for how long the request is valid (after which the manager is free to delete it).
When var_and_val() is {oid(), value()}, the manager makes an educated guess based on the loaded mibs.
The send option extra specifies an opaque data structure passed on to the net-if process. The net-if process included
in this application makes, with one exception, no use of this info, so the only use for it in such a option (when using
the built in net-if) would be tracing. The one usage exception is: Any tuple with snmpm_extra_info_tag as its
first element is reserved for internal use.
Some of the send options (community, sec_model, sec_name, sec_level and max_message_size) are
override options. That is, for this request, they override any configuration done when the agent was registered.
198 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpm
Asynchronous set-request.
The reply will be delivered to the user through a call to the snmpm_user callback function handle_pdu.
The Expire time indicates for how long the request is valid (after which the manager is free to delete it).
When var_and_val() is {oid(), value()}, the manager makes an educated guess based on the loaded mibs.
ExtraInfo is an opaque data structure passed on to the net-if process. The net-if process included in this application
makes, with one exception, no use of this info, so the only use for it in such a configuration (when using the built in
net-if) would be tracing. The one usage exception is: Any tuple with snmpm_extra_info_tag as its first element
is reserved for internal use.
sync_get_bulk2(UserId, TragetName, NonRep, MaxRep, Oids) -> {ok, SnmpReply,
Remaining} | {error, Reason}
sync_get_bulk2(UserId, TragetName, NonRep, MaxRep, Oids, SendOpts) -> {ok,
SnmpReply, Remaining} | {error, Reason}
Types:
UserId = term()
TargetName = target_name()
NonRep = integer()
MaxRep = integer()
Oids = [oid()]
SendOpts = send_opts()
send_opts() = [send_opt()]
send_opt() = {context, string()} | {timeout, pos_integer()} | {extra,
term()} | {community, community()} | {sec_model, sec_model()} | {sec_name,
string()} | {sec_level, sec_level()} | {max_message_size, pos_integer()}
SnmpReply = snmp_reply()
Remaining = integer()
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 199
snmpm
200 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpm
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 201
snmpm
202 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpm
log_to_txt(LogDir)
log_to_txt(LogDir, Block | Mibs)
log_to_txt(LogDir, Mibs, Block | OutFile) -> ok | {error, Reason}
log_to_txt(LogDir, Mibs, OutFile, Block | LogName) -> ok | {error, Reason}
log_to_txt(LogDir, Mibs, OutFile, LogName, Block | LogFile) -> ok | {error,
Reason}
log_to_txt(LogDir, Mibs, OutFile, LogName, LogFile, Block | Start) -> ok |
{error, Reason}
log_to_txt(LogDir, Mibs, OutFile, LogName, LogFile, Block, Start) -> ok |
{error, Reason}
log_to_txt(LogDir, Mibs, OutFile, LogName, LogFile, Start, Stop) -> ok |
{error, Reason}
log_to_txt(LogDir, Mibs, OutFile, LogName, LogFile, Block, Start, Stop) -> ok
| {error, Reason}
Types:
LogDir = string()
Mibs = [MibName]
MibName = string()
Block = boolean()
OutFile = string()
LogName = string()
LogFile = string()
Start = Stop = null | calendar:datetime() | {local_time,
calendar:datetime()} | {universal_time, calendar:datetime()}
Reason = disk_log_open_error() | file_open_error() | term()
disk_log_open_error() = {LogName, term()}
file_open_error() = {OutFile, term()}
Converts an Audit Trail Log to a readable text file. OutFile defaults to "./snmpm_log.txt". LogName defaults to
"snmpm_log". LogFile defaults to "snmpm.log".
The Block argument indicates if the log should be blocked during conversion. This could be usefull when converting
large logs (when otherwise the log could wrap during conversion). Defaults to true.
See snmp:log_to_txt for more info.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 203
snmpm
204 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpm
Reason = term()
Changes the run-time Audit Trail log type.
Note that this has no effect on the application configuration as defined by configuration files, so a node restart will
revert the config to whatever is in those files.
This function is primarily useful in testing/debugging scenarios.
load_mib(Mib) -> ok | {error, Reason}
Types:
Mib = MibName
MibName = string()
Reason = term()
Load a Mib into the manager. The MibName is the name of the Mib, including the path to where the compiled mib
is found. For example,
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 205
snmpm
Note that an alias-name is only unique within the mib, so when loading several mib's into a manager, there might be
several instances of the same aliasname.
oid_to_name(Oid) -> {ok, Name} | {error, Reason}
Types:
Oid = oid()
Name = atom()
Reason = term()
Transform a oid to its aliasname.
oid_to_type(Oid) -> {ok, Type} | {error, Reason}
Types:
Oid = oid()
Type = atom()
Reason = term()
Retreive the type (asn1 bertype) of an oid.
backup(BackupDir) -> ok | {error, Reason}
Types:
BackupDir = string()
Backup persistent data handled by the manager.
BackupDir cannot be identical to DbDir.
info() -> [{Key, Value}]
Types:
Key = atom()
Value = term()
Returns a list (a dictionary) containing information about the manager. Information includes statistics counters,
miscellaneous info about each process (e.g. memory allocation), and so on.
verbosity(Ref, Verbosity) -> void()
Types:
Ref = server | config | net_if | note_store | all
Verbosity = verbosity()
verbosity() = silence | info | log | debug | trace
Sets verbosity for the designated process. For the lowest verbosity silence, nothing is printed. The higher the
verbosity, the more is printed.
format_reason(Reason) -> string()
format_reason(Prefix, Reason) -> string()
Types:
Reason = term()
Prefix = integer() | string()
206 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpm
This utility function is used to create a formatted (pretty printable) string of the error reason received from either:
The Reason returned value if any of the sync/async get/get-next/set/get-bulk functions returns {error,
Reason}
The Reason parameter in the handle_error user callback function.
Prefix should either be an indention string (e.g. a list of spaces) or a positive integer (which will be used to create
the indention string of that length).
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 207
snmpm_conf
snmpm_conf
Erlang module
The module snmpm_conf contains various utility functions to used for manipulating (write/append/read) the config
files of the SNMP manager.
Exports
manager_entry(Tag, Val) -> manager_entry()
Types:
Tag = address | port | engine_id | max_message_size
Val = term()
manager_entry() = term()
Create an entry for the manager config file, manager.conf.
The type of Val depends on the value of Tag, see Manager Information for more info.
write_manager_config(Dir, Conf) -> ok
write_manager_config(Dir, Hdr, Conf) -> ok
Types:
Dir = string()
Hdr = string()
Conf = [manager_entry()]
Write the manager config to the manager 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 Manager Information for more info.
append_manager_config(Dir, Conf) -> ok
Types:
Dir = string()
Conf = [manager_entry()]
Append the config to the current manager config file.
Dir is the path to the directory where to store the config file.
See Manager Information for more info.
read_manager_config(Dir) -> Conf
Types:
Dir = string()
Conf = [manager_entry()]
Read the current manager config file.
Dir is the path to the directory where to store the config file.
208 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpm_conf
translates
to
the
following
call:
users_entry(UserId,
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 209
snmpm_conf
210 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpm_conf
Dir = string()
Conf = [agents_entry()]
Read the current manager agents config file.
Dir is the path to the directory where to store the config file.
See Agents for more info.
usm_entry(EngineID, UserName, AuthP, AuthKey, PrivP, PrivKey) -> usm_entry()
usm_entry(EngineID, UserName, SecName, AuthP, AuthKey, PrivP, PrivKey) ->
usm_entry()
Types:
EngineID = string()
UserName = string()
SecName = string()
AuthP = usmNoAuthProtocol | usmHMACMD5AuthProtocol |
usmHMACSHAAuthProtocol
AuthKey = [integer()]
PrivP = usmNoPrivProtocol | usmDESPrivProtocol | usmAesCfb128Protocol
PrivKey = [integer()]
usm_entry() = term()
Create an entry for the agent community config file, community.conf.
See Security data for USM for more info.
write_usm_config(Dir, Conf) -> ok
write_usm_config(Dir, Hdr, Conf) -> ok
Types:
Dir = string()
Hdr = string()
Conf = [usm_entry()]
Write the manager usm config to the manager 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.
append_usm_config(Dir, Conf) -> ok
Types:
Dir = string()
Conf = [usm_entry()]
Append the usm config to the current manager usm config file.
Dir is the path to the directory where to store the config file.
See Security data for USM for more info.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 211
snmpm_conf
212 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpm_mpd
snmpm_mpd
Erlang module
The module snmpm_mpd implements the version independent Message Processing and Dispatch functionality in
SNMP for the manager. It is supposed to be used from a Network Interface process (Definition of Manager Net if).
Legacy API function process_msg/7 that has got separate IpAddr and PortNumber arguments still works as
before for backwards compatibility reasons.
Exports
init_mpd(Vsns) -> mpd_state()
Types:
Vsns = [Vsn]
Vsn = v1 | v2 | v3
This function can be called from the net_if process at start-up. The options list defines which versions to use.
It also initializes some SNMP counters.
process_msg(Msg, Domain, Addr, State, NoteStore, Logger) -> {ok, Vsn, Pdu,
PduMS, MsgData} | {discarded, Reason}
Types:
Msg = binary()
Domain = transportDomainUdpIpv4 | transportDomainUdpIpv6
Addr = {inet:ip_address(), inet:port_number()}
State = mpd_state()
NoteStore = pid()
Logger = function()
Vsn = 'version-1' | 'version-2' | 'version-3'
Pdu = #pdu
PduMs = integer()
MsgData = term()
Processes an incoming message. Performs authentication and decryption as necessary. The return values should be
passed the manager server.
NoteStore is the pid() of the note-store process.
Logger is the function used for audit trail logging.
In the case when the pdu type is report, MsgData is either ok or {error, ReqId, Reason}.
generate_msg(Vsn, NoteStore, Pdu, MsgData, Logger) -> {ok, Packet} |
{discarded, Reason}
Types:
Vsn = 'version-1' | 'version-2' | 'version-3'
NoteStore = pid()
Pdu = #pdu
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 213
snmpm_mpd
MsgData = term()
Logger = function()
Packet = binary()
Reason = term()
Generates a possibly encrypted packet to be sent to the network.
NoteStore is the pid() of the note-store process.
MsgData is the message specific data used in the SNMP message. In SNMPv1 and SNMPv2c, this message data is
the community string. In SNMPv3, it is the context information.
Logger is the function used for audit trail logging.
generate_response_msg(Vsn, Pdu, MsgData, Logger) -> {ok, Packet} |
{discarded, Reason}
Types:
Vsn = 'version-1' | 'version-2' | 'version-3'
Pdu = #pdu
MsgData = term()
Logger = function()
Packet = binary()
Reason = term()
Generates a possibly encrypted response packet to be sent to the network.
MsgData is the message specific data used in the SNMP message. This value is received from the process_msg
function.
214 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpm_network_interface
snmpm_network_interface
Erlang module
This module defines the behaviour of the manager network interface. A snmpm_network_interface compliant
module must export the following functions:
start_link/2
stop/1
send_pdu/7
inform_response/4
note_store/2
info/1
get_log_type/1
set_log_type/2
verbosity/2
The semantics of them and their exact signatures are explained below.
Legacy API function send_pdu/7 that has got separate IpAddr and PortNumber arguments still works as before
for backwards compatibility reasons.
Exports
start_link(Server, NoteStore) -> {ok, Pid} | {error, Reason}
Types:
Server = pid()
NoteStore = pid()
Start-link the network interface process.
Server is the pid of the managing process.
NoteStore is the pid of the note-store process.
stop(Pid) -> void()
Types:
Pid = pid()
Stop the network interface process.
send_pdu(Pid, Pdu, Vsn, MsgData, Domain, Addr, ExtraInfo) -> void()
Types:
Pid = pid()
Pdu = pdu()
Vsn = 'version-1' | 'version-2' | 'version-3'
MsgData = term()
Domain = transportDomainUdpIpv4 | transportDomainUdpIpv6
Addr = {inet:ip_address(), inet:port_number()}
ExtraInfo = term()
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 215
snmpm_network_interface
Request the network interface process (Pid) to send this pdu (Pdu).
ExtraInfo is some opaque data that is passed to the net-if process. It originates from the ExtraInfo parameter in
the calls to the synchronous get-request, asynchronous get-request, synchronous get-next-request, asynchronous getnext-request, synchronous set-request and asynchronous set-request functions. Whether the net-if process chooses to
use this is implementation dependent. The net-if process included in this application ignores it.
inform_response(Pid, Ref, Addr, Port) -> void()
Types:
Pid = pid()
Ref = term()
Addr = address()
Port = integer()
Instruct the network interface process to send the response (acknowledgment) to an inform-request.
Ref is something that can be used to identify the inform-request, e.g. request-id of the inform-request.
Addr and Port identifies the agent, from which the inform-request originated.
note_store(Pid, NoteStore) -> void()
Types:
Pid = pid()
NoteStore = pid()
Change the pid of the note-store process. This is used when the server re-starts the note_store (e.g. after a crach).
info(Pid) -> [{Key, Value}]
Types:
Pid = pid()
The info returned is basically up to the implementer to decide. The implementation provided by this application
provides info about memory allocation and various socket information.
The info returned by this function is returned together with other info collected by the manager when the info function
is called (tagged with the key net_if).
verbosity(Pid, Verbosity) -> void()
Types:
Pid = pid()
Verbosity = verbosity()
Change the verbosity of the network interface process.
get_log_type(Pid) -> {ok, LogType} | {error, Reason}
Types:
Pid = pid()
LogType = atl_type()
Reason = term()
The Audit Trail Log is managed by the network interface process. So, it is this process that has to return the actual
log-type.
216 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpm_network_interface
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 217
snmpm_user
snmpm_user
Erlang module
This module defines the behaviour of the manager user. A snmpm_user compliant module must export the following
functions:
handle_error/3
handle_agent/4
handle_pdu/4
handle_trap/3
handle_inform/3
handle_report/3
handle_invalid_result/2
The semantics of them and their exact signatures are explained below.
Some of the function has no defined return value (void()), they can of course return anything. But the functions that
do have specified return value(s) must adhere to this. None of the functions can use exit of throw to return.
If the manager is not configured to use any particular transport domain, the behaviour handle_agent/4 will for
backwards copmpatibility reasons be called with the old IpAddr and PortNumber arguments
DATA TYPES
snmp_gen_info() = {ErrorStatus ::
ErrorIndex ::
Varbinds
::
snmp_v1_trap_info() :: {Enteprise
Generic
Spec
Timestamp
Varbinds
atom(),
pos_integer(),
[snmp:varbind()]}
:: snmp:oid(),
:: integer(),
:: integer(),
:: integer(),
:: [snmp:varbind()]}
Exports
handle_error(ReqId, Reason, UserData) -> void()
Types:
ReqId = integer()
Reason = {unexpected_pdu, SnmpInfo} | {invalid_sec_info, SecInfo,
SnmpInfo} | {empty_message, Addr, Port} | term()
SnmpInfo = snmp_gen_info()
SecInfo = term()
Addr = ip_address()
Port = integer()
UserData = term()
This function is called when the manager needs to communicate an "asynchronous" error to the user: e.g. failure to send
an asynchronous message (i.e. encoding error), a received message was discarded due to security error, the manager
218 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpm_user
failed to generate a response message to a received inform-request, or when receiving an unexpected PDU from an
agent (could be an expired async request).
If ReqId is less then 0, it means that this information was not available to the manager (that info was never retrieved
before the message was discarded).
For SnmpInfo see handle_agent below.
handle_agent(Domain, Addr, Type, SnmpInfo, UserData) -> Reply
Types:
Domain = transportDomainUdpIpv4 | transportDomainUdpIpv6
Addr = {inet:ip_address(), inet:port_number()}
Type = pdu | trap | report | inform
SnmpInfo = SnmpPduInfo | SnmpTrapInfo | SnmpReportInfo | SnmpInformInfo
SnmpPduInfo = snmp_gen_info()
SnmpTrapInfo = snmp_v1_trap_info()
SnmpReportInfo = snmp_gen_info()
SnmpInformInfo = snmp_gen_info()
UserData = term()
Reply = ignore | {register, UserId, TargetName, AgentConfig}
UserId = term()
TargetName = target_name()
AgentConfig = [agent_config()]
This function is called when a message is received from an unknown agent.
Note that this will always be the default user that is called.
For more info about the agent_config(), see register_agent.
The arguments Type and SnmpInfo relates in the following way:
The only user which would return {register, UserId, TargetName, AgentConfig} is the default user.
handle_pdu(TargetName, ReqId, SnmpPduInfo, UserData) -> void()
Types:
TargetName = target_name()
ReqId = term()
SnmpPduInfo = snmp_gen_info()
UserData = term()
Handle the reply to an asynchronous request, such as async_get, async_get_next or async_set.
It could also be a late reply to a synchronous request.
ReqId is returned by the asynchronous request function.
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 219
snmpm_user
220 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpm_user
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 221
snmpm_network_interface_filter
snmpm_network_interface_filter
Erlang module
This
module
defines
the
behaviour
of
the
manager
network
interface
snmpm_network_interface_filter compliant module must export the following functions:
filter.
accept_recv/2
accept_send/2
accept_recv_pdu/3
accept_send_pdu/2
The semantics of them and their exact signatures are explained below.
The purpose of the network interface filter is to allow for filtering of messages (accept or reject) receive and send.
This is done on two levels:
The first level is at the UDP entry / exit point, i.e. immediately after the receipt of the message, before any message
processing is done (accept_recv) and immediately before sending the message, after all message processing is
done (accept_send).
The second level is at the MPD entry / exit point, i.e. immediately after the basic message processing
(accept_recv_pdu) / immediately before the basic message processing (accept_send_pdu).
Note that the network interface filter is something which is used by the network interface implementation provided by
the application (snmpm_net_if and snmpm_net_if_mt). The default filter accepts all messages.
A network interface filter can e.g. be used during testing or for load regulation.
Legacy network interface filter modules used arguments on the form (IpAddr, PortNumber,...) instead of
(Domain, Addr, ...), and if the SNMP manager is run without changing the configuration to use transport
domains the network interface filter will still get the old arguments and work as before.
DATA TYPES
port() = integer() > 0
pdu_type() = 'get-request' | 'get-next-request' | 'get-response' |
'set-request' | trap | 'get-bulk-request' | 'inform-request' |
report | trappdu
Exports
accept_recv(Domain, Addr) -> boolean()
Types:
Domain = transportDomain()
Addr = transportAddressWithPort()
Called at the reception of a message (before any processing has been done).
For the message to be rejected, the function must return false.
222 | Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP)
snmpm_network_interface_filter
Ericsson AB. All Rights Reserved.: Simple Network Management Protocol (SNMP) | 223