Try running snmptrapd in the foreground with debugging for read_config:traphandle and snmptrapd.


snmptrapd -f -Lo -Dsnmptrapd,read_config:traphandle

When I send a test trap, I get:

read_config:traphandle: registering handler for: default
2004-12-14 21:41:49 NET-SNMP version 5.2.pre1 Started.
snmptrapd: input: a7
snmptrapd: Trap OID: SNMPv2-SMI::enterprises.534.1.11.4.1.0.22
snmptrapd: print_handler
snmptrapd: v2/3 format
2004-12-14 21:41:55 localhost [127.0.0.1]:
SNMPv2-MIB::sysUpTime.0 = Timeticks: (12345) 0:02:03.45 SNMPv2-MIB::snmpTrapOID.0 = OID: SNMPv2-SMI::enterprises.534.1.11.4.1.0.22 SNMPv2-SMI::enterprises.534.1.7.2.1.1.52 = INTEGER: 52 SNMPv2-SMI::enterprises.534.1.7.2.1.2.52 = OID: SNMPv2-SMI::enterprises.534.1.7.15 SNMPv2-SMI::enterprises.534.1.11.3.0 = STRING: "Alex"
snmptrapd: get_traphandler default (80704d8)
snmptrapd: command_handler
snmptrapd: token = '/root/traphandle-help default'
snmptrapd: execute format
snmptrapd: notification_handler


What do you get?

What version of Net-SNMP are you using?

Alex



Russ Woodman wrote:
Alex,

I've attempted to test the traps as shown in the tutorial. When I send a manufactured trap, the debug output from snmptrapd shows this:

trace: netsnmp_udp_recv(): snmpUDPDomain.c, 133:
netsnmp_udp: recvfrom fd 9 got 96 bytes (from 127.0.0.1)
trace: _sess_process_packet(): snmp_api.c, 4892:
sess_process_packet: session 0x808ba90 fd 9 pkt 0x808f4b8 length 96
trace: _sess_process_packet(): snmp_api.c, 4916:
sess_process_packet: pre-parse fail
trace: _sess_read(): snmp_api.c, 5210:
sess_read: not reading 6 (fdset 0xbffffc70 set 0)
trace: _sess_read(): snmp_api.c, 5210:
sess_read: not reading 5 (fdset 0xbffffc70 set 0)
trace: _sess_read(): snmp_api.c, 5210:
sess_read: not reading 3 (fdset 0xbffffc70 set 0)
trace: snmp_sess_select_info(): snmp_api.c, 5622:
sess_select: for all sessions: 9 6 5 3

And nothing is recorded in the /tmp/snmptrapd.log file. I'm cutting and pasting things directly from the tutorial and using the traphandle.sh you outlined below.

Any ideas?

Russ

Alex Burger wrote:


Hi Russ.

Russ Woodman wrote:

Hi,

I am attempting to receive traps from various devices on my network (Copper Mountain DSLAMs, Cisco routers, etc.) so that I can then funnel the traps into Nagios for network monitoring. However, nothing I have tried for the last three or more months has allowed me to receive/handle any traps sent by any devices. Below are some relevant files and configuration.



It looks like your script is not processing the output of snmptrapd correctly. Snmptrapd will output multiple lines to the handler. If you try the following snmptrapd.conf and traphandle.sh, it should work. The script is a slightly modified version of the snmptrap tutorial at:


http://www.net-snmp.org/tutorial-5/commands/snmptrap.html

snmptrapd.conf:
traphandle default /usr/local/bin/traphandle.sh

traphandle.sh:
#!/bin/bash
LOGFILE="/tmp/snmptrapd.log"
read host
read ip
vars=
while read oid val
do
  if [ "$vars" = "" ]
  then
    vars="$oid = $val"
  else
    vars="$vars, $oid = $val"
  fi
done
echo trap: $1 $host $ip $vars >> ${LOGFILE}
exit 0





-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/
_______________________________________________
Net-snmp-users mailing list
[EMAIL PROTECTED]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users

Reply via email to