Skip navigation links

Package com.tailf.ncs.snmp.snmp4j

NCS snmp4j support package

See: Description

Package com.tailf.ncs.snmp.snmp4j Description

NCS snmp4j support package

This package contains classes provided to support the use of snmp4j in NCS.

For the moment this support consists of a SNMP notification receiver that uses snmp4j to listen for notifications.

The benefit of using these classes is that the configuration of snmp4j is contained in the NCS configuration. The user provides handlers (or callbacks) that processes the notifications e.g. maps these to NCS alarms that are delivered to the NCS Alarm API *

Example: The expected usage of the NotificationReceiver and the, by the user, provided NotificationHandlers are in the main() method of the service manager:

 public class App {

     ....

     public static void main(String[] args) {

         ....


         // setting up AlarmManager and Snmp Notification receiver
         try {
             // We set up the AlarmSinkCentral to enable asynch
             // alarm provision to NCS.
             Socket cdbSocket = new Socket("localhost", Conf.NCS_PORT);
             Cdb cdb = new Cdb("snmp-notif-alarm-sink", cdbSocket);
             AlarmSinkCentral sinkCentral =
             AlarmSinkCentral.getAlarmSink(100000, cdb);
             // start sinkCental if not already running
             if (!sinkCentral.isAlive()) {
                 sinkCentral.start();
             }

             // Register snmp NotificationHandlers
             // and start the NotificationReceiver
             ExampleHandler handl = new ExampleHandler();
             NotificationReceiver notifRec =
                 NotificationReceiver.getNotificationReceiver()
             // register example handler
             notifRec.register(handl, null);
             // example of an anonymous handler
             notifRec.register(new NotificationHandler() {
                 public HandlerResponse
                     processPdu(CommandResponderEvent event, Object opaque)
                         throws Exception {
                             System.out.println("\n\n" +
                                 "------>Anonymous Filter called" +
                                 "\n\n");
                             return HandlerResponse.CONTINUE;
                 }
             }, null);

             // start the NotificationReceiver
             notifRec.start();
         } catch (Exception e) {
             e.printStackTrace();
         }

         ....
     }

     ....
 }
 

Skip navigation links