Architecture - Events and Listeners

Value events and listeners
Value events are associated with scalar and table values. There are four types of value events: GET value, VALIDATE value, SET value and RESTORE DEFAULT value. Events and listeners for scalars and cells in a table are very similar. Listeners for these events must be registered with a scalar or table object.

GET value event
This event is triggered by the agent when MIB browser sends SNMP GET request to the agent in attempt to retrieve a scalar or table value. The application is responsible to handle this event and update the scalar or table values with the latest available.

VALIDATE value event
This event is triggered by the agent when MIB browser sends SNMP SET request to the agent in attempt to update a scalar or table value. This event is followed by SET event. The application has an option to handle VALIDATE event and accept the new value or reject the update.

SET value event
This event is triggered by the agent when MIB browser sends SNMP SET request to the agent in attempt to update a scalar or table value. This event is prepended by VALIDATE event. This event is not sent if prepending VALIDATION event listener rejected the update.

RESTORE DEFAULT value event
This event is triggered by the agent when a user removes an entry from persistency storage using MIB browser. The application must register a listener to handle this event and propagate the restored default value to the application during the current session. The application will use the default value next time it is restarted even if the listener is not registered. See also Persistency.

Agent life events
During the life cycle the agent sends the following notifications to the MIB browser:

coldStart
This notification is declared in SNMPv2-MIB / RFC 3418. The notification is generated when the agent starts.

appStop
This notification is declared in FRIENDLY-SNMP-MIB. The notification is generated when the agent stops (suspended).

warmStart
This notification is declared in SNMPv2-MIB / RFC 3418. The notification is generated when the agent restarts (resumes).

appShutdown
This notification is declared in FRIENDLY-SNMP-MIB. The notification is generated when the agent shutdowns. See also here.

heartbeat
This notification is declared in FRIENDLY-HEARTBEAT-MIB. The notification is generated periodically at a fixed interval while the agent running. The heartbeat interval is configurable. Setting the heartbeat interval to 0 stops the heartbeat notifications. See also here.

Remote shutdown
The agent has an option to shutdown the application remotely. The remote shutdown is handled with a scalar shutdownApp declared in FRIENDLY-SNMP-MIB. The scalar always displays the running value. This value could be set to shutdown value using a MIB browser SNMP SET request. This action triggers shutdown event in the agent. The application is responsible to register org.friendlysnmp.event.ShutdownListener with the agent and implement the method

public boolean shutdownRequest()
The application may return false in this method as a signal that shutdown is rejected. The agent will return NO_ACCESS validation value to the MIB browser in this case. Otherwise the application should call System.exit() and return value does not matter.