4.5.1 Filtering Traps from DSLAM Device

 

Aim

 

To provide a complete DSLAM management capability to the EMS with effective Trap handling.

 

For details on Creating Trap Filter, refer to the Web NMS EclipsePlugin Guide.

 

Effort Estimate  

 

This task can be accomplished  in a man day.   

 

Instructions

 

Step 1: Invoking the TrapFilter Creation Wizard

 

Select WebNMS > Filters > Fault > Create Trap Filter menu

 

Step 2 : Trap Filter Details

 

Provide the following details about the Trap Filter

 

Package Name

com.adventnet.ebon.ems

Filter ClassName

DslamTrapFilter

 

 

Enter the Match Criteria for filtering the trap. It includes V1 Trap, V2 Trap. For V1 Trap , enter the Enterprise OID , Generic Trap Type and Specific Trap Type. For V2C Trap  , enter the Trap OID.

 

 Enterprise OID

*

Generic Trap Type

6

Specific Trap  Type

100

 

Click Finish.

 

In order to capture handle the V1 Traps for the card addition also you need to edit the trap.filters file to provide a similar entry as the one auto-generated using the above input for card deletion.  Copy and paste the entry as below in the trap.filter file:

 

 <FILTER

     name="Dslam_CardAddition"

     classname="com.adventnet.Ebon.ems.DslamDevice.DslamTrapFilter"

     enable="true"

     GT="6"

     ST="200"

     enterprise="*" />

 

 

You will find the <Trap Filter class> under <Your Project>/ source folder in the Project Explorer window.

You can add the custom code or modify the existing code of the source using the editor directly as per your requirement.

 

The appropriate entry  for this trap filter will be appended in the trap.filters file in the <Your Project>/resources/conf folder. You can rearrange the entries in this file as per your requirement to change the order in which the trap.filters are invoked.

 

Add the following code above the applyTrapFilter method:

 

TopoAPI api;

 

Add the following code  in the applyTrapFilter method:

 

 

//creating an event object and setting the properties based on the pdu type.

   Event event = new Event( );

   System.out.println("INSIDE device trap filter :"+pdu.getAgentAddr());

   NmsLogMgr.EVENTUSER.log("Trap properties in TrapFilter DslamTrapFilter are :",Log.DEBUG);

        NmsLogMgr.EVENTUSER.log("Trap AgentIPAddress is :"+pdu.getAgentAddress(),Log.DEBUG);

        

        Vector varbinds=pdu.getVariableBindings();

        

        for(Enumeration elements=varbinds.elements();elements.hasMoreElements();)

        {

        NmsLogMgr.EVENTUSER.log("Trap Varbinds are :"+elements.nextElement(),Log.DEBUG);

        }

        //debug statements

        if(pdu.getVersion() == SnmpAPI.SNMP_VERSION_1 )

        {

                NmsLogMgr.EVENTUSER.log("Trap version is V1 ",Log.DEBUG);

                NmsLogMgr.EVENTUSER.log("Trap EnterpriseOID is :"+pdu.getEnterprise().toString(),Log.DEBUG);

                NmsLogMgr.EVENTUSER.log("Trap Generic type is :"+pdu.getTrapType(),Log.DEBUG);

                NmsLogMgr.EVENTUSER.log("Trap Specific type is :"+pdu.getSpecificType(),Log.DEBUG);

        }

        else

        {

                if(pdu.getVersion() == SnmpAPI.SNMP_VERSION_3 )

                {

                        NmsLogMgr.EVENTUSER.log("Trap version is V3 ",Log.DEBUG);

                }

                else

                {

                        NmsLogMgr.EVENTUSER.log("Trap version is V2C ",Log.DEBUG);

                }

                NmsLogMgr.EVENTUSER.log("Trap TrapOID is : "+ pdu.getVariable(1),Log.DEBUG );

        }//end

        //checking for the Enterprise Id and trap type and based on the same the event properties are set.

        if((pdu.getEnterprise() != null && pdu.getEnterprise().toString().equals(".1.3.6.1.4.1.2162.1") ) && ( pdu.getTrapType() == 6))

        {

        String ip=pdu.getAgentAddr();

        if (ip == null)

        {

                return pdu;

        }

if(ip.trim().equalsIgnoreCase("127.0.0.1"))

{

try

{

ip = java.net.InetAddress.getLocalHost().getHostAddress();//pdu.getAgentAddress().getLocalHost().getHostAddress();

}

catch(java.net.UnknownHostException unknowne)

{

System.err.println("Trap from unknown host : " + unknowne);

}

}// end if

 

String hostName=ip;

 

if(api == null)

             api = getTopoAPI();

if (api != null)

{

try

{

/* The following call gets the name of the

   object given the IP Address. */

hostName = getObjectName(ip);

}

 

catch (Exception ee)

{

NmsLogMgr.EVENTERR.fail(

NmsUtil.GetString("From LinkUpDownTrapFilter .. Failed to get interface object key : ")+ee, ee);

return pdu;

}

}

        

                String  source = hostName+"_Slot1_Card11_Port1";

                System.err.println(pdu.getSpecificType()+"SOURCE:"+source);

                if((pdu.getSpecificType() == 200 ) || ( pdu.getSpecificType() == 300))

                {

   //setting the properties of the event from the trap PDU.

   event.setCategory( pdu.getCommunity( ) );

   //The source property of an event denotes the Managedobject for which this event is raised.

   //Note: It is based on this property that status propagation occurs.

                        event.setSource(source);

                        event.setNode(hostName);//TODO

                        //Entity denotes the Managedobject or one of its sub-component for which this event has been generated.

                        //Note: This property is used for correlation of alerts. All Events with the same Entity will result in only one Alert

                        event.setEntity(hostName);//TODO

                        event.setTime(pdu.getUpTime());

                        if((pdu.getSpecificType() == 200))

                        {

                                event.setText("The Dslam Port has gone down");

                                event.setSeverity(1);

                        }

                        if((pdu.getSpecificType() == 300))

                        {

                                event.setText("The Dslam Port is clear now");

                                event.setSeverity(5);

                        }

                        NmsLogMgr.EVENTUSER.log("Returned Event properties in DslamTrapFilter are : "+event.getProperties().toString(),Log.DEBUG);

                        //Here are are returning the event. This event will now be passed through event parsers and event filters and then be added to the database.

                        return event;

                }

        }

        //When the PDU is returned it will be passed through other trap filters defined in the trap.filters file. Even after passing through all the filters, if the PDU is still not converted to an Event, it will be passed to trap parsers.

   System.err.println("OUTSIDE:"+pdu.getTrapType());

 

 

Add the User code as given below at the end before the last "}":

 

/**

 * This method is used to get the name of the object given the ip-address.

 * @param address

 * @return

 */

private String getObjectName(String address){

try{

Properties pObjectName=new Properties();

pObjectName.put("isInterface","false");

pObjectName.put("ipAddress",address);

Vector objNames=api.getObjectNamesWithProps(pObjectName);

if(objNames!=null && objNames.size() != 0){

return  (String)objNames.elementAt(0);//vecONames.elementAt(0);//api.getInterfaceObjectKey(failedInterfaceIP);

}

}

catch (RemoteException ex)

{

NmsLogMgr.EVENTERR.fail(

NmsUtil.GetString("From LinkUpDownTrapFilter .. Failed to get interface object key : ")+ex, ex);

}catch(Exception exe){

exe.printStackTrace();

}

return  address;

}

 

 

/** This gets the TopoAPI.

 **/

private TopoAPI getTopoAPI()

{

try

        {   

api =(TopoAPI)NmsUtil.getAPI("TopoAPI");

        }

catch ( Exception e)

        {

            e.printStackTrace();

        }

return api;

} // end  getTopoAPI()

 

 

Result  

 

The trap handling and processing the trap to meaningful event from DSLAM device is ready.

 

You can now move to the next step to Create Status Poller for cards in DSLAM device.

 

 



Copyright © 2009 ZOHO Corp. All Rights Reserved.