Aggregate Traffic Used From a Combined Apache Logfile
Tuesday, May 8th, 2007Today I just wanted to know the traffic sent out by one of our apaches for a certain client. Our administrator came up with the following code that did it - awesome!
for file in [path to your logifes]/*.bz2;
do
echo -n " $(basename $file) " >> ~/traffic.out;
bzcat $file | awk ‘BEGIN{ regex="^/clientFolder/";summe=0;} { if (match($7,regex) && $9 == 200) {summe=summe+$10}} END {print summe/1024/1024}’ >> ~/traffic.out ;
done
This script will go through all logfiles and sum up the bytes transfered for all files in the clientFolder.