snmptrapd on systemd

1,190 views
Skip to first unread message

Robert Mckennon

unread,
Sep 8, 2014, 1:54:09 PM9/8/14
to jax...@googlegroups.com
Any systemd guru's out there?

Running on CentOS7.

I'm having a problem with snmptrapd.  When I start it from the commandline with:  snmptrapd -Lf /var/log/snmp-traps.log --disableAuthorization=yes
it works just fine!  I can send snmptraps from my routers to the server and they show up in the /var/log/snmp-traps.log file.

But when I kill the process, and start snmptrapd from systemd with: 
systemctl start snmptrapd
it starts without any errors, runs as the root user, and listens on port 162, but the traps are not showing up in the snmp-traps.log file.

I had to modify 2 snmptrap config files to get it to start from systemd and run without errors...
/etc/sysconfig/snmptrapd     
   OPTIONS="-Lf /var/log/snmp-traps.log"

/etc/snmp/snmptrapd.conf
  disableAuthorization yes


Here's an output from the status...

[root@splunk ~]# systemctl status snmptrapd
snmptrapd.service - Simple Network Management Protocol (SNMP) Trap Daemon.
   Loaded: loaded (/usr/lib/systemd/system/snmptrapd.service; enabled)
   Active: active (running) since Mon 2014-09-08 13:40:07 EDT; 4min 55s ago
 Main PID: 5379 (snmptrapd)
   CGroup: /system.slice/snmptrapd.service
           └─5379 /usr/sbin/snmptrapd -Lf /var/log/snmp-traps.log -f

Sep 08 13:40:07 splunk.peak10.services.monetra.com systemd[1]: Starting Simple Network Management Protocol (SNMP) Trap Daemon....
Sep 08 13:40:07 splunk.peak10.services.monetra.com systemd[1]: Started Simple Network Management Protocol (SNMP) Trap Daemon..


[root@splunk ~]# netstat -anp |grep udp
udp        0      0 0.0.0.0:162             0.0.0.0:*                           5379/snmptrapd     

[root@splunk log]# ps -elf |grep trap
4 S root      5379     1  0  80   0 - 56186 poll_s 13:40 ?        00:00:00 /usr/sbin/snmptrapd -Lf /var/log/snmp-traps.log -f



Any thoughts on solving this conundrum this would be greatly appreciated!

Rob.

Robert Mckennon

unread,
Sep 8, 2014, 2:40:48 PM9/8/14
to jax...@googlegroups.com
solved.... I don't know why this was happening, but I just deleted the log file, then restarted snmptrapd via:  systemctl restart snmptrapd, and viola, it worked.  Not sure why it wouldn't append to the current residing file, but it works fine now.

Rob.

p.s. thanx Brad!


Gene Cronk

unread,
Sep 8, 2014, 3:41:00 PM9/8/14
to jax...@googlegroups.com
Just a guess here, but starting it as root may have either set the file permissions for root (and starting the daemon the "normal" way couldn't write to the file), and/or done something funky with the SELinux attributes.

--
You received this message because you are subscribed to the Google Groups "JaxLUG" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jaxlug+un...@googlegroups.com.
To post to this group, send email to jax...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages