现在的位置: 首页 > 综合 > 正文

snmp v3 trap(send and receive use net-snmp)

2019年05月30日 ⁄ 综合 ⁄ 共 1575字 ⁄ 字号 评论关闭

1. install net-snmp-5.7.2

2. send and receive snmp v3 trap

From http://www.net-snmp.org/wiki/index.php/TUT:Configuring_snmptrapd_to_receive_SNMPv3_notifications#A_SNMPv3_TRAP

A SNMPv3 TRAP

(for this, I'm making up an engineID to use: 0x8000000001020304)

In a /tmp/snmptrapd.conf file put:

 createUser -e 0x8000000001020304 traptest SHA mypassword AES
 authuser log traptest

Then start snmptrapd pointing to that file (runs in the foreground, uses only that config file and logs to stderr):

 (1)snmptrapd -f -C -c /tmp/snmptrapd.conf -Le
 or(2)snmptrapd -f -C -c /usr/local/net-snmp/share/snmp/snmptrapd.conf -Le -m /usr/local/net-snmp/share/snmp/mibs/xx.mib
 or
(3)snmptrapd -f -C -c /usr/local/net-snmp/share/snmp/snmptrapd.conf -Lf /usr/log -m /usr/local/net-snmp/share/snmp/mibs/xx.mib

-m 指定mib库
-f do not fork from the shell
-C do not read the default configuration files
-L <LOGOPTS> toggle options controlling where to log to
            e:           log to standard error
            o:           log to standard output
            n:           don't log at all
            f file:      log to the specified file
            s facility:  log to syslog (via the specified facility)

Then run snmptrap (in another window) to send a linkup trap:

 snmptrap -v 3 -n "" -a SHA -A mypassword -x AES -X mypassword -l authPriv -u traptest -e 0x8000000001020304 localhost 0 linkUp.0
 -e ENGINE-ID        set security engine ID (e.g. 800000020109840301)

You should see this in the output of the window running snmptrapd:

 2007-10-10 10:19:11 localhost [UDP: [127.0.0.1]:46380]: DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (0) 0:00:00.00 SNMPv2-MIB::snmpTrapOID.0 = OID: IF-MIB::linkUp.0

3. snmptrapd may be failed

error:
couldn't open udp:162 -- errno 98 ("Address already in use")

fix:ps
-ef | grep snmptrapd
to kill snmptrapd

抱歉!评论已关闭.