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 :-



I came up with the following one liner :-

cat other_vhosts_access.log.1 [.. add any additional files here ..] | \
tr :][ " " | \
awk '{ sum[$6] += $15 }
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: ,