5.19.5.1.1 Configuring Trap Filters

 



 

Overview

 

Traps need to be converted into Event Objects. Event Objects are WebNMS representation of the network problem. Trap filters are used to generate Event Objects from the received SNMP Traps. They filter the traps based on the specified matching criteria and can be configured to function in any of the following ways:

You can have your own trap filter to accomplish any of the above mentioned functions, based on the requirements. To have a custom trap filter, you need to do the following:

Writing a trap filter using  EclipsePlugin

 

Web NMS  EclipsePlugin facilitates easy creation of a Trap Filter by taking you through a wizard. Enter the package name, Filter Class Name and match criteria. The code will be generated and the corresponding entry will be made in the trap.filters file automatically.

For more details on using  EclipsePlugin to create a trap filter, refer to the topic Creating a Trap Filter in Web NMS EclipsePlugin Guide

 

Writing a custom Trap Filter Class

 

The custom Trap filter Class written by you should implement the interface com.adventnet.nms.eventdb.TrapFilter Whenever a trap matching the specified criteria is received by Web NMS, the method applyTrapFilter (com.adventnet.snmp.snmp2.SnmpPDU pdu) defined in the TrapFilter interface will be called. The argument SnmpPDU will have the information about the received trap.

 

Please refer to the LinkUpdownTrapFilter example present in <Web NMS Home>/examples/FaultManagement/trap_filters for more details on how to write a custom trap filter class. You can also view the description about the filter and the source code.

 

Configuring Trap Filters through Configuration file

 

The name of the trap filter class which has to be executed, on receipt of a trap, should be specified in the trap.filters file present in <Web NMS Home>/conf directory. The matching criteria for the traps can also be specified here.

 

Defining match criteria for SNMP v1 traps

 

For processing a SNMP v1 trap, you should specify the match criteria which comprises of the enterprise oid, Generic Trap Type and Specific Trap Type of the trap. The syntax for trap.filters will be like the one shown below

 

<FILTER

classname="test.TestTrapFilter"

GT="2" ST="0" enterprise=".1.3.6.1.2.11"/>

 

Defining match criteria for SNMP v2c and v3 traps

 

For defining trap filters for SNMP v2c traps, you should specify the match criteria which comprises of the "trapoid" of the device. You can define multiple trap filters with their match criteria, for the trapoid of the trap.

 

If the class "LinkUpDownTrapFilter" has to be invoked for a trap received with trapoid as ".1.3.6.1.6.3.1.1.5.3", then the entry in the trap.filters should be like:

 

<FILTER

classname="test.LinkUpDownTrapFilter"

trapoid=".1.3.6.1.6.3.1.1.5.3" name = "xxxxxx" enable = "true"/>

 

Enabling / Disabling Trap Filters

 

Users can now enable the filter to invoke the actions or let it be dormant using the enable/disable option. Trap Filters can be enabled or disabled by using the parameter "enable" in the trap.filters file present in <Web NMS Home>/conf directory.

 

This parameter can take two values either "true" or "false" If the value is set to "true", then the corresponding filter will be enabled and if it is set to "false", it gets disabled. By default, this field is set to true.

 

Look at the trap.filters file given below for better understanding of the enable parameter.

 

<TRAP_FILTERS>

<FILTER name="LinkDownSnmpV1" classname="test.LinkUpDownTrapFilter"

enable="true"

GT="3" ST="0" enterprise=".1.3.6.1.2.1.11" />

</TRAP_FILTERS>

 

Configuring the Trap Filters using the Trap Filter Configuration Tool

 

You can invoke the Trap Filter Configuration Tool by choosing Tools -->Runtime Administration in the Client and then choosing Fault -->Trap Filters from the tree.

 

The following are the options in the configuration of Trap Filters.

 

 

Adding Trap Filters

 

The following steps have to be followed to Add Trap Filters

Specifying Trap Filter Information

 

Viewing Trap Filter Details

 

This option is used to view the details of the currently configured Trap Filter.

 

The following are the steps:

      • Select the Trap Filter

      • Click on the View Details button

The details that are displayed are the Trap Filter Name, the Trap Filter Class Name, the SNMP Version, GT (Generic Type), ST (Specific Type), Enterprise OID for SNMP V1 and TrapObjectID for SNMP V2 and V3.

 

This option is only to view the details, so the fields are not editable.

 

 

Modifying Trap Filter

 

When you want to change an incorrect entry in class name or filter name, this option can be used. For example, instead of giving the class file name as 'testFilter' if you have incorrectly typed as 'tesfilter', then this Modify option can be used to change the class file name.

 

The following are the steps:

The details that are displayed are the Trap Filter Name, the Trap Filter Class Name, the SNMP Version, GT, ST, Enterprise OID for SNMP V1 and TrapObjectID for SNMP V2 and V3.

 

 

The fields are editable. Modify the details as required and then click on the OK button to approve the modifications or Cancel to discard the changes.

 

Deleting Trap Filters

 

The filters which are currently enabled in the system will be displayed in the screen. Select the Filter to be deleted and click Delete. A dialog will pop up asking to confirm, and on clicking Yes, the filter will be removed forever.

 

Ordering of Trap Filters

 

When Traps are received, the Server checks for the satisfaction of specific match criteria. If the Trap matches the criteria, it will be passed to the Trap Filter class specified in the file. The matching of Trap Filters will be done in a sequence starting from the first filter in the trap.filters file. Only when the first Trap Filter returns a trap PDU, it will be passed through the subsequent Trap Filters.

 

The following are the steps to change the order of execution of trap filters via the UI.

Enabling/ Disabling Trap Filters

 

Users can now enable the filter to invoke the actions or let it be dormant using the enable/disable option.

 

The following are the steps

Saving the Trap Filters Configuration

 

After configuring new Trap Filters, modifications effected to the list of Trap Filters, click the Save button to save the configuration. The details are saved in the trap.filters file (under the <Web NMS Home>/conf directory)

 

Configuring Trap Filters using API

 

Let us illustrate this with an example:

 

Match Criteria for Link Down Trap

SNMP Version:

V1

Enterprise ObjectID:

.1.3.6.1.2.1.11

Generic Type

2

Specific Type

0

Trap Filter Details

 

Name

Example V1 Trap Filter

Filter Class

test.LinkUpDownTrapFilter

Enable

true

 

Match Criteria for Link Down Trap

SNMP Version:

V2

TrapObjectID:

.1.3.6.1.6.3.1.1.5.3

Trap Filter Details

 

Name

Example V2 Trap Filter

Filter Class

test.LinkUpDownTrapFilter

Enable

true

 

The sample code will be like the following:

 

...>

import com.adventnet.nms.eventdb.TrapAPI;

import com.adventnet.nms.NmsUtil;

....

 

public void setTrapFilters)

{

 

.......

 

/* Get the Handle of TrapAPI */

TrapAPI trapAPI = getTrapAPI();

 

/* Get the Trap Filter (Holder)to handle V1 Trap - Link Down */

TrapFilterHolder tfp = getV1TrapFilterHolder("Example V1 Trap Filter",".1.3.6.1.2.1.11","2","0",true,"test.LinkUpDownTrapFilter");

 

/* Get the Trap Filter (Holder) to handle V2 Trap - Link Down */

TrapFilterHolder holder = getV2TrapFilterHolder("Example V2 Trap Filter",".1.3.6.1.6.3.1.1.5.3",true,"test.LinkUpDownTrapFilter");

 

/** Construct an Array from the V1 Trap Filter and V2 Trap Filter (Holders) **/

TrapFilterHolder[] filterArray = {tfp,holder};

 

/** Configure the Web NMS with the Trap Filters with the option to **/

/** save the Trap Filters without overwriting the existing Trap Filters **/

trapAPI.setTrapFilters(filterArray,true,true);

 

.......

 

}

/** Method to construct a TrapFilterHolder Instance with the given values for V2 Trap **/

public TrapFilterHolder getV2TrapFilterHolder(String name,String trapOID,boolean toEnable ,String trapFilterClassName)

{

TrapFilterHolder holder = new TrapFilterHolder();

holder.setFilterName(name);

holder.setTrapOID(trapOID);

try

{

holder.setTrapFilter((TrapFilter)Class.forName(trapFilterClassName).newInstance());

}

catch(Exception ee)

{

ee.printStackTrace();

}

}

/** Method to construct a TrapFilterHolder Instance with the given values for V1 Trap**/

 

public TrapFilterHolder getV1TrapFilterHolder(String name,String enterpriseOID, String genericType, String specificType,boolean toEnable,String trapFilterClassName)

{

TrapFilterHolder tfp = new TrapFilterHolder();

tfp.setFilterName(name);

tfp.setEnterpriseOID(enterpriseOID);

tfp.setGenericType(genericType);

tfp.setSpecificType(specificType);

try

{

tfp.setTrapFilter(Class.forName(trapFilterClassName).newInstance());

}

catch(Exception e)

{

e.printStackTrace();

}

tfp.setEnableType(toEnable);

 

return tfp;

 

}

/** Get the TrapAPI handle using RMI **/

public TrapAPI getTrapAPI()

{

 

TrapAPI trapAPI = null;

try

 

// hostName specifies the host in which Web NMS Server is running.

String apiString = "//<hostName>/TrapAPI";

 

//RMI lookup This fetches the TrapAPI handle

trapAPI = (TrapAPI)Naming.lookup(apiString);

 

}

catch{Exception e}

{

e.printStackTrace();

}

return trapAPI;

}

 

 

 

Options available in Trap Filter Configuration

 

  1. To match a set of traps with OIDs starting with a particular value, the asterisk wild card character (*) can be specified after the common value.

    <FILTER trapoid=".1.3.6.1.4.1.3085.3.1.1.1*" enable="true" classname="test.LinkUpDownTrapFilter" />

    Also, negation operator ! can be used while specifying enterprise/trap OID in trap filters.
     

  2. To do an exact match of the OIDs, the value should be specified within &lt; and &gt; (angular brackets).

    <FILTER name="TrapFilter1" classname="test.UserPropTrapFilter" enable="true" GT="2" ST="0"   enterprise="&lt;.1.3.6.1.2.1.11&gt;" />
     

  3. To process multiple trap/enterprise OIDs in a single trap filter, the required trap/enterprise OIDs need to be specified as comma-separated values.

    <FILTER name="TrapFilter1" classname="test.UserPropTrapFilter" enable="true" trapoid=".1.3.6.1.6.3.1.1.5.2,.1.3.6.1.6.3.1.1.5.4,.1.3.6.1.6.3.1.1.5.3" />

    <FILTER name="TrapFilter1" classname="test.UserPropTrapFilter" enable="true" GT="2" ST="0"   enterprise=".1.3.6.1.2.1.11,.1.3.6.1.2.1.12,.1.3.6.1.2.1.13" />

 

Examples for Trap Filters

 

An example Recovering Lost Traps has been provided in <Web NMS Home>/examples/FaultManagement/trap_filters directory. The example trap filter monitors for any loss of traps while being sent from the Agent to the Manager. Click RecoverLostTrapFilter.java to view the example code.

 

Another example, Handling Link Up/Down Traps has been bundled in Web NMS by default. So, all Link Down and Link Up (both SNMP v1 and SNMP v2) traps received by Web NMS will be processed by this trap filter class. It generates a Critical event with the associated interface which has gone down  being set as the entity of the Event, when it receives a Link Down trap and a Clear event for the associated interface when it receives a Link Up trap. Click LinkUpDownTrapFilter.java to view the code.

 


Copyright © 2013, ZOHO Corp. All Rights Reserved.