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.
|