# eva_snmp_adaptation

### MODULE

eva_snmp_adaptation

### MODULE SUMMARY

An SNMP Adaptation to EVA

### DESCRIPTION

This module implements an SNMP adaptation to basic EVA. The MIB implemented by this adaptation is OTP-EVA-MIB. The MIB is located in the directory `mibs` in the distribution.

The resources generate events and alarms using the API provided by EVA. They are not aware that the events and alarms are sent as SNMP traps to SNMP managers.

However, each trap to be sent must be defined in an SNMP MIB, and there must be instrumentation functions that translate the EVA events and alarms into SNMP traps. Normally, each event and alarm in the system is mapped onto one separate SNMP trap. This mapping is done by registration of the events. The following functions are available for the registration. They could be called when the corresponding MIB is loaded.

### EXPORTS

`create_tables(Nodes) -> void()`

Types:

`Nodes = [node()]`

This function creates the Mnesia tables required for the `eva_snmp_adaptation`. `Nodes` is a list of nodes where the tables should be replicated. This list of nodes should specify the same nodes where the application EVA can be run distributed, so that EVA always can have local access to the tables.

This function should be called once when installing the EVA application in the system.

`name2index(Name) -> {ok, Index} | undefined`

Types:

`Name = atom()`
`Index = integer()`

Maps an event to the corresponding `eventIndex` value for the event, as defined in the `eventTable` in `OTP-EVA-MIB`.

`register_alarms(Alarms) -> void()`

Types:

`Alarms = [{Name, Trap, Treatment, Community, Func}]`
`Name = Trap = atom()`
`Func = fun(#alarm) -> {ok, ObjOID, CauseOID, SnmpVarbinds}`
`Treatment = none | snmpTrap`
`Community = string()`
`ObjOid = CauseOid = [integer()]`

This function must be used to register an EVA alarm as an SNMP alarm. It is used to associate each event with the corresponding SNMP trap and an Erlang instrumentation function which translates the `#alarm` into a trap. The corresponding `Trap` must be defined in an SNMP MIB. `Treatment` defines how this alarm is treated when it is generated. If it is `snmpTrap`, it is sent to the `Community`.

When the EVA alarm `Name` is generated by an application, the adaptation calls `Func(#alarm)`. The purpose of the `Func` is to translate the Erlang record `#alarm` into SNMP values. `ObjOID` is an OBJECT IDENTIFIER representation of the `#alarm.sender`, `CauseOID` is an OBJECT IDENTIFIER representation of the `#alarm.cause`, and `SnmpVarbinds` is a list of extra variable bindings for the trap. This list is as defined for `snmp:send_trap`.

The `alarm` record is defined in `eva.hrl`, available in the `include` directory in the distribution.

`register_events(Events) -> void()`

Types:

`Events = [{Name, Trap, Treatment, Community, Func}]`
`Name = Trap = atom()`
`Func = fun(#event) -> {ok, SnmpVarbinds}`
`Treatment = none | snmpTrap`
`Community = string()`

This function must be used to register an EVA event as an SNMP event. It is used to associate each event with the corresponding SNMP trap and an Erlang instrumentation function which translates the `#event` into a trap. The corresponding `Trap` must be defined in an SNMP MIB. `Treatment` defines how this event is treated when it is generated. If it is `snmpTrap` it is sent to the `Community`.

When the EVA event `Name` is generated by an application, the adaptation calls `Func(#event)`. The purpose of the `Func` is to translate the Erlang record `#event` into SNMP values. The `SnmpVarbinds` is a list of extra variable bindings for the trap. This list is as defined for `snmp:send_trap`.

The `event` record is defined in `eva.hrl`, available in the `include` directory in the distribution.

`start_link() -> {ok, Pid} | {error, Reason}`

Starts the EVA SNMP adaptation. This function can be used to include the service in a supervisor. Normally, functions in the supervisor `eva_sup` can be used instead.

The function `create_tables/1` must be called before the service is started.

An EVA adaptation is always implemented as a `gen_event` handler. So is `eva_snmp_adaptation`. But in order to supervise this service from an ordinary supervisor, this function creates a process that supervises the `gen_event` handler.

### Instrumentation Functions for the OTP-EVA-MIB

In some cases, other adaptations may need access to the SNMP specific data in EVA. To do this, the instrumentation functions for the SNMP objects can be used. These instrumentation functions takes the arguments and return the values defined in the application `snmp`.

### EXPORTS

`alarmTable(Op, RowIndex, Cols) -> InstrumRet`

Instrumentation function for `alarmTable`. This function assumes that access checks are made according to the MIB, so it may crash if, for example, `alarmClass` is set.

`curAlarmTable(Op, RowIndex, Cols) -> InstrumRet`

Instrumentation function for `currentAlarmTable`. This function assumes that access checks are made according to the MIB, so it may crash if, for example, `currentAlarmSeverity` is set.

`curAlarmLastTimeChanged(get) -> InstrumRet`

Instrumentation function for `currentAlarmLastTimeSent`.

`eventTable(Op, RowIndex, Cols) -> InstrumRet`

Instrumentation function for `eventTable`. This function assumes that access checks are made according to the MIB, so it may crash if, for example, `eventTrapName` is set.

### See Also

eva(3), eva_sup(3), gen_event(3), snmp(3)

### AUTHORS

Martin Björklund - support@erlang.ericsson.se

eva 2.0.3
Copyright © 1991-2003 Ericsson Utvecklings AB