pero on anything

Aggregate Traffic Used From a Combined Apache Logfile

Today 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!


#!/bin/sh
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.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">