aquaballoon

Snort Cron Job: Sent to Mail

Apr 26th, 2012
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.33 KB | None | 0 0
  1. dpkg-reconfiugre snort-mysql
  2.  
  3. /etc/cron.daily/5snort
  4.  
  5. #!/bin/sh -e
  6.  
  7. test -f /usr/sbin/snort || exit 0
  8.  
  9. LOGFILE=/var/log/snort/alert
  10. PATH=/bin:/usr/bin:/sbin:/usr/sbin
  11. CONFIG=/etc/snort/snort.debian.conf
  12. . $CONFIG
  13.  
  14. # Don't generate stats if we are configured not to
  15. [ "$DEBIAN_SNORT_SEND_STATS" = "false" ] && exit 0
  16.  
  17. export DEBIAN_SNORT_STATS_RCPT DEBIAN_SNORT_STATS_THRESHOLD
  18.  
  19. # Just in case it's not properly configured for whatever reason
  20. [ -z "$DEBIAN_SNORT_STATS_THRESHOLD" ] && DEBIAN_SNORT_STATS_THRESHOLD=1
  21. [ -z "$DEBIAN_SNORT_STATS_RCPT" ] && DEBIAN_SNORT_STATS_RCPT=root
  22.  
  23. # Cannot use logrotate to rotate these logfiles...
  24. # 'rotate' saved RAW-Ethernet streams
  25. # New snort has different naming scheme, old one still here for upgrades
  26. find /var/log/snort -name "snort-*@*.log" -mtime +15 | xargs --no-run-if-empty rm
  27. find /var/log/snort -name "tcpdump.log.*" -mtime +15 | xargs --no-run-if-empty rm
  28. find /var/log/snort -name "snort.log.*" -mtime +15 | xargs --no-run-if-empty rm
  29.  
  30. # Mail snort stats
  31. if [ -s $LOGFILE ]; then
  32.     (echo "To: $DEBIAN_SNORT_STATS_RCPT"; snort-stat -a -t $DEBIAN_SNORT_STATS_THRESHOLD < $LOGFILE) | sendmail -t
  33. fi
  34.  
  35. # Restarting snort is now handled by the logrotate configuration.
  36. # The 'intelligence' of not to start in certain startup-modes moved
  37. # to the init.d script as well.
  38.  
  39. exit 0
Advertisement
Add Comment
Please, Sign In to add comment