Hey everyone. Running 14.04 LTS for a Zabbix installation. I've followed several guides but I can't seem to get snmptrapd to do anything. I'm thinking it's not even running but because it's a subset of snmpd instead of its own service I don't know how to check.
I've edited /etc/init.d/snmpd to add TRAPDRUN=yes (also tried with quotes to match SNMPDRUN's option), and I have tried logging to syslog, a dedicated log file and straight to the output stream. The best I've gotten is to get an incoming UDP connection in the log but never an actual trap.
Below are my configuration files:
/etc/init.d/snmpd:
/etc/snmp/snmp.conf (comments trimmed):Code:#! /bin/sh -e ### BEGIN INIT INFO # Provides: snmpd snmptrapd # Required-Start: $network $remote_fs $syslog # Required-Stop: $network $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: SNMP agents # Description: NET SNMP (Simple Network Management Protocol) Agents ### END INIT INFO # # Author: Jochen Friedrich <jochen@scram.de> # set -e . /lib/lsb/init-functions export PATH=/sbin:/usr/sbin:/bin:/usr/bin test -x /usr/sbin/snmpd || exit 0 test -x /usr/sbin/snmptrapd || exit 0 # Defaults OLD_MIBS_DIR="/usr/share/mibs/site:/usr/share/snmp/mibs:/usr/share/mibs/iana:/usr/share/mibs/ietf:/usr/share/mibs/netsnmp" MIBS_DIR="/usr/share/snmp/mibs:/usr/share/snmp/mibs/iana:/usr/share/snmp/mibs/ietf" export MIBDIRS="$MIBS_DIR:$OLD_MIBS_DIR" SNMP_PID="/run/snmpd.pid" TRAPD_PID="/run/snmptrapd.pid" SNMPDRUN="yes" SNMPDOPTS="-Lsd -Lf /dev/null -p $SNMP_PID" TRAPDRUN=Yes TRAPDOPTS="-Lsd -Lo -p $TRAPD_PID" # Reads config file (will override defaults above) [ -r /etc/default/snmpd ] && . /etc/default/snmpd # Cd to / before starting any daemons. cd / case "$1" in start) log_daemon_msg "Starting network management services:" # remove old symlink with previous version if [ -L /var/run/agentx ]; then rm -f /var/run/agentx fi if [ ! -d /var/run/agentx ]; then mkdir -p /var/run/agentx fi if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then start-stop-daemon --quiet --start --oknodo --exec /usr/sbin/snmpd \ -- $SNMPDOPTS log_progress_msg " snmpd" fi if [ "$TRAPDRUN" = "yes" -a -f /etc/snmp/snmptrapd.conf ]; then start-stop-daemon --quiet --start --oknodo --exec /usr/sbin/snmptrapd \ -- $TRAPDOPTS log_progress_msg " snmptrapd" fi ;; stop) log_daemon_msg "Stopping network management services:" start-stop-daemon --quiet --stop --oknodo --exec /usr/sbin/snmpd && [ ! -f $SNMP_PID ] || rm $SNMP_PID log_progress_msg " snmpd" start-stop-daemon --quiet --stop --oknodo --exec /usr/sbin/snmptrapd && [ ! -f $TRAPD_PID ] || rm $TRAPD_PID log_progress_msg " snmptrapd" ;; restart) log_daemon_msg "Restarting network management services:" start-stop-daemon --quiet --stop --oknodo --exec /usr/sbin/snmpd && [ ! -f $SNMP_PID ] || rm $SNMP_PID start-stop-daemon --quiet --stop --oknodo --exec /usr/sbin/snmptrapd && [ ! -f $TRAPD_PID ] || rm $TRAPD_PID # Allow the daemons time to exit completely. sleep 2 if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then start-stop-daemon --quiet --start --exec /usr/sbin/snmpd -- $SNMPDOPTS log_progress_msg " snmpd" fi if [ "$TRAPDRUN" = "yes" -a -f /etc/snmp/snmptrapd.conf ]; then # Allow snmpd time to start up. sleep 1 start-stop-daemon --quiet --start --exec /usr/sbin/snmptrapd -- $TRAPDOPTS log_progress_msg " snmptrapd" fi ;; reload|force-reload) log_daemon_msg "Reloading network management services:" if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then start-stop-daemon --quiet --stop --signal 1 \ --pidfile /var/run/snmpd.pid --exec /usr/sbin/snmpd log_progress_msg " snmpd" fi ;; status) status=0 if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then status_of_proc /usr/sbin/snmpd snmpd || status=$? fi if [ "$TRAPDRUN" = "yes" -a -f /etc/snmp/snmptrapd.conf ]; then status_of_proc /usr/sbin/snmptrapd snmptrapd || status=$? fi exit $status ;; *) echo "Usage: /etc/init.d/snmpd {start|stop|restart|reload|force-reload|status}" exit 1 esac exit 0
/etc/snmp/snmptrapd.conf:Code:agentAddress udp:161,udp6:[::1]:161,udp:162 view systemonly included .1.3.6.1.2.1.1 view systemonly included .1.3.6.1.2.1.25.1 # Full access from the local host #rocommunity public localhost # Default access to basic system info rocommunity public default -V systemonly # Full read-only access for SNMPv3 rouser authOnlyUser # Full write access for encrypted requests # Remember to activate the 'createUser' lines above #rwuser authPrivUser priv ############################################################################### # # SYSTEM INFORMATION # # Note that setting these values here, results in the corresponding MIB objects being 'read-only' # See snmpd.conf(5) for more details sysLocation Sitting on the Dock of the Bay sysContact Me <me@example.org> # Application + End-to-End layers sysServices 72 # # Process Monitoring # # At least one 'mountd' process proc mountd # No more than 4 'ntalkd' processes - 0 is OK proc ntalkd 4 # At least one 'sendmail' process, but no more than 10 proc sendmail 10 1 # Walk the UCD-SNMP-MIB::prTable to see the resulting output # Note that this table will be empty if there are no "proc" entries in the snmpd.conf file # # Disk Monitoring # # 10MBs required on root disk, 5% free on /var, 10% free on all other disks disk / 10000 disk /var 5% includeAllDisks 10% # Walk the UCD-SNMP-MIB::dskTable to see the resulting output # Note that this table will be empty if there are no "disk" entries in the snmpd.conf file # # System Load # # Unacceptable 1-, 5-, and 15-minute load averages load 12 10 5 # Walk the UCD-SNMP-MIB::laTable to see the resulting output # Note that this table *will* be populated, even without a "load" entry in the snmpd.conf file ############################################################################### # # ACTIVE MONITORING # # send SNMPv1 traps trapsink localhost public #trap2sink localhost public # send SNMPv2c INFORMs #informsink localhost public # Note that you typically only want *one* of these three lines # Uncommenting two (or all three) will result in multiple copies of each notification. # # Event MIB - automatically generate alerts # # Remember to activate the 'createUser' lines above iquerySecName internalUser rouser internalUser # generate traps on UCD error conditions defaultMonitors yes # generate traps on linkUp/Down linkUpDownNotifications yes # # Arbitrary extension commands # extend test1 /bin/echo Hello, world! extend-sh test2 echo Hello, world! ; echo Hi there ; exit 35 #extend-sh test3 /bin/sh /tmp/shtest # # AgentX Sub-agents # # Run as an AgentX master agent master agentx # Listen for network connections (from localhost) # rather than the default named socket /var/agentx/master #agentXSocket tcp:localhost:705
/etc/default/snmpd:Code:authCommunity execute (our snmpv3 community) authCommunity execute (our snmpv3 private community) authCommunity log,execute,net public snmpTrapdAddr udp:162 logOption -Lf /var/log/syslog #perl do "/usr/bin/zabbix_trap_receiver.pl" #logoption f /var/log/snmptrap.log logoption s 1 traphandle default /usr/bin/zabbix_trap_receiver.pl disableAuthorization yes
Trap I am using to test:Code:# This file controls the activity of snmpd and snmptrapd # Don't load any MIBs by default. # You might comment this lines once you have the MIBs downloaded. #export MIBS= # snmpd control (yes means start daemon). SNMPDRUN=yes # snmpd options (use syslog, close stdin/out/err). SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -g snmp -I -smux,mteTrigger,mteTriggerConf -p /var/run/snmpd.pid' # snmptrapd control (yes means start daemon). As of net-snmp version # 5.0, master agentx support must be enabled in snmpd before snmptrapd # can be run. See snmpd.conf(5) for how to do this. TRAPDRUN=YES # snmptrapd options (use syslog). #TRAPDOPTS='-Lsd -p /var/run/snmptrapd.pid' TRAPDOPTS='-n -On -t -Lf /var/log/snmptrap.log -p /var/run/snmptrapd.pid'
System log entry whenever I do a test:Code:snmptrap -v1 -c public localhost .1.3.6.1.6.3.1.1.5.2 0 0 "" "" .1.3.6.1.4.1 s "hello"
Any help would be appreciated. I must be missing something really obvious but I've spent too long down this rabbit hole to see where I'm going wrong. Thanks in advance.Code:Oct 18 10:10:00 ms02 snmpd[12240]: Connection from UDP: [127.0.0.1]:53079->[127.0.0.1]:162



Adv Reply
Bookmarks