Created
May 1, 2015 01:27
-
-
Save sean-kang/d1b34d0e3df57d152435 to your computer and use it in GitHub Desktop.
Outgoing spam alert cron script
This file contains hidden or 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
#!/usr/bin/env bash | |
HOURLY_THRESHOLD=200 | |
total=$(cat /var/log/mail.log | sma -q -d -D 00,59 2>&1 | grep Total | head -1 | awk '{print $4}') | |
[ -z $total ] && total=0 | |
if [ $total -gt $HOURLY_THRESHOLD ]; then | |
hostname=$(hostname -f) | |
cat /var/log/mail.log | sma -q -d -D 00,59 2>&1 | grep -i -A13 'top envelope senders' | mutt -e "set content_type=text/plain" -s "More than ${HOURLY_THRESHOLD} hourly outgoing mails in ${hostname}" [email protected] 2>&1 > /dev/null | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment