(Optional) Configuring the Trap Function
Prerequisites
Before configuring a device to send traps, confirm that the information center has been enabled. If the information center is not enabled, run the info-center enable command to enable it.
Procedure
- Run:
system-view
The system view is displayed.
- Enable the trap function.
Enable the trap function for a module.
Run:
snmp-agent trap enable
The trap function is enabled for all modules.
Run:
snmp-agent trap enable feature-name feature-name [ trap-name trap-name ]
The trap function is enabled for a specified module.
Enable the trap function for an interface.
Run:
snmp-agent trap enable feature-name ifnet trap-name { linkdown | linkup }
The trap function is enabled on all interfaces.
By default, the trap function is disabled on all interfaces. When parameters linkdown and linkup are configured for all ifnet modules, the device sends a trap to the NMS upon an interface status change. When an interface frequently sends traps to the NMS because of frequent status changes, you can disable the interface status trap function on the interface to reduce the NMS loads. The procedure is as follows:
Run:
interface interface-type interface-number
The interface view is displayed.
Run:
undo enable snmp trap updown
The interface status trap function is disabled.
Run:
quit
Return to the system view.
- Run:
snmp-agent trap source interface-type interface-number
The source interface for traps is specified.
After the source interface is specified, the IP address of the source interface is used as the source IP address for sending traps. This helps the NMS identify the trap source. The source interface that sends traps must have an IP address; otherwise, the commands will fail to take effect. To ensure device security, it is recommended that you set the source IP address to the local loopback address.
The source interface specified on the switch for traps must be consistent with that specified on the NMS; otherwise, the NMS does not accept the traps sent from the switch.
- Run:
snmp-agent trap queue-size size
The queue length of traps sent to the destination host is set.
The default queue length of traps sent to the destination host is 100.
The queue length depends on the number of generated traps. If the switch frequently sends traps to the NMS, set a longer queue length to prevent traps from being lost.
- Run:
snmp-agent trap life seconds
The lifetime of traps is set.
The default lifetime of traps is 300 seconds.
The lifetime of each trap depends on the number of generated traps. If the switch frequently sends traps to the NMS, set a longer lifetime to prevent traps from being lost.