Meaning and write of SNMP trap

Source: Internet
Author: User
Tags snmp

In the SNMP definition, we know that it has the Trap function. What does this function mean? Let's start with what it means. First, we can translate traps into traps or traps in SNMP. The agent in the managed device can report errors to the network management workstation at any time, such as pre-defined threshold out-of-bounds. The agent does not need to wait until the management workstation polls the agent to receive these errors. These errors are well known SNMP traps ).

In this method, you can use a network management workstation to query a device if it is still reachable ), for more information.

Using snmptrapd to receive SNMP trap information and write it into a specific document recently, we are studying snmp trap and snmptrapd information. So far, we have not found out how to Enable snmp trap to automatically send information. However, you can use snmptrapd to receive SNMP trap information and write it into a specific document.

I. Management end

Create/usr/share/snmp/snmptrapd. conf is used on my machine. Different machines may be stored in/etc/snmp,/usr/local/share/snmp/, and experiment with each other based on different situations)

Add the following line:

Set access permissions for all users: executable, record, and pass:

Authcommunity execute, log, net public

Set traphandle (that is, when you receive the OID information of. 1.3.6.1.4.1.2021.251.1, run test. pl)

Traphandle. 1.3.6.1.4.1.2021.251.1/home/long/test. pl

Here. 1.3.6.1.4.1.2021.251.1 is an Enterprise-OID

/Home/long/test. pl is a processing perl file:

#!/usr/bin/perl
use strict;
my $file="file.trap";
open(HANDOUT,">>./$file");
while(<STDIN>)
{
    print HANDOUT "$_";
}

This is the packet sent by snmp trap into file. in the trap file, start/etc/init. d/snmpd start, which must be started first, and then use "snmptrapd-c/etc/snmp/snmptrapd. conf"

Ii. Proxy

Enter the following command on another machine:

Snmptrap-v 2c-c public 192.168.126.99 "". 1.3.6.1.4.1.2021.251.1 sysLocation.0 s "longtengfei"

192.168.126.99 is the management end address. 1.3.6.1.4.1.2021.251.1 corresponds to the Enterprise-OID in snmptrapd. conf of the management end.

After the execution is completed, the file content in file. trap (in the/root/file. trap directory) becomes:

<UNKNOWN> UDP: [192.168.126.200]: 20177disman-event-mib: sysUpTimeInstance 3: 1: 37: 20: 21

SNMPv2-MIB: snmpTrapOID.0 UCD-SNMP-MIB: ucdStartSNMPv2-MIB: sysLocation.0 longtengfei

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.