Apache Logs Rough Data Transfer

how to get a rough daily and average data transfer figure from logs

I needed to figure out how much data transfer one of my clients sites was using today, and after a bit of a headstart from these sites :-

http://www.linuxjournal.com/article/9257?page=0,0

http://www.chemie.fu-berlin.de/chemnet/use/info/gawk/gawk_12.html

I came up with the following one liner :-

cat other_vhosts_access.log.1 [.. add any additional files here ..] | \
tr :][ " " | \
awk '{ sum[$6] += $15 }
END {
for(r in sum) {
print r,sum[r];
tot += sum[r];
numrows += 1
};
printf "Average Daily Transfer : %.2fmb\n", tot/numrows/1024/1024
}'

(note: Remember to either remove or replace "[.. add any additional files here ..]")

(note: it was a one liner before i multi lined it for formatting purposes here)

The numbers to use for $6 and $15 (field positions you will need to experiment with your log files until you get the right values ( $6 should be the field that contains the date, and $15 should be the field that contains the total bytes transferred )

Monday 27 January 2014 at 2:15 pm | | Apache, Linux | No comments
Tags: ,

Deny .svn Directory Access With .htaccess

The following little snippet in a .htaccess file in your web root will block access to .svn directories via http.

# Block access to .svn files
RewriteRule ^(.*/)?\.svn - [F,L]
ErrorDocument 403 "Access Forbidden"

I found this by googling but the original had a trailing / on the .svn in the RewriteRule.   I've removed this as with out it, it appears that /.svn/ would be blocked, but /.svn would still get through.

Friday 28 December 2012 at 8:56 pm | | Apache, Linux | No comments
  • 1