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

No comments

(optional field)
(optional field)

Comment moderation is enabled on this site. This means that your comment will not be visible until it has been approved by an editor.

Remember personal info?
Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.