LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-06-2012, 01:09 AM   #1
Rockin80sRob
LQ Newbie
 
Registered: Aug 2012
Distribution: Red Hat
Posts: 3

Rep: Reputation: 0
net-SNMP Trap Handling


I am trying to figure out SNMP trap handling (net-SNMP 5.5) that came on the RHEL 6 distro.

I'm doing a simple test to verify the trap handler will run a desired program/script and I can't seem to make it work unless I specify the "-f" option and only on the command line. When I try adding it to the default set of options "-Lsd -p /var/run/snmptrapd.pid", it prevents the service from coming up. "service snmptrapd restart" hangs on startup. Edited /etc/init.d/snmptrapd making OPTIONS=-f -Lsd -p /var/run/snmptrapd.pid.

My trap log file (logoption f /var/log/snmptrapd-direct.log) seems to indicate that the traps are being received but again not executing actions on the trap.

I'm triggering the trap by resetting the local snmp agent service: service snmpd restart.

With the "-f" option on the command line:
"/usr/sbin/snmptrapd -f -Lsd -p /var/run/snmptrapd.pid"
the snmpd restart triggers the test script that just echos "Hello World"

For one thing, shouldn't I be able to use the SNMP trap service without having to make this type of change for simple use? Am I doing it wrong? Config files below.

Second, why won't the "-f" option work in the config file.

------------------
/etc/snmp/snmptrapd.conf:
authCommunity log,execute,net public
logoption f /var/log/snmptrapd-direct.log
traphandle default /bin/bash /var/tmp/robs/test

--------------
/etc/snmp/snmpd.conf:
trapsink localhost
view all included .1 80
master agentx
TrapDRUN=yes

--------------
[root@Robs ~]# ps -ef | grep snmp
root 2798 2769 0 Aug05 pts/2 00:00:00 tail -f /var/log/snmptrapd-direct.log
root 5046 1 0 Aug05 ? 00:00:02 /usr/sbin/snmpd -LS0-6d -Lf /dev/null -p /var/run/snmpd.pid
root 5305 1 0 Aug05 ? 00:00:00 /usr/sbin/snmptrapd -Lsd -p /var/run/snmptrapd.pid
root 5716 2801 0 00:32 pts/3 00:00:00 grep snmp

-------------------
snmpd and snmptrap restart(/var/log/snmptrapd-direct.log):

2012-08-06 00:36:03 Robs.Home [192.168.1.101] (via UDP: [127.0.0.1]:39968->[127.0.0.1]) TRAP, SNMP v1, community public
NET-SNMP-MIB::netSnmpNotificationPrefix Enterprise Specific Trap (NET-SNMP-AGENT-MIB::nsNotifyShutdown) Uptime: 0:00:17.78

2012-08-06 00:36:03 Robs.Home [192.168.1.101] (via UDP: [127.0.0.1]:45681->[127.0.0.1]) TRAP, SNMP v1, community public
NET-SNMP-MIB::netSnmpAgentOIDs.10 Cold Start Trap (0) Uptime: 0:00:00.19

2012-08-06 00:36:06 NET-SNMP version 5.5 Stopped.
Stopping snmptrapd

tail: /var/log/snmptrapd-direct.log: file truncated
NET-SNMP version 5.5

--------------------
WITH -f OPTION
[root@Robs ~]# ps -ef | grep snmp
root 2798 2769 0 Aug05 pts/2 00:00:00 tail -f /var/log/snmptrapd-direct.log
root 5782 1 0 00:36 ? 00:00:00 /usr/sbin/snmpd -LS0-6d -Lf /dev/null -p /var/run/snmpd.pid
root 5817 4814 0 00:38 pts/5 00:00:00 /usr/sbin/snmptrapd -f -Lsd -p /var/run/snmptrapd.pid
root 5822 2801 0 00:39 pts/3 00:00:00 grep snmp

------
COMMAND LINE START:
/usr/sbin/snmptrapd -f -Lsd -p /var/run/snmptrapd.pid

and snmpd restart(/var/log/snmptrapd-direct.log):

tail: /var/log/snmptrapd-direct.log: file truncated
NET-SNMP version 5.5 AgentX subagent connected
NET-SNMP version 5.5
2012-08-06 00:40:32 Robs.Home [192.168.1.101] (via UDP: [127.0.0.1]:45681->[127.0.0.1]) TRAP, SNMP v1, community public
NET-SNMP-MIB::netSnmpNotificationPrefix Enterprise Specific Trap (NET-SNMP-AGENT-MIB::nsNotifyShutdown) Uptime: 0:04:28.57

2012-08-06 00:40:32 Robs.Home [192.168.1.101] (via UDP: [127.0.0.1]:43242->[127.0.0.1]) TRAP, SNMP v1, community public
NET-SNMP-MIB::netSnmpAgentOIDs.10 Cold Start Trap (0) Uptime: 0:00:00.19

NET-SNMP version 5.5 AgentX subagent connected


{I get Hello World to term and file}

Last edited by Rockin80sRob; 08-06-2012 at 02:48 AM. Reason: Missed more info I had.
 
Old 08-15-2012, 10:52 PM   #2
Rockin80sRob
LQ Newbie
 
Registered: Aug 2012
Distribution: Red Hat
Posts: 3

Original Poster
Rep: Reputation: 0
Never really found the real solution to this put the product I was working on that I was prototying for was fixed by correcting the community string in /etc/snmp/snmptrapd.conf file. So my real problem is solved but not this question. Stangely now that the trap are being caught, I no longer need the "-f" option. It doesn't seem to matter if the "-f" option is there or not.

BTW - TCPDump and Wireshark helped by confirming the traps were making it to the box.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
snmp trap lamou23 Linux - Networking 4 08-03-2010 04:04 PM
how to send snmp trap & recieve trap in C program minil Programming 3 07-10-2010 09:22 AM
SNMP Trap metallica1973 Linux - Networking 1 11-28-2007 09:14 AM
Snmp Trap shan_nathan Linux - Server 2 09-01-2007 05:49 AM
snmp-trap tied2 Linux - Security 7 07-19-2002 08:20 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration