Skip to content

Instantly share code, notes, and snippets.

@leobossmann
Created August 14, 2014 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leobossmann/02881bc99c922b19c08a to your computer and use it in GitHub Desktop.
Save leobossmann/02881bc99c922b19c08a to your computer and use it in GitHub Desktop.
Get cumulated traffic usage from webalizer stats, send email if over limit
#!/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