View Single Post
Old 08-30-2002, 12:06 PM  
whyaskwhy
Registered User
 
Industry Role:
Join Date: Aug 2002
Posts: 61
Another useful tool...
Know your refers and mail the report to view every hour.
Let's call this referdaemon.sh
Oh yeah, this is for a standard apache log on unix, you might need to change the field positioning print $11 to the proper field for referers..


#!/bin/sh

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/adm/bin
TAIL=`which tail`
GREP=`which grep`
SORT=`which sort`
UNIQ=`which uniq`
AWK=`which awk`

cd /var/log/httpd [location of log directory}

$TAIL -n 40000 mywebsiteslogfile.com.log >test.log
cat test.log |$AWK '{print $11}' >refererreport
cat refererreport |$SORT -rn |$UNIQ -c |$SORT >test
cat test |$GREP -v "mywebsite.com" >hoap [this will remove your own domain refering to itself]
cat hoap |$GREP -v "\"-\"" >refers [this will remove direct requests]
cat refers |mail -s "Refer Report" [email protected]



Just setup a root cron to run referdeamon.sh every hour and you are set.

:-)

Last edited by whyaskwhy; 08-30-2002 at 12:19 PM..
whyaskwhy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote