This is the method that was used in Example 16-2 to send traps, along with its v2 equivalent (see the Javadoc API for a description of the parameters):
sendV1Trap( int generic, int specific, java.util.Vector varBindList )
sendV2Trap( SnmpOid trapOid, java.util.Vector varBindList )
Using these methods, you must first define the trap group in an access control list. See "Access Control Lists (ACL)" for a formal definition of the trap group and instructions for defining the ACL file when starting the agent. By default, these lists are file-based, but you may implement other mechanisms, as described in "Custom Access Control".
In this example we provide the following template file:
acl = { ... } trap = { { trap-community = public hosts = yourmanager } } |
The trap group lists all of the hosts to which the SNMP protocol adaptor will send every trap. A community definition associates a community name with a list of hosts specified either by their hostname or by their IP address. All hosts in a community definition will receive the trap in a PDU identified by the community name.
Since access control and trap recipients share the same file, you must fully define the access control when you want to send traps using the ACL mechanism.
Given this definition, traps will be sent to a host called yourmanager, and the community string of the trap PDU would contain the value public. By adding community definitions to this file, you can specify all hosts which will receive traps along with the community string for each host or group of hosts.
If the ACL file is not defined, or if the trap group is empty, the default behavior of these methods is to send a trap only to the localhost.