Last active
March 2, 2025 00:55
-
-
Save casebeer/182854eaf9608c74161f518efc294fc4 to your computer and use it in GitHub Desktop.
snmptrapd logging to rsyslogd and snmptrapd.log with logrotate rotation on Ubuntu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# snmptrapd.log files as per `systemctl edit snmptrapd.service` | |
# (in addition to logging traps to syslog) | |
/var/log/snmptrapd.log | |
{ | |
rotate 7 | |
daily | |
missingok | |
notifempty | |
delaycompress | |
compress | |
postrotate | |
/usr/bin/systemctl restart snmptrapd.service | |
endscript | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
authCommunity log public | |
disableAuthorization yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Service] | |
ExecStart= | |
# log to syslog daemon facility and append to snmptrapd.log | |
ExecStart=/usr/sbin/snmptrapd -n -f -A -Lf /var/log/snmptrapd.log -Lsd | |
# | |
# n.b. set these options via `systemctl edit snmptrapd.service`, NOT via /etc/defaults/snmptrapd, which is ignored | |
# | |
# n.b. option "-LSwd" (uppercase 'S' -LS<level><facility> for syslog w/level + facility) | |
# which is proivded as example does NOT work. | |
# You MUST use the facility-only syslog option e.g. -Lsd (lowercase 's' -Ls<facility>) | |
# | |
# Options: | |
# -n no reverse DNS lookups on IPs | |
# -f don't fork | |
# -A append to logfile, don't overwrite | |
# -a ignore authenticationFailure traps | |
# -M MIB dirlist | |
# -m MIB module list | |
# -t DISABLE logging traps to syslog (runs hook scripts only) | |
# -Lf log to file | |
# -Ls<level><facility> log to syslog |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment