This page describes an older version of the product. The latest stable version is 16.4.

SNMP Alerts

The XAP Alert interface exposes the XAP environment and the application’s health state. It allows users to register listeners on one or more alert types and receive notifications once an alert has been raised or has been resolved. You may use this framework to build a custom integration with a third party monitoring products to leverage the XAP alerting system. A recommended approach for such integration would be to construct a listener that writes the chosen types of alerts into logger mechanism. Examples for such may be the log4j or the commons-logging frameworks.

The main advantage with this approach is the ability to use an extensive set of out-of-box log appenders that translates log messages into different protocols and APIs to be consumed by third party products. AlertsLoggerBridge.jpg


The AlertLoggingGateway example project provided with the GigaSpaces distribution using an existing Log4J Appender (SnmpTrapAppender) to convert log messages into SNMP traps, resulting in the alerts propagated to a third party network management solution. SNMP_Appender.jpg

AlertsLoggingGatway components


The SnmpTrapTransmitter is a XAP PU responsible for the generic Alert-to-Log bridging. It does that by listening to all alerts in its alert filter file. Any incoming alerts are simply writing to commons logging log. Notice that, being generic in nature, the SnmpTrapTransmitter can be reused without any changes in similar projects. SnmpTrapTransmitter exposes the following configuration parameters:

AlertFileFilter - the name of Alert filter xml file used to filter Alerts to be logged
loggerName - the name of the logger to be created
group - the XAP group for which the Alert listener will be configured

  <bean id="SnmpTrapTransmitter" class="org.openspaces.example.alert.logging.snmp.SnmpTrapTransmitter" >
    <property name="alertFileFilter" value="notify-alerts.xml" />
    <property name="loggerName" value="org.openspaces.example.alert.logging.AlertLoggingGateway" />
    <property name="group" value="group-name-here" />

Note that if you implement your own variant for this class, for other types of alert interception, you will also have to override the construct() method to register for alerts, the destroy() method to cleanup the registration, and to create your own class implementing the AlertTriggeredEventListener interface in which you will issue the logging calls:

public class SnmpTrapTransmitter {

    private Log logger;

    public void construct() throws Exception {

    public void destroy() throws Exception {

    private void registerAlertTrapper() {
        atListener = new AlertTriggeredEventListener() {
            public void alertTriggered(Alert alert) {
                String loggRecord;
                loggRecord = alert.toString();

        XmlAlertConfigurationParser cparse = new XmlAlertConfigurationParser(alertFileFilter);


The SnmpTrapSender is a utility class that implements the SnmpTrapAppender’s SnmpTrapSenderFacade interface with an implementation that queues and asynchronously transmits Alerts as SNMP traps. The SNMP transmission method - sendTrap() - uses snmp4j library as its underlying implementation.

public class SnmpTrapSender implements SnmpTrapSenderFacade {

    public void addTrapMessageVariable(String trapOID, String trapValue) {

    public void initialize(SNMPTrapAppender arg0) {

    public void sendTrap() {
        String trapVal = trapQueue.removeFirst();
                PDUv1 trapPdu = (PDUv1)DefaultPDUFactory.createPDU(SnmpConstants.version1);
                // pack trapVal into trapPdu
        snmp.send(trapPdu, target);
    } and

The file is a commons logging configuration file which re-directs its calls to a log4j logger. In our example this file contains redirection of commons-logging to log4j as the SNMP trapper we use is on top of log4j. is a log4j configuration file which delegates log writes to the SNMPTrapAppender, resulting in SNMP traps.


Running the Example

The example is located under <XAP root>/tools/alert-integration. To run it you should do the following:

  1. Set the “group” value in the pu.xml file to your own XAP group. Optionally you may edit the function registerAlertTrapper() in to create your own Admin object in any way you see fit.
  2. Optionally edit file notify-alerts.xml to set your own alerts and alert conditions that will be listened to by this example.
  3. Optionally edit to set the IP and port used by your SNMP server software (if any).
  4. If you do not have an SNMP server software, you should download one for the sake of running and testing this example. iReasoning MIB browser for example ( provides good basic SNMP trap viewing capabilities with a free personal edition. Make sure you configure to use the same IP and port used by the server.
  5. Build and pack the example project into a jar file. This can be done by executing the command “mvn” from the project’s root directory or performing an equivalent action within your UI. A successful build should result in the creation of the example jar file in target/AlertLoggingGateway.jar.
  6. If needed start XAP with at least one running LUS, GSM and GSC belonging to the XAP group declared in item #2.
  7. Deploy the example JAR into the GSC.
  8. If needed - perform XAP actions that will trigger one or more of the alerts the example is tuned to listen to. Creating a new GSCs is usually a good way for creating a multitude of different alerts.
  9. Start-up your SNMP server to intercept and view incoming traps. If you use MIB browser enter the Trap Receiver (Ctrl-I) and make sure it is configured to listen on the right IP and port.

#. External Dependencies

  1. log4j version >= 1.2.14
  2. snmpTrapAppender version >= 1.2.9
  3. snmp4j version >= 1.11.2
  4. For the example build process you should have Apache Maven installed. You may find it already part of the GigaSpaces folders under \gigaspaces-xap\tools\maven.