SNMPtrap logrotate

I worked this days to troubleshoot why our monitoring tool hardrive gets full very fast. Looks like that service snmptrapd that collects snmp traps is using all the space.Here is my logrotate script to fix it. The trick is that you need to use logrotate to restart the service at every “cleaninig”

root@hostname:$ cat /etc/logrotate.d/snmptrapd
/var/log/snmptrap/*.log {
hourly
missingok
rotate 24
delaycompress
notifempty
compress
postrotate
/bin/systemctl restart snmptrapd.service > /dev/null 2>/dev/null || true
endscript
}

Leave a reply:

Your email address will not be published.

Site Footer