Created
August 14, 2014 14:10
-
-
Save leobossmann/02881bc99c922b19c08a to your computer and use it in GitHub Desktop.
Get cumulated traffic usage from webalizer stats, send email if over limit
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
#!/bin/bash | |
LIMIT=45000000 | |
USAGE=0 | |
for dir in /path/to/stats/*/ | |
do | |
LOCAL_USAGE=`head -n 2 $dir/webalizer.hist | tail -n 1 | cut -d" " -f6` | |
USAGE=$(($USAGE + $LOCAL_USAGE)) | |
done | |
if [ $USAGE -gt $LIMIT ] | |
then | |
echo "Traffic limit of $LIMIT reached" | mail -s "Traffic limit of $LIMIT reached" email@host.tld | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment