1. create a new file called /etc/snmp/snmptrapd.conf

-------------------Content--------------------------
###########################################################################
#
# snmptrapd.conf
#
#   - created by the snmpconf configuration program
#
###########################################################################
# SECTION: Output formatting for traps received.
#
#   Output from snmptrapd is formatted according to the
#   rules defined by the formatting configuration directives.


# format1: How SNMPv1 traps are formatted.
#   See the snmptrapd.conf manual page for format string details.
#   arguments: formatstring

# format2: How SNMPv2 and SNMPv3 traps are formatted.
#   See the snmptrapd.conf manual page for format string details.
#   arguments: formatstring

authCommunity log,execute,net public
disableAuthorization yes
logOption f /var/log/snmptraps.log

format1 %V\n% Agent Address: %A \n PDU Source Hostname: %B \n Date: 
%#02.2h:%#02.2j:%#02.2k %#02.2m/%#02.2l/%#y \n Enterprise OID: %N \n 
Trap Type: %W \n Trap Sub-Type: %q \n Community/Infosec Context: %P \n 
Uptime: %#T \n Description: %W \n PDU Attribute/Value Pair Array:\n%v \n 
-------------- \n

format2 %V\n% PDU Source Hostname: %B \n Date: %#02.2h:%#02.2j:%#02.2k 
%#02.2m/%#02.2l/%#y \n Community/Infosec Context: %P \n PDU 
Attribute/Value Pair Array:\n%v \n -------------- \n

snmpTrapdAddr 128.224.165.250:162
-------------------Content--------------------------

2. create a new mib file called /usr/share/snmp/mibs/TRAP-TEST-MIB.txt
--------------content-------------------
TRAP-TEST-MIB DEFINITIONS ::= BEGIN
     IMPORTS ucdExperimental FROM UCD-SNMP-MIB;

demotraps OBJECT IDENTIFIER ::= { ucdExperimental 990 }

demo-trap TRAP-TYPE
     STATUS current
     ENTERPRISE demotraps
     VARIABLES { sysLocation }
     DESCRIPTION "This is just a demo"
     ::= 17

END
--------------content-------------------
3. natstat -nap
4. killall -9 snmptrapd
5. snmptrapd -D -Le
6. tail -f /var/log/snmptraps.log
7.snmptrap -v 1 -c public 128.224.165.250:162 TRAP-TEST-MIB::demotraps 
localhost 6 17 '' SNMPv2-MIB::sysLocation.0 s "Just here"

In the file /var/log/snmptraps.log:
NET-SNMP version 5.4
  Agent Address: localhost
  PDU Source Hostname: <UNKNOWN>
  Date: 00:59:37 01/01/1970
  Enterprise OID: UCD-SNMP-MIB::ucdExperimental.990
  Trap Type: Enterprise Specific
  Trap Sub-Type: .17
  Community/Infosec Context: TRAP, SNMP v1, community public
  Uptime: 0:59:29.16
  Description: Enterprise Specific
  PDU Attribute/Value Pair Array:
SNMPv2-MIB::sysLocation.0 = STRING: Just here
  --------------


------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to