A user-defined instrumentation function for each object attaches
the managed objects to real resources. This function is called by
the agent on a
When a managed object is referenced in an SNMP operation, the
associated
Instrumentation functions must be written for
The following sections describe how the instrumentation
functions should be defined in Erlang for the different
operations. In the following,
These functions are described in detail in
For scalar variables:
variable_access(new [, ExtraArg1, ...])
variable_access(delete [, ExtraArg1, ...])
For tables:
table_access(new [, ExtraArg1, ...])
table_access(delete [, ExtraArg1, ...])
These functions are called for each object in an MIB when the MIB is unloaded or loaded, respectively.
For scalar variables:
variable_access(get [, ExtraArg1, ...])
For tables:
table_access(get,RowIndex,Cols [,ExtraArg1, ...])
These functions must return the current values of the associated variables.
For scalar variables:
variable_access(set, NewValue [, ExtraArg1, ...])
For tables:
table_access(set, RowIndex, Cols [, ExtraArg1,..])
These functions returns
As a complement to the
variable_access(is_set_ok, NewValue [, ExtraArg1, ...])
For tables:
table_access(set, RowIndex, Cols [, ExtraArg1,..])
A function which has been called with
variable_access(undo, NewValue [, ExtraArg1, ...])
For tables:
table_access(set, RowIndex, Cols [, ExtraArg1,..])
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
table_access(get_next, RowIndex, Cols [, ExtraArg1, ...])
This operation is best described with an example.
A table called
N/A means not accessible.
The manager issues the following
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(get_next, [1, 1], [3, 5])
In this call,
[{[3, 1, 2], d}, {[5, 1, 2], f}]
This is illustrated in the following table:
The manager now issues the following
getNext{ myTable.myTableEntry.3.2.1,
myTable.myTableEntry.5.2.1 }
This is transformed into one call to
my_table(get_next, [2, 1], [3, 5])
The function should now return:
[{[4, 1, 1], b}, endOfTable]
This is illustrated in the following table:
The manager now issues the following
getNext{ myTable.myTableEntry.3.1.2,
myTable.myTableEntry.4.1.2 }
This will be transform into one call to
my_table(get_next, [1, 2], [3, 4])
The function should now return:
[{[3, 2, 1], g}, {[5, 1, 1], c}]
This is illustrated in the following table:
The manager now issues the following
getNext{ myTable.myTableEntry,
myTable.myTableEntry.1.3.2 }
This will be transform into two calls to
my_table(get_next, [], [0]) and
my_table(get_next, [3, 2], [1])
The function should now return:
[{[3, 1, 1], a}] and
[{[3, 1, 1], a}]
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.
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
The
{ipAdr, {my_module, ip_access, []}}.
% Or using the oid syntax for 'name'
{[1,1,7], {my_module, name_access, []}}.
The
If
{ipAdr, {my_module, generic_access, ['IPADR']}}.
% The mnemonic 'name' is more convenient than 1.1.7
{name, {my_module, generic_access, ['NAME']}}.
When the agent receives the same get-request as above, a call
will be made to
Yet another possibility, closer to the hardware, could be:
{ipAdr, {my_module, generic_access, [16#2543]}}.
{name, {my_module, generic_access, [16#A2B3]}}.
When the MIB definition work is finished, there are two major issues left.
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
The agent stores the values in an internal volatile database,
which is based on the standard module
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.
The generation of default functions for tables works for
tables which use the
We strongly encourage the use of the
In SNMP, the
At
the end of phase one, the user defined
If no error occurs, the second phase is performed. This phase
calls the user defined
If an error occurs, either in the
There are limitations with this transaction mechanism. If
complex dependencies exist between variables, for example between
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.