
SNMP Trap Handler
=================


Setting up SNMP traps
---------------------

To get jffnms receiving traps, you will need to install a snmp trapd from
net-snmp (formerly CMU snmp) package or one that works similarly.  In
the configuration file for snmptrapd, eg /etc/snmp/snmptrapd.conf put a line
like:
traphandle default php -q /opt/jffnms/engine/trap_receiver.php

This tells snmptrapd to run that trap receiver program every time it gets
a trap.  See snmptrapd.conf(5) manual page for details about what this does.

Please remember to use the 'printNumericOids yes' option in your /etc/snmp/snmp.conf
or include -On in the snmptrapd command line


Configuring SNMP Trap Events
----------------------------

To configure a trap event, you will need to know the trap OID and the order
of the variable bindings (if you are going to use them).  You then go to
the menu Administration->Events->SNMP Trap Events. Click on Add to make a new
trap event

The following fields are used:
  Action - You can edit or delete an existing trap event type here
  ID - A unique id for the type
  OID Match - The trap OID to match, this is NOT the variable bindings OID.
  Interface, Username, State and Extra Info  Fields - Which variable binding
  will be used to fill in a particular field.  Eg putting 2 in the username
  field means the value for varbind 2 for the trap will be used as the
  username.  Putting * puts all the fields on the line, good for working
  out what varbinds give what information. Leaving blank means this 
  field is null.

An example:

You're worried the fan on your router might be broken, so you want to 
know if the fan is broken trap is sent, 1.3.6.1.4.1.9.9.13.3.0.4
This trap has 5 variable bindings:
1 the enterprise of the trap, for this trap it is enterprises.9.9.13.3
2 Name of the fan that has the problem, eg ps2
3 The IP address of the source of the trap
4 The SNMP community of the trap
5 The state of the trap (its a number 1-5)

Most of this is pretty useless, we only really need to know something has
happened and then to what fan is it.

So we setup the event to fill in varbind 2 into the info field and then
setup a new event which prints
Problem with fan at <info>.

So the result on the events screen is something like

	Problem with fan at ps2.


Tables Description
------------------

The traps table is where the raw traps come in from the snmp trap daemon.
They are stored here and then analyzed by the consolidator.  The fields have the following meanings:

    id - incremental unique id
    date - date the trap was recieved
    ip - IP address the trap came from
    trap_oid - The OID (Object Identifier) of the trap.
    analized - Has the trap been processed by the consolidator (0 means not yet)

Each trap has a number of variable bindings.  These bindings are put into
a table before processing.

    id - incremental unique id
    trapid - The id of the trap that these variable bindings are for, foriegn key to traps.id
    oid - Object ID of the variable binding, not really used in jffnms
    value - The value of the binding, eg the number or variable measurement.
    oidid - sequence number of the OID, gives the order the bindings came in from in the trap.  
	EG the first varbind in every trap will have 1 here.
