counting apache traffic from access logs
inspiration from:
http://stackoverflow.com/questions/8019742/measure-traffic-from-apache-access-log
#!/bin/bash
for arg in `find /var/log/httpd/ -maxdepth 3 -type f -name *access.log`
do
echo ${arg}
data=`cat ${arg} | perl -e 'my $sum=0; while(<>) { my ($traffic) = m/\[.+\] ".+" \d+ (\d+)/; $sum += $traffic}; printf("%.3f", $sum/1024/1024/1024)'`
echo "$data GB"
echo
done
Written by Sakari
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Related Tags
#bash
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#