Skip to content

Instantly share code, notes, and snippets.

@CNG
Created October 25, 2013 03:24
Show Gist options
  • Save CNG/7149013 to your computer and use it in GitHub Desktop.
Save CNG/7149013 to your computer and use it in GitHub Desktop.
Count Apache errors by date
date;
cd /var/log/apache2; mkdir combined_error_logs;
rsync -a -e ssh root@www1:/var/log/apache2/error* combined_error_logs/www1;
rsync -a -e ssh root@www2:/var/log/apache2/error* combined_error_logs/www2;
date;
cd combined_error_logs/www1; gunzip *.gz; cd ../..;
cd combined_error_logs/www2; gunzip *.gz; cd ../..;
date;
cat combined_error_logs/*/* | sed -r -n 's/^\[(\w+) (\w+ \w+) ..:..:.. (\w+).+/\3 \2 \1/p' | awk '{count[$1]++}END{for(j in count) print j" "count[j]}' FS=: | sort > errors_by_date.$(date +%Y-%m-%d).txt;
rm -rf combined_error_logs;
date;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment